GRAMMAR: Dragon 1+epsilon program -> DEF ID '(' id_ls ')' ';' decls sub_decls comp_stmt '.' id_ls -> ID | id_ls ',' ID decls -> decls VAR id_ls ':' type ';' | empty type -> std_type | ARRAY '[' range ']' OF std_type range -> NUM '.' '.' NUM std_type -> INTEGRAL | RATIONAL sub_decls -> sub_decls sub_decl ';' | empty sub_decl -> sub_head decls sub_decls comp_stmt sub_head -> FUNC ID args ':' std_type ';' | PROC ID args ';' args -> '(' par_ls ')' | empty par_ls -> id_ls ':' type | par_ls ';' id_ls ':' type comp_stmt -> BEGIN opt_stmts END opt_stmts -> stmt_ls | empty stmt_ls -> stmt | stmt_ls ';' stmt stmt -> var ASSIGNOP expr | proc_stmt | comp_stmt | IF expr THEN stmt ELSE stmt | IF expr THEN stmt | WHILE expr DO stmt | REPEAT stmt UNTIL expr | FOR ID ASSIGNOP range DO stmt var -> ID | ID '[' expr ']' proc_stmt -> ID | ID '(' expr_ls ')' expr_ls -> expr | expr_ls ',' expr expr -> simp_expr | simp_expr RELOP simp_expr simp_expr -> term | ADDOP term | simp_expr ADDOP term term -> factor | term MULOP factor factor -> ID | ID '(' expr_ls ')' | ID '[' expr ']' | NUM | '(' expr ')' | NOT factor LEXICAL RULES: 1. Comments are surrounded by '{' and '}' or by "(*" and "*)". Comments may appear before any token. 2. Blanks between tokens are optional. 3. ID -> LETTER (LETTER | DIGIT)* where DIGIT -> [0-9] and LETTER -> [a-zA-Z] There is no limit on identifier length. 4. NUM -> INUM "." INUM where INUM -> DIGIT+ 5. Keywords are reserved and appear capitalized in the grammar. 6. RELOP are "=", "<>", "<", "<=", ">", ">=" 7. ADDOP are "+", "-" and "or" 8. MULOP are "*", "/", "div", "mod" and "and" 9. ASSIGNOP is ":="