diff options
| author | Cody <cody@codyq.dev> | 2023-03-30 02:44:54 -0500 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-03-30 02:44:54 -0500 |
| commit | 2970520a9592b5c6d45291f54073552a474b71b4 (patch) | |
| tree | f42ecc1be0989367cf7c70d0b7909bac0b86904e /docs/grammar.md | |
| parent | bb95375f8b24141bf7dfe5a8b1bba5c995f61253 (diff) | |
| download | sloth-2970520a9592b5c6d45291f54073552a474b71b4.tar.gz | |
Restructure
Diffstat (limited to 'docs/grammar.md')
| -rw-r--r-- | docs/grammar.md | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/docs/grammar.md b/docs/grammar.md deleted file mode 100644 index d172254..0000000 --- a/docs/grammar.md +++ /dev/null @@ -1,39 +0,0 @@ -Formal grammar definition for Sloth. - -``` -program → statement* ; -block → "{" statement* "}" - -statement → exprStmt - | valStmt - | varStmt - | returnStmt - | printStmt - | functionStmt - | ifStmt - | forStmt ; - -exprStmt → expression ";" ; -valStmt → "val" IDENTIFIER "=" expression ";" ; -varStmt → "var" IDENTIFIER "=" expression ";" ; -returnStmt → "return" expression ";" ; -printStmt → "print" expression ";" ; - -functionStmt → "fn" IDENTIFIER "(" (IDENTIFIER ":" IDENTIFIER)* ")" block ; -ifStmt → "if" expression block ; -forStmt → "for" IDENTIFIER "in" expression ".." expression block ; - -expression → logical_or ; - -logical_or → logical_and ( "||" logical_and )* ; -logical_and → equality ( "&&" equality )* ; -equality → comparison ( ( "!=" | "==" ) comparison )* ; -comparison → bitwise_shift ( ( "<" | ">" | "<=" | ">=" ) bitwise_shift )* ; -bitwise_shifting → additive ( ( "<<" | ">>" ) additive )* ; -additive → multiplicative ( ( "+" | "-" ) multiplicative )* ; -multiplicative → unary ( ( "*" | "/" | "%" ) unary )* ; -unary → ( "!" | "+" | "-" ) unary | call ; - -call → primary ( "(" arguments? ")" )* ; -primary → "true" | "false" | NUMBER | STRING | IDENTIFIER | "(" expression ")" ; -``` |
