Group Members: İsmail Temüroğlu, Can Dündar, Emre Topcu, Ömer Lütfi Duran
EON is a statically-typed programming language with a clean syntax that emphasizes readability and explicit type declarations. It features unique control flow keywords, specialized operators, and a distinctive statement termination approach using colons.
Variables must be declared with explicit types using the :: operator:
variableName :: value:
Bare in mind that MAX_ID_LENGTH 64 is 64
Bare in mind that MAX_CALL_DEPTH is 100
Bare in mind that MAX_SYMBOLS is 1000
Supported primitive types:
int: Integer valuesbool: Boolean values (TrueorFalse)
Examples:
- numberVal :: 42:
- boolVal :: True:
Bare in my that True and Falses are basically one and zero.
- Single-line comments: Begin with
---
--- This is a single line comment
- Multi-line comments: Enclosed between
-*and*-
-_ This is a multi-line comment _-
-
when/otherwise: Similar to if/else:- when (condition) { // code } otherwise { // code }
-
unless: Opposite ofwhen, executes if condition is false:- unless (condition) { // code }
-
ctloop(count loop): Similar to a for loop- ctloop (initialization: condition: update) { // code }
-
cnloop(continue loop): Similar to a while loop- cnloop (condition) { // code }
Functions are declared using the method keyword:
method name(param) { // function body return value: } ENDF
-
Arithmetic:
+,-,*,/,++,-- -
Assignment:
=,+=,-=,*=,/= -
Comparison:
>,<,>=,<=,== -
Logical:
&&(AND),||(OR),^^(XOR) -
Bitwise:
&(AND),|(OR),^(XOR)
-
Output:
write(expression) -
Input:
input()
All statements end with a colon : rather than a semicolon.
when (k > 4) {
write(5):
write(6):
write(7):
write(8):
write(9):
write(10):
} otherwise {
write(1):
write(2):
write(3):
}
<program> ::= <function>
<function> ::= <function> <stmt> | ε
<stmt> ::=
COLON
| <expr> COLON
| PRINT <expr> COLON
| IDENTIFIER ASSIGN <expr> COLON
| WHILE LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt>
| IF LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt>
| IF LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS <stmt> ELSE <stmt>
| LEFT_BRACE <stmt_list> RIGHT_BRACE
| <comment> <stmt_list>
| <try_catch_stmt>
| <throw_stmt>
<try_catch_stmt> ::=
TRY <stmt> <catch_clauses>
| TRY <stmt> <catch_clauses> <finally_clause>
<catch_clauses> ::=
<catch_clause>
| <catch_clauses> <catch_clause>
<catch_clause> ::=
CATCH LEFT_PARENTHESIS INTEGER RIGHT_PARENTHESIS <stmt>
| CATCH LEFT_PARENTHESIS RIGHT_PARENTHESIS <stmt>
<finally_clause> ::= FINALLY <stmt>
<throw_stmt> ::= THROW <expr> COLON
<stmt_list> ::=
<stmt>
| <stmt_list> <stmt>
<comment> ::= COMMENTLINE | OPENCOMMENT
<expr> ::=
INTEGER
| IDENTIFIER
| MINUS <expr>
| <expr> PLUS <expr>
| <expr> MINUS <expr>
| <expr> MULTIPLE <expr>
| <expr> DIVIDE <expr>
| <expr> LESSTHAN <expr>
| <expr> GREATERTHAN <expr>
| <expr> EQUALORGREAT <expr>
| <expr> EQUALORLESS <expr>
| <expr> ISNOTEQUAL <expr>
| <expr> EQUAL <expr>
| LEFT_PARENTHESIS <expr> RIGHT_PARENTHESIS
To execute your program:
-
Create a file with the
.eonextension -
Use the provided Makefile to compile the program
-
Run your program with:
make
./eon_parser < example.eon