Program --> Module Module --> module identifier semi BlockNoScope identifier dot Block --> BlockNoScope BlockNoScope --> OptDecls begin Stmts end OptDecls --> | Decls Decls --> Declaration | Decls Declaration Declaration --> const OptConstDecls | type OptTypeDecls | typerec RecTypeDecls | var OptVarDecls | ProcDecl RecTypeDecls --> TypeDecl | RecTypeDecls and TypeDecl OptConstDecls --> | ConstDecls OptTypeDecls --> | TypeDecls OptVarDecls --> | VarDecls ConstDecls --> ConstDecl | ConstDecls ConstDecl TypeDecls --> TypeDecl | TypeDecls TypeDecl VarDecls --> VariableDecl | VarDecls VariableDecl ConstDecl --> identifier colon Type equal Expr semi | identifier equal Expr semi TypeDecl --> identifier equal Type semi VariableDecl --> IDList colon Type semi | IDList colon Type coloneq Expr semi | IDList coloneq Expr semi ProcDecl --> procedure identifier Signature equal BlockNoScope identifier semi Signature --> lpar OptFormals rpar OptDeclType OptDeclType --> | colon Type OptFormals --> | Formals | Formals semi Formals --> Formal | Formals semi Formal Formal --> OptMode IDList colon Type OptMode --> | value | var Stmts --> | StmtList | StmtList semi StmtList --> Stmt | StmtList semi Stmt Stmt --> Block | AssignStmt | CallStmt | ExitStmt | EvalStmt | ForStmt | IfStmt | LoopStmt | ReadStmt | RepeatStmt | ReturnStmt | WhileStmt | WriteStmt AssignStmt --> Expr coloneq Expr CallStmt --> ProcCall ExitStmt --> exit EvalStmt --> eval Expr ForStmt --> for identifier coloneq Expr to Expr OptBy do Stmts end OptBy --> | by Expr IfStmt --> IfHead end | IfHead else Stmts end IfHead --> if Expr then Stmts | IfHead elsif Expr then Stmts LoopStmt --> loop Stmts end ReadStmt --> read lpar text comma ReadList rpar ReadList --> Expr | Expr comma ReadList RepeatStmt --> repeat Stmts until Expr ReturnStmt --> return | return Expr WhileStmt --> while Expr do Stmts end WriteStmt --> write lpar text WriteList rpar WriteList --> | comma Expr WriteList Type --> ArrayType | RecordType | SubrangeType | identifier | lpar Type rpar | ref Type ArrayType --> array OptTypeList of Type OptTypeList --> | TypeList TypeList --> Type | TypeList comma Type RecordType --> record OptFields end OptFields --> | Fields | Fields semi Fields --> IDList colon Type | Fields semi IDList colon Type SubrangeType --> lbrack Expr dotdot Expr rbrack Expr --> Expr or Expr | Expr and Expr | not Expr | Expr Relop Expr | Expr Addop Expr | Expr Mulop Expr | Sign Expr | Primary Relop --> equal | nequal | less | greater | le | ge Addop --> plus | minus Mulop --> star | div | mod Sign --> plus | minus Primary --> identifier | integer | real | text | lpar Expr rpar | Primary dot identifier | ArrayRef | ProcCall | Primary caret | new lpar Type rpar | nil lpar Type rpar ArrayRef --> Primary lbrack rbrack | ArrayHead rbrack ArrayHead --> Primary lbrack Expr | ArrayHead comma Expr ProcCall --> Primary lpar rpar | CallHead rpar CallHead --> Primary lpar Expr | CallHead comma Expr IDList --> identifier | IDList comma identifier