s bof prog eof prog PROGRAM def id ( id_list ) ; block . block declarations BEGIN statements END declarations optlabels optconsts opttypes optvars optprocs optlabels | labeldecs ; opttypes | types ; optconsts | consts ; optvars | vars ; optprocs | procs ; labeldecs LABEL def integer | labeldecs , integer consts CONST def id = constant | consts ; def id = constant types TYPE def id = type | types ; def id = type vars VAR id_list : type | vars ; id_list : type procs procdef | procs ; procdef procdef PROCEDURE def id ; body | PROCEDURE def id ( fp_list ) ; body | FUNCTION def id : ref id ; body | FUNCTION def id ( fp_list ) : ref id ; body | FUNCTION def id ; block body block | FORWARD type ref id | ( id_list ) | ref id .. constant | const_expr .. constant | ^ ref id | packed ARRAY [ type_list ] OF type | packed RECORD field_list END | packed SET OF type | packed FILE OF type packed | PACKED type_list type | type_list , type field_list invariant_part variant_part invariant_part field | invariant_part ; field field | id_list : type variant_part | CASE id OF variant_cases | CASE id : ref id OF variant_cases variant_cases variant_case | variant_cases ; variant_case variant_case | constant_list : ( field_list ) constant_list constant | constant_list , constant statements statement | statements ; statement statement labels matched_else | labels unmatched_else labels | integer : labels matched_else | ref id := expression | var_expr := expression | ref id | ref id ( expressions ) | BEGIN statements END | IF expression THEN labels matched_else ELSE labels matched_else | CASE expression OF case_body END | WHILE expression DO labels matched_else | REPEAT statements UNTIL expression | FOR ref id := expression to expression DO labels matched_else | WITH var DO labels matched_else | GOTO integer unmatched_else IF expression THEN statement | IF expression THEN labels matched_else ELSE labels unmatched_else | WHILE expression DO labels unmatched_else | FOR ref id := expression to expression DO labels unmatched_else | WITH var DO labels unmatched_else to TO | DOWNTO case_body case_part | case_body ; case_part case_part | constant_list : statement expressions expression | expressions , expression fp_list fp | fp_list ; fp fp id_list : ref id | VAR id_list : ref id | PROCEDURE def id ( fp_list ) | FUNCTION def id ( fp_list ) : ref id | PROCEDURE def id | FUNCTION def id : ref id expression simple_expression | simple_expression relop simple_expression relop = | <> | > | < | >= | <= | IN simple_expression term | + term | - term | simple_expression addop term addop + | - | OR term factor | term mulop factor mulop * | / | DIV | MOD | AND factor integer | real | ref id | string | NIL | var_expr | ref id ( expressions ) | NOT factor | ( expression ) | [ set ] set expression | expression .. expression | set , expression | set , expression .. expression constant ref id | const_expr const_expr + ref id | - ref id | integer | real | + integer | + real | - integer | - real | string var ref id | var_expr var_expr ref id [ expressions ] | ref id . ref id | var_expr [ expressions ] | var_expr . ref id | ref id ^ | var_expr ^ id_list id | id_list , id def ref