mirror of
https://github.com/MorizzG/rlox.git
synced 2026-02-04 03:44:47 +00:00
chapter 8 done
This commit is contained in:
parent
f56fcc4a8b
commit
956c4d0f28
13 changed files with 566 additions and 173 deletions
|
|
@ -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" ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue