# NEK-Lang ## High level Components - [x] Lexer: Transforms text into Tokens - [x] Parser: Transforms Tokens into Abstract Syntax Tree - [x] Interpreter (tree-walk-interpreter): Walks the tree and evaluates the expressions / statements - [ ] Abstract Syntax Tree Optimizer ## Language features - [x] Math expressions - [x] Unary operators - [x] Negate `-X` - [x] Parentheses `(X+Y)*Z` - [x] Logical boolean operators - [x] Variables - [x] Declaration - [x] Assignment - [x] While loop `while X { ... }` - [x] If else statement `if X { ... } else { ... }` - [x] If Statement - [x] Else statement - [ ] Line comments `//` - [x] Strings - [x] For loops `for X; Y; Z { ... }` - [ ] IO Intrinsics - [x] Print - [ ] ReadLine ## Grammar ### Expressions ``` LITERAL = I64 | Str expr_primary = LITERAL | IDENT | "(" expr ")" | "-" expr_primary expr_mul = expr_primary (("*" | "/" | "%") expr_primary)* expr_add = expr_mul (("+" | "-") expr_mul)* expr_shift = expr_add ((">>" | "<<") expr_add)* expr_rel = expr_shift ((">" | ">=" | "<" | "<=") expr_shift)* expr_equ = expr_rel (("==" | "!=") expr_rel)* expr_band = expr_equ ("&" expr_equ)* expr_bxor = expr_band ("^" expr_band)* expr_bor = expr_bxor ("|" expr_bxor)* expr = expr_bor ``` ## Statements ``` stmt_expr = expr stmt_let = "let" IDENT "=" expr stmt_while = "while" expr "{" (stmt)* "}" stmt_for = "for" stmt_let ";" expr ";" expr "{" (stmt)* "}" stmt_if = "if" expr "{" (stmt)* "}" ( "else" "{" (stmt)* "}" ) stmt_dbgprint = "$$" expr stmt_print = "$" expr stmt = stmt_expr | stmt_let | stmt_while | stmt_for | stmt_if | stmt_dbgprint | stmt_print ```