-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calc.bnfc
57 lines (42 loc) · 1.57 KB
/
Calc.bnfc
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
PDefs. Program ::= [Def] ;
DFun. Dfn ::= "function" Id "(" [Arg] ")" "{" [Stm] "}" ;
DMember. Dmem ::= Id;
DClass. Def ::= "class" Id ":" Id "{" [Dmem][Dfn] "}" ;
terminator Def "" ;
terminator Dfn "" ;
terminator Dmem ";" ;
ADecl. Arg ::= Id ;
separator Arg "," ;
SExp. Stm ::= Exp ";" ;
SInit. Stm ::= Id "=" Exp ";" ;
SMemInit. Stm ::= Id "." Id "=" Exp ";" ;
SReturn. Stm ::= "return" Exp ";" ;
SWhile. Stm ::= "while" "(" Exp ")" "{" [Stm] "}" ;
SIfElse. Stm ::= "if" "(" Exp ")" "{" [Stm] "}" "else" "{" [Stm] "}";
SException. Stm ::= "try" "{" [Stm] "}" "catch" "{" [Stm] "}";
SThrow. Stm ::= "throw" String ";";
terminator Stm "" ;
EInt. Exp13 ::= Integer ;
EDouble. Exp13 ::= Double ;
EString. Exp13 ::= String ;
EId. Exp13 ::= Id ;
EApp. Exp13 ::= "this." Id "(" [Exp] ")" ;
SNewClass. Exp13 ::= "new" Id ;
SClassMember. Exp13 ::= Id "." Id "(" [Exp] ")" ;
SClassMemberVar. Exp13 ::= Id "." Id ;
ETimes. Exp12 ::= Exp12 "*" Exp13 ;
EDiv. Exp12 ::= Exp12 "/" Exp13 ;
EPlus. Exp11 ::= Exp11 "+" Exp12 ;
EMinus. Exp11 ::= Exp11 "-" Exp12 ;
ELt. Exp9 ::= Exp9 "<" Exp10 ;
EGt. Exp9 ::= Exp9 ">" Exp10 ;
EEq. Exp8 ::= Exp8 "==" Exp9 ;
ENEq. Exp8 ::= Exp8 "!=" Exp9 ;
EAss. Exp2 ::= Exp8 "=" Exp2 ;
coercions Exp 13 ;
separator Exp "," ;
token Id (letter (letter | digit | '_')*) ;
separator nonempty Id "," ;
comment "#" ;
comment "//" ;
comment "/*" "*/" ;