-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammar.bnf
More file actions
21 lines (15 loc) · 857 Bytes
/
grammar.bnf
File metadata and controls
21 lines (15 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<program> ::= <declaration> "\n" <program> | <declaration> | ""
<declaration> ::= <assignment-declaration> | <expression-declaration>
<assignment-declaration> ::= "let" <identifier> "=" <expression>
<expression-declaration> ::= <expression>
<expression> ::= <binary-expression>
<binary-expression> ::= <unary-expression> <binary-operator> <binary-expression>
| <unary-expression>
<binary-operator> ::= "+" | "-" | "*" | "/" | "**" | "%"
| "==" | "!=" | ">" | ">=" | "<" | "<="
| "and" | "or"
<unary-expression> ::= <unary-operator> <value> | <value>
<unary-operator> ::= "-" | "not"
<value> ::= <parenthesized-expression> | <literal> | <identifier>
<parenthesized-expression> ::= "(" <expression> ")"
<literal> ::= <number> | "true" | "false"