Kai-Philipp Nosper 35fbae8ab9 Implement multi statement code
- Add statements
- Add mandatory semicolons after statements
2022-01-29 23:18:15 +01:00
2022-01-29 23:18:15 +01:00
2022-01-02 18:44:05 +01:00
2022-01-02 18:44:05 +01:00
2022-01-29 23:18:15 +01:00

NEK-Lang

High level Components

  • Lexer: Transforms text into Tokens
  • Parser: Transforms Tokens into Abstract Syntax Tree
  • Interpreter (tree-walk-interpreter): Walks the tree and evaluates the expressions / statements
  • Abstract Syntax Tree Optimizer

Language features

  • General expressions
    • Arithmetic operations
      • Addition X+Y
      • Subtraction X-Y
      • Multiplication X*Y
      • Division X/Y
      • Modulo X%Y
    • Unary operators
      • Negate -X
    • Parentheses (X+Y)*Z
    • Logical boolean operators
      • Equal ==
      • Not equal !=
      • Greater than >
      • Less than <
      • Greater than or equal >=
      • Less than or equal <=
    • Bitwise operators
      • Bitwise AND X&Y
      • Bitwise OR X|Y
      • Bitwise XOR X^Y
      • Bitwise NOT ~X
      • Bitwise left shift X<<Y
      • Bitwise right shift X>>Y
  • Variables
    • Declaration
    • Assignment
  • Statements with semicolon & Multiline programs
  • Control flow
    • While loop while X { ... }
    • If else statement if X { ... } else { ... }
      • If Statement
      • Else statement
  • Line comments //
  • Strings
  • IO Intrinsics
    • Print
    • ReadLine

Grammar

Expressions

expr_primary = LITERAL | IDENT | "(" expr ")" | "-" expr_primary | "~" 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 = stmt_expr
Description
No description provided
Readme 635 KiB
Languages
Rust 100%