Changes in src/Parser/parser.yy [1efa1e1:9bd6105]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r1efa1e1 r9bd6105 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:08:08201713 // Update Count : 27 0412 // Last Modified On : Sat Aug 26 17:50:19 2017 13 // Update Count : 2712 14 14 // 15 15 … … 97 97 DeclarationNode::TypeClass tclass; 98 98 StatementNode * sn; 99 WaitForStmt * wfs; 99 100 ConstantExpr * constant; 100 101 IfCtl * ifctl; … … 119 120 %token RESTRICT // C99 120 121 %token ATOMIC // C11 121 %token FORALL MUTEX VIRTUAL // CFA122 %token FORALL MUTEX VIRTUAL // CFA 122 123 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 123 124 %token BOOL COMPLEX IMAGINARY // C99 … … 189 190 190 191 // statements 191 %type<sn> labeled_statement compound_statement expression_statement selection_statement 192 %type<sn> iteration_statement jump_statement 193 %type<sn> with_statement exception_statement asm_statement 194 %type<sn> when_clause_opt waitfor_statement waitfor_clause waitfor timeout 195 %type<sn> fall_through_opt fall_through 196 %type<sn> statement statement_list 197 %type<sn> block_item_list block_item 198 %type<sn> with_clause_opt 192 %type<sn> statement labeled_statement compound_statement 193 %type<sn> statement_decl statement_decl_list statement_list_nodecl 194 %type<sn> selection_statement 195 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 199 196 %type<en> case_value 200 197 %type<sn> case_clause case_value_list case_label case_label_list 201 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 202 %type<sn> handler_clause finally_clause 198 %type<sn> fall_through fall_through_opt 199 %type<sn> iteration_statement jump_statement 200 %type<sn> expression_statement asm_statement 201 %type<sn> with_statement with_clause_opt 202 %type<sn> exception_statement handler_clause finally_clause 203 203 %type<catch_kind> handler_key 204 %type<en> when_clause when_clause_opt waitfor timeout 205 %type<sn> waitfor_statement 206 %type<wfs> waitfor_clause 204 207 205 208 // declarations … … 773 776 push push 774 777 local_label_declaration_opt // GCC, local labels 775 block_item_list// C99, intermix declarations and statements778 statement_decl_list // C99, intermix declarations and statements 776 779 pop '}' 777 780 { $$ = new StatementNode( build_compound( $5 ) ); } 778 781 ; 779 782 780 block_item_list:// C99781 block_item782 | block_item_list push block_item783 statement_decl_list: // C99 784 statement_decl 785 | statement_decl_list push statement_decl 783 786 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } } 784 787 ; 785 788 786 block_item:789 statement_decl: 787 790 declaration // CFA, new & old style declarations 788 791 { $$ = new StatementNode( $1 ); } … … 802 805 ; 803 806 804 statement_list :807 statement_list_nodecl: 805 808 statement 806 | statement_list statement809 | statement_list_nodecl statement 807 810 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 808 811 ; … … 814 817 815 818 selection_statement: 816 IF '(' push if_control_expression ')' statement %prec THEN819 IF '(' push if_control_expression ')' statement %prec THEN 817 820 // explicitly deal with the shift/reduce conflict on if/else 818 821 { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); } … … 889 892 890 893 switch_clause_list: // CFA 891 case_label_list statement_list 894 case_label_list statement_list_nodecl 892 895 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); } 893 | switch_clause_list case_label_list statement_list 896 | switch_clause_list case_label_list statement_list_nodecl 894 897 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 895 898 ; … … 904 907 case_label_list fall_through 905 908 { $$ = $1->append_last_case( $2 ); } 906 | case_label_list statement_list fall_through_opt909 | case_label_list statement_list_nodecl fall_through_opt 907 910 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); } 908 911 | choose_clause_list case_label_list fall_through 909 912 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); } 910 | choose_clause_list case_label_list statement_list fall_through_opt913 | choose_clause_list case_label_list statement_list_nodecl fall_through_opt 911 914 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); } 912 915 ; … … 977 980 ; 978 981 982 when_clause: 983 WHEN '(' comma_expression ')' 984 { $$ = $3; } 985 ; 986 979 987 when_clause_opt: 980 988 // empty 981 { $$ = nullptr; } // FIX ME 982 | WHEN '(' comma_expression ')' 983 { $$ = nullptr; } // FIX ME 989 { $$ = nullptr; } 990 | when_clause 984 991 ; 985 992 986 993 waitfor: 987 994 WAITFOR '(' identifier ')' 988 { $$ = nullptr; } // FIX ME 995 { 996 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 997 delete $3; 998 } 989 999 | WAITFOR '(' identifier ',' argument_expression_list ')' 990 { $$ = nullptr; } // FIX ME 1000 { 1001 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 1002 $$->set_last( $5 ); 1003 delete $3; 1004 } 991 1005 ; 992 1006 993 1007 timeout: 994 1008 TIMEOUT '(' comma_expression ')' 995 { $$ = nullptr; } // FIX ME1009 { $$ = $3; } 996 1010 ; 997 1011 998 1012 waitfor_clause: 999 when_clause_opt waitfor statement %prec THEN1000 { $$ = nullptr; } // FIX ME1013 when_clause_opt waitfor statement %prec THEN 1014 { $$ = build_waitfor( $2, $3, $1 ); } 1001 1015 | when_clause_opt waitfor statement WOR waitfor_clause 1002 { $$ = nullptr; } // FIX ME1003 | when_clause_opt timeout statement %prec THEN1004 { $$ = nullptr; } // FIX ME1016 { $$ = build_waitfor( $2, $3, $1, $5 ); } 1017 | when_clause_opt timeout statement %prec THEN 1018 { $$ = build_waitfor_timeout( $2, $3, $1 ); } 1005 1019 | when_clause_opt ELSE statement 1006 { $$ = nullptr; } // FIX ME 1007 | when_clause_opt timeout statement WOR when_clause_opt ELSE statement 1008 { $$ = nullptr; } // FIX ME 1020 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); } 1021 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1022 | when_clause_opt timeout statement WOR when_clause ELSE statement 1023 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); } 1009 1024 ; 1010 1025 1011 1026 waitfor_statement: 1012 when_clause_opt waitfor statement %prec THEN1013 { $$ = n ullptr; } // FIX ME1027 when_clause_opt waitfor statement %prec THEN 1028 { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); } 1014 1029 | when_clause_opt waitfor statement WOR waitfor_clause 1015 { $$ = n ullptr; } // FIX ME1030 { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); } 1016 1031 ; 1017 1032
Note:
See TracChangeset
for help on using the changeset viewer.