// This is a vanilla grammar as from the CLEO manual // It does not yet cover section 15 // file CLEO.y is derived from this to make it LALR1 %token alphabetic_character %token AND %token BEGIN %token BY %token CLEAR %token CLOSE %token COLUMN %token COMPOSE %token COPY %token COUNT %token DECIMAL %token digit %token DIGITS %token DO %token ELSE %token END %token FILE %token FOR %token FORMAT %token FROM %token GO %token HALT %token HIGH %token IDENTIFIER %token IF %token IN %token INPUT %token OUTPUT %token integer %token IS %token KEY %token letter %token LETTERS %token LEVEL %token LOW %token MARK %token MOVE %token NOT %token numeric_literal %token OBTAIN %token ON %token OPEN %token OR %token OVERLAY %token POUND %token PRINT %token QUOTE %token READ %token RECORDS %token REEL %token REMAINDER %token REREAD %token RESULT %token REWIND %token RO %token RU %token RUN %token SET %token SHEET %token SKIP %token STERLING %token SUBSET /*?*/ %token TO %token TOTAL %token TYPE %token UNLOAD %token UNTIL %token WHEN %token WRITE %token UNKNOWN %% /* sect 4.1 */ program : command_list END ; /*-*/ command_list : command | command_list command ; /*-*/ arithmetic_expression : operand | '+' operand | '-' operand | arithmetic_expression '+' operand | arithmetic_expression '-' operand | arithmetic_expression '*' operand | arithmetic_expression '/' operand ; /*-*/ operand : numeric_item_identofoer | numeric_literal | floating_point_literal | '(' arithmetic_expression ')' | function_call | special_item | DECIMAL '(' IDENTIFIER ')' | STERLING '(' IDENTIFIER ')' ; /*-*/ /* sect 4.2 */ conditional_expression : relation | '(' conditional_expression ')' | conditional_expression OR conditional_expression | conditional_expression AND conditional_expression | NOT conditional_expression ; /*-*/ relation : arithmetic_expression relational_operator arithmetic_expression | alpha_item relational_operator alpha_item | input_record_identifier | magnetic_tape_input_file_identifier LEVEL integer | END magnetic_tape_input_file_identifier | formal_parameter_of_type_C | selection IS comparison_list ; /*-*/ relational_operator : '<'| '>'| '*' | NOT '<'| NOT '>'| NOT '=' ; /*-*/ alpha_item : alpha_literal | alpha_item_identifier ; /*-*/ comparison_list : comparison_element | comparison_element ':' comparison_list ; /*-*/ comparison_element : alpha_literal | LETTERS | DIGITS | QUOTE ; /*-*/ /* sect 5.1 */ literal : alpha_literal | numeric_literal | '-' numeric_literal | floating_point_literal | '-' floating_point_literal ; /*-*/ floating_point_literal : decimal_number | exponent_number ; /*-*/ decimal_number : integer '.' integer ; /*-*/ exponent_number : decimal_number 't' signed_integer | integer 't' signed_integer ; /*-*/ signed_integer : integer | '-' integer ; /*-*/ /* sect 6.2 */ file_identifier : letter digit ; /*-*/ file_identifier_list : file_identifier | file_identifier_list ',' file_identifier ; /*-*/ internal_identifier_list : internal_identifier | internal_identifier_list ',' internal_identifier ; /*-*/ /* sect 6.3 */ record_identifier : IDENTIFIER ; /*-*/ alpha_numeric_character : letter | digit | '.' ; /*-*/ /* sect 6.4 */ group_identifier : IDENTIFIER ; /*-*/ /* sect 6.5 */ item_identifier : IDENTIFIER ; /*-*/ /* sect 6.6 */ subscripted_identifier : identifier_of_repeated_item '(' subscript ')' | identifier_of_repeated_group '(' subscript ')' ; /*-*/ subscript : arithmetic_expression | arithmetic_expression ',' arithmetic_expression ; /*-*/ /* sect 6.7 */ compound_record_identifier : simple_record_identifier IN file_identifier ; /*-*/ /* sect 7.12 */ RECORDS_statement : RECORDS record_identifier_list ':' ; /*-*/ record_identifier_list : record_identifier | record_identifier_list ',' record_identifier ; /*-*/ TOTAL_statement : TOTAL total_list ':' ; /*-*/ total_list : couplet | couplet ',' total_list ; /*-*/ couplet : item_identifier_from_magnetioc_tape_file TO item_identifier_from_internal_file MARK_statement : MARK IS identifier_in_internal_file ; /*-*/ COUNT_statement :COUNT '(' HIGH ')' IS internal_identifier_of_type_SL |COUNT '(' LOW ')' IS internal_identifier_of_type_SL ; /*-*/ /* sect 7.12.5 */ REEL_END_statement : DO subroutine_label ON REEL END ; /*-*/ /* sect 7.12.5 */ KEY_statement : KEY IS internal_identifier ; /*-*/ result_type_statement : RESULT TYPE IS numeric_literal | RESULT TYPE IS numeric_item_identifier ; /*-*/ FORMAT_statement : FORMAT IS numeric_literal | FORMAT IS numeric_item_identifier ; /*-*/ sheet_number_statement : SHEET IS numeric_item_identifier ; /*-*/ /* sect 8.6 */ occurrences : integer | integer '*' integer ; /*-*/ /* sect 8.7 */ type : 'A' | 'D' | 'D''L' | POUND | POUND 'L' | 'S' | 'S''L' | 'F' | 'A' integer | 'D' integer POUND integer | 'S' integer | 'D''L' integer POUND | 'L' integer | 'S''L' integer | 'C' | 'L' ; /*-*/ /* sect 8. 11 .1 */ column_position : integer | integer ',' integer ; /*-*/ alpha_item_identifier : IDENTIFIER ; alpha_literal : IDENTIFIER ; formal_parameter_of_type_C : IDENTIFIER ; function_call : IDENTIFIER ; identifier_in_internal_file : IDENTIFIER ; magnetic_tape_input_file_identifier : IDENTIFIER ; item_identifier_from_internal_file : IDENTIFIER ; item_identifier_from_magnetioc_tape_file : IDENTIFIER ; magnetic_tape_input_file_identifier : IDENTIFIER ; numeric_item_identofoer : IDENTIFIER ; identifier_of_repeated_group : IDENTIFIER ; identifier_of_repeated_item : IDENTIFIER ; selection : IDENTIFIER ; simple_record_identifier : IDENTIFIER ; special_item : IDENTIFIER ; internal_identifier_of_type_SL : IDENTIFIER ; internal_identifier : IDENTIFIER ; input_record_identifier : IDENTIFIER ; numeric_item_identifier : IDENTIFIER ; subroutine_label : integer ; /* sect 11 */ imperative_command : SET_command | CLEAR_command | MOVE_command | GOTO_command | DO_command | HALT_command | UNLOAD_command | FOR_command | compound_command | OPEN_command | CLOSE_command | REWIND_command | READ command | WRITE_command | PRINT_command | OBTAIN_command | FILE_command | COPY_command | RUN_command | OVERLAY_command | TYPE_command | COMPOSE_command | REREAD_command ; /*-*/ searching_command : COPY_command | SKIP_command ; /*-*/ conditional_command : IF_command ; /*-*/ command : imperative_command | searching_command | conditional_command | compound_command ; /*-*/ compound_command : BEGIN command_list END SET_command : SET numeric_item_identifier '=' arithmetic_expression | SET '('RO')' numeric_item_identifier '=' arithmetic_expression | SET '('RU')' numeric_item_identifier '=' arithmetic_expression | SET numeric_item_identifier '=' operand '/' operand AND numeric_item_identifier '=' REMAINDER ; /*-*/ CLEAR_command : CLEAR internal_identifier_list ; /*-*/ MOVE_command : MOVE internal_list TO internal_identifier_list ; /*-*/ internal_list : UNKNOWN ; /*-*/ GOTO_command : GO TO procedure_label | GO TO numeric_item_identifier ':' label_list ; /*-*/ procedure_label : integer ; /*-*/ DO_command : DO subroutine_label /* more in sect 15 */ ; /*-*/ HALT_command : HALT alarm_number GO TO option_list ; /*-*/ option_list : label_list ; /*-*/ label_list : integer | label_list ',' integer alarm_number : integer | numeric_item_identifier ; /*-*/ UNLOAD_command : UNLOAD ; /*-*/ FOR_command : FOR numeric_item_identifier '=' arithmetic_expression ':' arithmetic_expression ':' arithmetic_expression imperative_command | FOR numeric_item_identifier '=' arithmetic_expression ':' arithmetic_expression UNTIL conditional_expression imperative_command ; /*-*/ OPEN_command : OPEN INPUT file_identifier_list | OPEN OUTPUT file_identifier_list | OPEN REEL INPUT file_identifier | OPEN REEL OUTPUT file_identifier | OPEN REEL '(' numeric_item_identifier ')' INPUT file_identifier | OPEN REEL '(' numeric_item_identifier ')' OUTPUT file_identifier ; /*-*/ CLOSE_command : CLOSE file_identifier_list | CLOSE REEL file_identifier ; /*-*/ REWIND_command : REWIND file_identifier_list ; /*-*/ READ_command : READ file_identifier ; /*-*/ WRITE_command : WRITE output_list FROM internal_list ; /*-*/ PRINT_command : PRINT output_list FROM internal_list | PRINT '(' track_number ')' output_list FROM internal_list | PRINT ':' COLUMN '(' column_position ')' output_list FROM internal_list | PRINT file_identifier | PRINT '(' track_number ')' file_identifier ; /*-*/ track_number : integer | simple_numeric_item_identifier_of_type_D_or_DL ; /*-*/ column_position : integer | simple_numeric_item_identifier_of_type_S_or_SL ; /*-*/ simple_numeric_item_identifier_of_type_D_or_DL : integer ; /*-*/ simple_numeric_item_identifier_of_type_S_or_SL : integer ; /*-*/ OBTAIN_command : OBTAIN file_identifier ; /*-*/ FILE_command : FILE output_list FROM internal_list ; /*-*/ COPY_command : COPY file_identifier TO file_identifier WHEN_statement | COPY file_identifier TO file_identifier ',' arithmetic_expression ; /*-*/ WHEN_statement : simple_WHEN_statement | WHEN_statement simple_WHEN_statement ; /*-*/ simple_WHEN_statement :WHEN conditional_expression imperative_command ; /*-*/ SKIP_command : SKIP file_identifier WHEN_statement | SKIP file_identifier ',' arithmetic_expression ; /*-*/ IF_command : IF conditional_expression imperative_command | IF conditional_expression imperative_command ELSE command ; /*-*/ MARK_command : MARK file_identifier ',' arithmetic_expression ; /*-*/ RUN_command : RUN file_identifier ',' arithmetic_expression ; /*-*/ OVERLAY_command : OVERLAY chapter_number BY chapter_number ; /*-*/ chapter_number : integer ; /*-*/ TYPE_command :TYPE output_list FROM internal_list ; /*-*/ output_list : UNKNOWN ; /*-*/ COMPOSE_command : COMPOSE internal_identifier FROM selection_list ; /*-*/ selection_list : selection | selection ',' selection_list ; /*-*/ selection : alpha_literal | internal_identifier | subset ; /*-*/ subset : SUBSET '(' subset_operand ',' arithmetic_expression ',' arithmetic_expression ')' ; /*-*/ subset_operand : internal_identifier | alpha_literal ; /*-*/ REREAD_command : REREAD file_identifier ; /*-*/ %% %token REREAD %token SUBSET /*?*/ %token COMPOSE %token FROM %token TYPE %token OVERLAY %token BY %token RUN %token MARK %token IF %token SKIP %token WHEN %token COPY %token FILE %token OBTAIN %token BEGIN %token PRINT %token WRITE %token READ %token REWIND %token CLOSE %token OPEN %token FOR %token UNLOAD %token HALT %token DO %token GO %token MOVE %token CLEAR %token SET