Changes in src/Parser/parser.yy [8b47e50:cbce272]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r8b47e50 rcbce272 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jul 12 18:23:36201713 // Update Count : 24 2611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 4 13:33:00 2017 13 // Update Count : 2475 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %token ATOMIC // C11 120 %token FORALL LVALUE MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 120 %token FORALL LVALUE MUTEX VIRTUAL // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 122 %token BOOL COMPLEX IMAGINARY // C99 123 %token ZERO_T ONE_T // CFA 122 124 %token VALIST // GCC 123 %token BOOL COMPLEX IMAGINARY // C99124 125 %token TYPEOF LABEL // GCC 125 126 %token ENUM STRUCT UNION … … 141 142 // converted into the tuple index (.)(1). e.g., 3.x 142 143 %token<tok> REALDECIMALconstant REALFRACTIONconstant FLOATINGconstant 143 %token<tok> ZERO ONE // CFA144 144 145 145 // multi-character operators … … 151 151 %token ELLIPSIS // ... 152 152 153 %token MULTassign DIVassign MODassign // *= /= %=/153 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %= 154 154 %token PLUSassign MINUSassign // += -= 155 155 %token LSassign RSassign // <<= >>= … … 158 158 %token ATassign // @= 159 159 160 %type<tok> identifier no_attr_identifier zero_one160 %type<tok> identifier no_attr_identifier 161 161 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 162 162 %type<constant> string_literal … … 168 168 %type<op> ptrref_operator unary_operator assignment_operator 169 169 %type<en> primary_expression postfix_expression unary_expression 170 %type<en> cast_expression multiplicative_expression additive_expression shift_expression 171 %type<en> relational_expression equality_expression AND_expression exclusive_OR_expression 172 %type<en> inclusive_OR_expression logical_AND_expression logical_OR_expression conditional_expression 173 %type<en> constant_expression assignment_expression assignment_expression_opt 170 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression 171 %type<en> shift_expression relational_expression equality_expression 172 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression 173 %type<en> logical_AND_expression logical_OR_expression 174 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 174 175 %type<en> comma_expression comma_expression_opt 175 %type<en> argument_expression_list argument_expression assignment_opt176 %type<en> argument_expression_list argument_expression default_initialize_opt 176 177 %type<fctl> for_control_expression 177 178 %type<en> subrange … … 181 182 %type<en> asm_clobbers_list_opt 182 183 %type<flag> asm_volatile_opt 184 %type<en> handler_predicate_opt 183 185 184 186 // statements … … 358 360 ; 359 361 360 zero_one: // CFA361 ZERO362 | ONE363 ;364 365 362 string_literal: 366 363 string_literal_list { $$ = build_constantStr( *$1 ); } … … 382 379 IDENTIFIER // typedef name cannot be used as a variable name 383 380 { $$ = new ExpressionNode( build_varref( $1 ) ); } 384 | zero_one385 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }386 381 | tuple 387 382 | '(' comma_expression ')' … … 483 478 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 484 479 } 485 | zero_one fraction_constants486 {487 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );488 }489 480 ; 490 481 … … 537 528 | ALIGNOF unary_expression // GCC, variable alignment 538 529 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 539 | ALIGNOF '(' type_no_function ')' // GCC, type alignment530 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 540 531 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 541 532 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' … … 569 560 | '(' type_no_function ')' cast_expression 570 561 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 562 // VIRTUAL cannot be opt because of look ahead issues 563 | '(' VIRTUAL ')' cast_expression 564 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); } 565 | '(' VIRTUAL type_no_function ')' cast_expression 566 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); } 571 567 // | '(' type_no_function ')' tuple 572 568 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 569 ; 574 570 571 exponential_expression: 572 cast_expression 573 | exponential_expression '\\' cast_expression 574 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 575 ; 576 575 577 multiplicative_expression: 576 cast_expression577 | multiplicative_expression '*' cast_expression578 exponential_expression 579 | multiplicative_expression '*' exponential_expression 578 580 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 579 | multiplicative_expression '/' cast_expression581 | multiplicative_expression '/' exponential_expression 580 582 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 581 | multiplicative_expression '%' cast_expression583 | multiplicative_expression '%' exponential_expression 582 584 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 583 585 ; … … 678 680 '=' { $$ = OperKinds::Assign; } 679 681 | ATassign { $$ = OperKinds::AtAssn; } 682 | EXPassign { $$ = OperKinds::ExpAssn; } 680 683 | MULTassign { $$ = OperKinds::MulAssn; } 681 684 | DIVassign { $$ = OperKinds::DivAssn; } … … 939 942 940 943 with_statement: 941 WITH identifier_listcompound_statement944 WITH '(' tuple_expression_list ')' compound_statement 942 945 { $$ = (StatementNode *)0; } // FIX ME 943 946 ; … … 966 969 967 970 handler_clause: 968 // TEMPORARY, TEST EXCEPTIONS 969 handler_key '(' push push INTEGERconstant pop ')' compound_statement pop 970 { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); } 971 | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop 972 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 973 974 | handler_key '(' push push exception_declaration pop ')' compound_statement pop 975 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); } 976 | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop 977 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); } 971 handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 972 { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); } 973 | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 974 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); } 975 ; 976 977 handler_predicate_opt: 978 //empty 979 { $$ = nullptr; } 980 | ';' conditional_expression 981 { $$ = $2; } 978 982 ; 979 983 … … 1502 1506 | IMAGINARY // C99 1503 1507 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1504 | VALIST // GCC, __builtin_va_list1505 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1506 1508 | ZERO_T 1507 1509 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1508 1510 | ONE_T 1509 1511 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1512 | VALIST // GCC, __builtin_va_list 1513 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1510 1514 ; 1511 1515 … … 1845 1849 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1846 1850 parameter_declaration 1847 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1851 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1848 1852 { $$ = $1->addName( $2 ); } 1849 | cfa_abstract_tuple identifier_or_type_name assignment_opt1853 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1850 1854 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1851 1855 { $$ = $1->addName( $2 ); } 1852 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1856 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1853 1857 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1854 1858 | cfa_function_specifier … … 1867 1871 parameter_declaration: 1868 1872 // No SUE declaration in parameter list. 1869 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1873 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1870 1874 { 1871 1875 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1872 1876 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1873 1877 } 1874 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1878 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1875 1879 { 1876 1880 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1880 1884 1881 1885 abstract_parameter_declaration: 1882 declaration_specifier_nobody assignment_opt1886 declaration_specifier_nobody default_initialize_opt 1883 1887 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1884 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1888 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1885 1889 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1886 1890 ; … … 1926 1930 | '=' initializer 1927 1931 { $$ = $2; } 1932 | '=' VOID 1933 { $$ = nullptr; } 1928 1934 | ATassign initializer 1929 1935 { $$ = $2->set_maybeConstructed( false ); } … … 2222 2228 // empty 2223 2229 { $$ = (StatementNode *)0; } // FIX ME 2224 | WITH identifier_list2230 | WITH '(' tuple_expression_list ')' 2225 2231 { $$ = (StatementNode *)0; } // FIX ME 2226 2232 ; … … 3045 3051 ; 3046 3052 3047 assignment_opt:3053 default_initialize_opt: 3048 3054 // empty 3049 3055 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.