+<FunDecl> ::= <id> '(' <Type>* ')' ['::' <FunType] '{' <VarDecl>* <Stmt>+ '}'
+<FunType> ::= <Type>+ '->' <VoidType>
+ | <VoidType>
+<Stmt> ::= 'if' '(' <Expr> ')' '{' <Stmt>* '}' ['else' '{' <Stmt>* '}']
+ | 'while' '(' <Expr> ')' '{' <Stmt>* '}'
+ | <id> <FieldSels> '=' <Expr> ';'
+ | <FunCall> ';'
+ | 'return' [<Expr>] ';'
+
+<VarDecl> ::= (<Type> | 'var') <id> '=' <Expr> ';'
<Expr> ::= <BinOrExpr> [':' <Expr>]
<BinOrExpr> ::= <BinAndExpr> ['||' <BinOrExpr>]
<BinAndExpr> ::= <CompareExpr> ['&&' <BinAndExpr>]
<CompareExpr> ::= <PlusMinExpr> [('==' | '<' | '>' | '<=' | '>=' | '!=') <CompareExpr>]
<PlusMinExpr> ::= <TimesDivExpr> (('+' | '-') <TimesDivExpr>)*
-<TimesDivExpr> ::= <BasicExpr> ('*' | '/' | '%'] <BasicExpr>)*
-<BasicExpr> ::= <id> ['hd'|'tl'|'fst'|'snd]
+<TimesDivExpr> ::= <BasicExpr> (['*' | '/' | '%'] <BasicExpr>)*
+<BasicExpr> ::= <id> <FieldSels>
| <Op1> <Expr>
| <int>
| <char>
| 'False'
| 'True'
| '(' <Expr> ')'
- | <id> '(' [<ActArgs>] ')'
+ | <FunCall>
| '[]' <Expr>
| '(' <Expr> ',' <Expr> ')'
+<FieldSels> ::= ('.' ('hd'|'tl'|'fst'|'snd))*
+<FunCall> ::= <id> '(' [<ActArgs>] ')'
<ActArgs> ::= <Expr> [',' ActArgs]
-<VarDecl> ::= (<Type> | 'var') <id> '=' <Expr> ';'
-
<Type> ::= 'Int'
| 'Bool'
| 'Char'
| '(' Type ',' Type ')'
| '[' Type ']'
| <id>
+<VoidType> ::= 'Void' | Type