You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eon/README.md

134 lines
2.3 KiB

4 years ago
# Eon programming language V0.9.6.1
5 years ago
My computer programming language made with LEX/YACC written in C. (interpreted)
4 years ago
# Downloads
4 years ago
Supports both linux and windows, download link for current build can be found here: [download link](https://githacks.org/xerox/eon/-/tags)
4 years ago
5 years ago
# Hello World.
4 years ago
Hello world in Eon.
4 years ago
4 years ago
```c
4 years ago
__main:
4 years ago
{
print["hello world"];
5 years ago
};
```
# Variables
4 years ago
* Variables support "type juggling" where types are assumed at runtime.
* Variables can be assigned to each other even if they are different types.
4 years ago
4 years ago
```c
4 years ago
/* main function */
def main:
{
my_var = 121231; /* int */
print[my_var];
my_var = -123.122; /* double */
print[my_var];
my_var = "cool string"; /* null terminating string */
print[my_var];
my_var = 'c'; /* char */
print[my_var];
my_var = { print[ "hello world" ]; }; /* lambda function */
call my_var;
};
call main;
```
4 years ago
4 years ago
# Expressions
4 years ago
* As ov v0.9.5 expressions are only supported for int types, I need to recode the entire expression parsing system
4 years ago
to support up to doubles.
4 years ago
4 years ago
```c
4 years ago
def main:
{
var = 10 + (5 * 2 / (11 % 2));
/* should print 20 */
print[var];
};
call main;
```
5 years ago
4 years ago
# Scope
4 years ago
* As of v0.9.6.1 there is scope, but the scope is limited to functions. Anything inside of a function is accessable anywhere inside of that function.
4 years ago
4 years ago
```c
4 years ago
def test[a]: {
if[a]: { print[a]; };
4 years ago
};
4 years ago
__main: { var = 10; print[var]; call test[var]; };
5 years ago
```
4 years ago
5 years ago
# Logic
4 years ago
* As of version 0.9.5, logical conditions will evaluate the provided variable.
4 years ago
### If statements
4 years ago
4 years ago
```c
4 years ago
__main:
4 years ago
{
var = 1;
if[var]: /* condition must be a variable */
{
print["var was 1"];
var = 0;
};
if[var]:
{
4 years ago
print["this wont print!"];
4 years ago
};
5 years ago
};
4 years ago
```
4 years ago
4 years ago
### While loops
4 years ago
4 years ago
```c
4 years ago
def main:
{
var = 1;
/* loop that runs forever */
while[var]:
{
print["this will run forever"];
print["it also wont stack overflow, so dont worry"];
};
5 years ago
};
4 years ago
call main;
5 years ago
```
4 years ago
5 years ago
# Functions
4 years ago
* Functions can be defined as variables (lambda) or defined normally.
4 years ago
* Functions support parameters of any amount.
4 years ago
```c
4 years ago
def my_function[a, b, c, d]:
4 years ago
{
some_function = {
print["hello world"];
5 years ago
};
4 years ago
call some_function;
4 years ago
if[a]:
{
if[b]:
{
print[c];
print[d];
};
4 years ago
};
4 years ago
};
4 years ago
4 years ago
__main:
{
var = 1;
test_string = "hello world";
call my_function[var, var, test_string, test_string];
};
4 years ago
```
4 years ago
4 years ago