| 〈Program〉 | → | 〈Block〉 |
| | | | 〈Block〉 ';' |
| 〈Decls〉 | → | 〈DeclList〉 |
| | | | ε |
| 〈DeclList〉 | → | 〈Decl〉 |
| | | | 〈Decl〉 ; 〈DeclList〉 |
| 〈Decl〉 | → | 'VAR' id 〈OptType〉 |
| | | | 'TYPE' id '=' 〈Type〉 |
| | | | 〈ProcDecl〉 |
| 〈OptType〉 | → | ε |
| | | | ':' 〈Type〉 |
| 〈ProcDecl〉 | → | 'PROC' id '(' 〈Formals〉 ')' 〈OptType〉 '=' 〈Block〉 |
| | | | 'PROC' id '(' 〈Formals〉 ')' '=' 〈Block〉 |
| 〈Formals〉 | → | 〈FormalList〉 |
| | | | ε |
| 〈FormalList〉 | → | 〈Formal〉 |
| | | | 〈FormalList〉 ',' 〈Formal〉 |
| 〈Formal〉 | → | id ':' 〈Type〉 |
| 〈Type〉 | → | 'INT' |
| | | | 〈SubrTy〉 |
| | | | 〈ArrayTy〉 |
| | | | id |
| | | | 〈ProcTy〉 |
| 〈SubrTy〉 | → | '[' number 'TO' number ']' |
| 〈ArrayTy〉 | → | 'ARRAY' 〈SubrTy〉 'OF' 〈Type〉 |
| 〈ProcTy〉 | → | 'PROC' '(' 〈Formals〉 ')' 〈OptType〉 |
| 〈Block〉 | → | 〈Decls〉 'BEGIN' 〈Stmts〉 'END' |
| 〈Stmts〉 | → | 〈StmtList〉 |
| | | | ε |
| 〈StmtList〉 | → | 〈Stmt〉 |
| | | | 〈StmtList〉 ';' 〈Stmt〉 |
| 〈Stmt〉 | → | 〈Assignment〉 |
| | | | 〈Return〉 |
| | | | 〈Block〉 |
| | | | 〈Conditional〉 |
| | | | 〈Iteration〉 |
| | | | 〈Output〉 |
| | | | 〈Expr〉 |
| 〈Assignment〉 | → | 〈Expr〉 ':=' 〈Expr〉 |
| 〈Return〉 | → | 'RETURN' 〈Expr〉 |
| 〈Conditional〉 | → | 'IF' 〈Expr〉 'THEN' 〈StmtList〉 'ELSE' 〈StmtList〉 'END' |
| 〈Iteration〉 | → | 'WHILE' 〈Expr〉 'DO' 〈StmtList〉 'END' |
| 〈Output〉 | → | 'PRINT' 〈Expr〉 |
| 〈Expr〉 | → | 〈Operand〉 |
| | | | 〈Expr〉 〈Operator〉 〈Operand〉 |
| 〈Operand〉 | → | number |
| | | | id |
| | | | 〈Operand〉 '[' 〈Expr〉 ']' |
| | | | 〈Operand〉 '(' 〈Actuals〉 ')' |
| | | | '(' 〈Expr〉 ')' |
| 〈Operator〉 | → | '+' |
| | | | '>' |
| | | | '==' |
| | | | 'AND' |
| 〈Actuals〉 | → | 〈ActualList〉 |
| | | | ε |
| 〈ActualList〉 | → | 〈Expr〉 |
| | | | 〈Actuals〉 ',' 〈Expr〉 |
where