chapter 8 done

This commit is contained in:
Moritz Gmeiner 2023-01-22 23:33:57 +01:00
commit 956c4d0f28
13 changed files with 566 additions and 173 deletions

View file

@ -1,8 +1,18 @@
expression -> equality
program -> statement* EOF ;
statement -> exprStmt | printStmt | declaration | block ;
exprStmt -> expression ";" ;
printStmt -> "print" expression ";" ;
declaration -> "var" IDENTIFIER ( "=" expression )? ";" ;
block -> "{" statement* "}" ;
expression -> assignment
assignment -> IDENTIFIER "=" assignment | equality ;
equality -> comparison ( ( "==" | "!=" ) comparison )* ;
comparison -> term ( ">" | ">=" | "<" | "<=" term )* ;
term -> factor ( ( "+" | "-" ) factor )*
factor -> unary ( ( "*" | "/" ) unary )* ;
unary -> ( "!" | "-" ) unary | primary ;
primary -> "(" expression ")" | NUMBER | STRING | "true" | "false" | "nil" ;
primary -> "(" expression ")" | IDENTIFIER | NUMBER | STRING | "true" | "false" | "nil" ;