5 True. Bool ::= "true" ;
6 False. Bool ::= "false" ;
9 TBool. Type ::= "bool" ;
11 Program. Stms ::= [Stm] ;
14 SExp. Stm ::= Exp ";" ;
15 SBlock. Stm ::= "{" [Stm] "}" ;
16 SDecl. Stm ::= Type Ident "=" Exp ";" ;
17 SDeclD. Stm ::= Type Ident ";" ;
20 SWhile. Stm ::= "while" "(" Exp ")" Stm ;
21 SIf. Stm ::= "if" "(" Exp ")" Stm "else" Stm ;
22 if. Stm ::= "if" "(" Exp ")" Stm ;
23 define if e s = SIf e s SNoop ;
25 -- SFor. Stm ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
26 SPrint. Stm ::= "print" Exp ";" ;
30 EAss. Exp ::= Ident "=" Exp;
32 compExp. Exp ::= Exp1 Op0 Exp1 ;
33 define compExp e1 o e2 = BiOpExp e1 o e2 ;
35 op1. Exp1 ::= Exp1 Op1 Exp2 ;
36 define op1 e1 o e2 = BiOpExp e1 o e2 ;
38 op2. Exp2 ::= Exp2 Op2 Exp3 ;
39 define op2 e1 o e2 = BiOpExp e1 o e2 ;
41 postIncr. Exp3 ::= Ident "++" ;
42 define postIncr i = EPost i Plus ;
44 postDecr. Exp3 ::= Ident "--" ;
45 define postDecr i = EPost i Minus ;
47 EVar. Exp3 ::= Ident ;
48 EInt. Exp3 ::= Integer ;
49 EBool. Exp3 ::= Bool ;
51 ENeg. Exp3 ::= "-" Exp3 ;
52 ENot. Exp3 ::= "!" Exp3 ;
54 EReadI. Exp3 ::= "readInt" ;
55 EReadB. Exp3 ::= "readBool" ;
61 -- _. Stm ::= Stm ";" ;
86 -- internal ExpT. Exp ::= Type Exp ;
87 -- internal EDefault. Exp ::= ;
88 internal BiOpExp. Exp ::= Exp Op Exp ;
89 -- internal NoType. Type ::= ;
90 internal EPost. Exp ::= Ident Op1 ;
92 internal SNoop. Stm ::= ;
97 entrypoints Stms, Exp ;