statement -> print_statement | return_statement | break_statement | block_statement | var_statement | if_statement | while_statement | for_statement | expression_statement print_statement -> "print" expression ";" return_statement -> "return" expression? ";" break_statement -> "break" ";" block_statement -> "do" statement* "end" expression_statement -> expression ";"? ; leading "var" optional; the ":" is required var_statement -> "var"? IDENTIFIER ":" IDENTIFIER? ( variable_declaration | function_declaration | struct_declaration ) ; struct = WIP variable_declaration -> ( "=" expression )? ";" function_declaration -> ":" "fn" "(" parameters? ")" ( "{" expression "}" )? statement parameters -> IDENTIFIER ( ":" IDENTIFIER )? ( "," IDENTIFIER ( ":" IDENTIFIER )? )* if_statement -> "if" expression "then" statement ( "elif" expression "then" statement )* ( "else" statement )? while_statement -> "while" expression statement for_statement -> "for" var_statement expression ";" expression_statement statement ; ---------- expressions (lowest -> highest precedence) ---------- expression -> assignment assignment -> IDENTIFIER "=" assignment ; right-associative | pipe pipe -> logic ( "|>" logic )* ; left-assoc; x |> f(a) == f(x, a) logic -> is ( ( "or" | "and" ) is )* is -> equality ( "is" equality )* equality -> comparison ( ( "==" | "!=" ) comparison )* comparison -> term ( ( ">" | ">=" | "<" | "<=" ) term )* term -> factor ( ( "+" | "-" ) factor )* factor -> unary ( ( "*" | "/" ) unary )* unary -> ( "!" | "-" ) unary | call call -> primary ( "(" arguments? ")" )* arguments -> expression ( "," expression )* primary -> NUMBER | STRING | "true" | "false" | "nil" | "(" expression ")" | IDENTIFIER | dictionary | list | ATOM ; WIP ; ---------- work in progress (lexed; parser support being added) ---------- struct_declaration -> "struct" "{" field* "}" field -> IDENTIFIER ( ":" IDENTIFIER )? ";" dictionary -> "dict" "(" IDENTIFIER ":" expression ( "," IDENTIFIER ":" expression )* ")" list -> "list" "(" expression ( "," expression )* ")"