4 Program. Stms ::= [Stm] ;
7 SExp. Stm ::= Exp ";" ;
8 SBlock. Stm ::= "{" [Stm] "}" ;
9 SDecl. Stm ::= Type Ident "=" Exp ";" ;
10 decl. Stm ::= Type Ident ";" ;
11 define decl t v = SDecl t v EDefault ;
13 SWhile. Stm ::= "while" "(" Exp ")" Stm ;
14 SIf. Stm ::= "if" "(" Exp ")" Stm "else" Stm ;
15 if. Stm ::= "if" "(" Exp ")" Stm ;
16 define if e s = SIf e s SNoop ;
18 -- SFor. Stm ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
19 SPrint. Stm ::= "print" Exp ";" ;
23 EAss. Exp ::= Ident "=" Exp;
25 compExp. Exp ::= Exp1 Op0 Exp1 ;
26 define compExp e1 o e2 = BiOpExp e1 o e2 ;
28 op1. Exp1 ::= Exp1 Op1 Exp2 ;
29 define op1 e1 o e2 = BiOpExp e1 o e2 ;
31 op2. Exp2 ::= Exp2 Op2 Exp3 ;
32 define op2 e1 o e2 = BiOpExp e1 o e2 ;
34 postIncr. Exp3 ::= Ident "++" ;
35 define postIncr i = EPost i Plus ;
37 postDecr. Exp3 ::= Ident "--" ;
38 define postDecr i = EPost i Minus ;
40 EVar. Exp3 ::= Ident ;
41 EInt. Exp3 ::= Integer ;
42 EBool. Exp3 ::= Bool ;
44 ENeg. Exp3 ::= "-" Exp3 ;
45 ENot. Exp3 ::= "!" Exp3 ;
47 EReadI. Exp3 ::= "readInt" ;
48 EReadB. Exp3 ::= "readBool" ;
54 -- _. Stm ::= Stm ";" ;
77 True. Bool ::= "true" ;
78 False. Bool ::= "false" ;
80 TInt. Type ::= "int" ;
81 TBool. Type ::= "bool" ;
85 internal ExpT. Exp ::= Type Exp ;
86 internal SNoop. Stm ::= ;
87 internal EDefault. Exp ::= ;
88 internal BiOpExp. Exp ::= Exp Op Exp ;
89 internal NoType. Type ::= ;
90 internal EPost. Exp ::= Ident Op1 ;
95 entrypoints Stms, Exp ;