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

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