|
|
|
# Deon programming language V0.9.5
|
|
|
|
My computer programming language made with LEX/YACC written in C. (interpreted)
|
|
|
|
|
|
|
|
# Downloads
|
|
|
|
Supported operating systems and downloads:
|
|
|
|
|
|
|
|
* [Win-32 Download](https://git.hacks.ltd/xerox/deon/uploads/9991a71c059678b0986634b2c71a1a8f/deon.exe) SHA1: 9216C9A0073A66A896346D98FE365E1A3B21C0BC
|
|
|
|
* [Win-64 Download](https://git.hacks.ltd/xerox/deon/uploads/61a72f55863033549064b88126776338/deon.exe) SHA1: AFB2DE7360F34E2C397DD34CE6553A1D37CF1884
|
|
|
|
* [Linux-32 Download](https://git.hacks.ltd/xerox/deon/uploads/cbcd4097975aa5f5e7a638dd1b335fd1/deon) SHA1: 1df2c25783fd96156da322aa7cd6f26ec84b63c4
|
|
|
|
* [Linux-64 Download](https://git.hacks.ltd/xerox/deon/uploads/310146a23b042eb7c40b7def35ccf94a/deon) SHA1: 554a1d50dea246b65a6f3e459f02dd6b5fc4ab35
|
|
|
|
|
|
|
|
# Hello World.
|
|
|
|
Hello world in Deon.
|
|
|
|
|
|
|
|
```c
|
|
|
|
def main:
|
|
|
|
{
|
|
|
|
print["hello world"];
|
|
|
|
};
|
|
|
|
call main;
|
|
|
|
```
|
|
|
|
|
|
|
|
# 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.5 there is not scope inside of this programming language.
|
|
|
|
|
|
|
|
```c
|
|
|
|
/* changes var from 10 to 100 */
|
|
|
|
def another_function:
|
|
|
|
{
|
|
|
|
var = 100;
|
|
|
|
};
|
|
|
|
|
|
|
|
def main:
|
|
|
|
{
|
|
|
|
var = 10;
|
|
|
|
/* should print 10 */
|
|
|
|
print[var];
|
|
|
|
call another_function;
|
|
|
|
/* should print 100 */
|
|
|
|
print[var];
|
|
|
|
};
|
|
|
|
call main;
|
|
|
|
```
|
|
|
|
|
|
|
|
# Logic
|
|
|
|
* while loops are if statements
|
|
|
|
* As of version 0.9.5, logic conditions must only be variables.
|
|
|
|
|
|
|
|
### If statements
|
|
|
|
* As stated above, if statement conditions must be a variable.
|
|
|
|
|
|
|
|
```c
|
|
|
|
def main:
|
|
|
|
{
|
|
|
|
var = 1;
|
|
|
|
if[var]: /* condition must be a variable */
|
|
|
|
{
|
|
|
|
print["var was 1"];
|
|
|
|
var = 0;
|
|
|
|
};
|
|
|
|
if[var]:
|
|
|
|
{
|
|
|
|
print["this wont print! (or shouldnt)"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
call main;
|
|
|
|
```
|
|
|
|
|
|
|
|
### While loop
|
|
|
|
|
|
|
|
```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.
|
|
|
|
|
|
|
|
```c
|
|
|
|
def my_function:
|
|
|
|
{
|
|
|
|
some_function = {
|
|
|
|
print["hello world"];
|
|
|
|
};
|
|
|
|
call some_function;
|
|
|
|
};
|
|
|
|
call my_function;
|
|
|
|
```
|
|
|
|
|
|
|
|
# Redefinitions
|
|
|
|
* As of v0.9.5 everything in this programming language can be redefined. That means everything, including the function that
|
|
|
|
is currently being executed.
|
|
|
|
|
|
|
|
```c
|
|
|
|
def main:
|
|
|
|
{
|
|
|
|
main = {
|
|
|
|
print["i just redefined main"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
call main;
|
|
|
|
call main;
|
|
|
|
```
|
|
|
|
|
|
|
|
|