-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnf.txt
40 lines (23 loc) · 855 Bytes
/
bnf.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<statements> ::= { <statement> }
<statement> ::= "var" <ident> { “,” <ident> } “;”
| "let" <ident> “=“ <expression> “;”
| "if" <expression> <relop> <expression> “{”
<statements>
“}”
[ "else" "{"
<statements>
"}"]
| "while" <expression> <relop> <expression> “{”
<statements>
“}”
| "print" ( <expression> | <string> ) { "," ( <expression> | <string> ) } “;”
| "input" <ident> “;”
<expression> ::= [ + | - ] <term> { ( + | - ) <term> }
<term> ::= <factor> { ( * | / ) <factor> }
<factor> ::= <ident> | <constant> | "(" <expression> ")"
<ident> ::= <letter> { <letter> | <digit> }
<string> ::= "”" { <letter> | <digit> } "”"
<letter> ::= a | .. | Z
<constant> ::= <digit> { <digit> }
<digit> ::= 0 | .. | 9
<relop> ::= <[=] | >[=] | =