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

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