$ mdkir build
$ cmake -DLLVM_DIR=path_to_llvm_build/lib/cmake/llvm -B build/
$ cd build
$ cmake --build .
-
Program -> Declaration* EOF
-
Declaration -> VarDecl | FuncDecl | ClassDecl | Statement
-
Statement -> ExprStmt | AssignStmt | ForStmt | IfStmt | PrintStmt | ReturnStmt | WhileStmtl | Block
-
ExprStmt -> Literal | Identifier | Unary | Binary | Grouping
-
AssignStmt -> Identifier EQUAL ExprStmt SEMICOLON
-
ForStmt -> FOR OPEN_PAREN VarDecl SEMICOLON ExprStmt SEMICOLON ExprStmt CLOSE_PAREN Block
-
IfStmt -> IF OPEN_PAREN ExprStmt CLOSE_PAREN Block | IF OPEN_PAREN ExprStmt CLOSE_PAREN Block ELSE Block
-
PrintStmt -> PRINT OPEN_PAREN ExprStmt CLOSE_PAREN SEMICOLON
-
ReturnStmt -> RETURN SEMICOLON | RETURN ExprStmt SEMICOLON
-
WhileStmt -> WHILE OPEN_PAREN ExprStmt CLOSE_PAREN Block
-
Block -> OPEN_CURLY Statement* CLOSE_CURLY
-
Literal -> NUMBER | STRING | "true" | "false" | "nil" ;
-
Grouping -> "(" ExprStmt ")" ;
-
Unary -> ( "-" | "!" ) ExprStmt ;
-
Binary -> ExprStmt Operator ExprStmt ;
-
Operator -> "==" | "!=" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/" ;
-
VarDecl -> VAR Identifier SEMICOLON | VAR Identifier EQUAL ExprStmt SEMICOLON
-
FuncDecl -> FUN Function
-
ClassDecl -> CLASS Identifier OPEN_CURLY Function* CLOSE_CURLY SEMICOLON
-
Function -> Identifier ( ) Block; | Identifier ( Parameters ) Block
-
Parameters -> Identifier | Identifier , Identifier+
-
VAR -> "var"
-
PRINT -> "print"
-
CLASS -> "class"
-
RETURN -> "return"