-
Notifications
You must be signed in to change notification settings - Fork 12
/
CORE_ch.bnf
21 lines (21 loc) · 956 Bytes
/
CORE_ch.bnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<prog> ::= 程序 <decl seq> 开始 <stmt seq> 结束
<decl seq> ::= <decl> | <decl> <decl seq>
<stmt seq> ::= <stmt> <stmt seq> | <stmt>
<decl> ::= int <id list> ;
<id list> ::= <id> , <id list> | <id>
<stmt> ::= <assign>|<if>|<loop>|<output>|<input>
<assign> ::= <id> 等于 <exp> ;
<if> ::= 如果 <cond> { <stmt seq> } ;
<loop> ::= 见鬼 <cond> { <stmt seq> } ;
<input> ::= 输入 <id list> ;
<output> ::= 输出 <id list> ;
<cond> ::= <comp> | ! <cond> | [ <cond> && <cond> ] | [ <cond> or <cond> ]
<comp> ::= ( <op> <comp op> <op> )
<exp> ::= <fac> | <fac> 加 <exp> | <fac> 减 <exp>
<fac> ::= <op> | <op> 乘 <fac>
<op> ::= <int> | <id> | ( <exp> )
<comp op> ::= != | == | < | > | <= | >=
<id> ::= <let><id> | <let><int> | <let>
<let> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
<int> ::= <digit><int> | <digit>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9