Changes in src/Parser/parser.yy [cbce272:8b47e50]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rcbce272 r8b47e50 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 4 13:33:00201713 // Update Count : 24 7511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 12 18:23:36 2017 13 // Update Count : 2426 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %token ATOMIC // C11 120 %token FORALL LVALUE MUTEX VIRTUAL // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 120 %token FORALL LVALUE MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 122 %token VALIST // GCC 122 123 %token BOOL COMPLEX IMAGINARY // C99 123 %token ZERO_T ONE_T // CFA124 %token VALIST // GCC125 124 %token TYPEOF LABEL // GCC 126 125 %token ENUM STRUCT UNION … … 142 141 // converted into the tuple index (.)(1). e.g., 3.x 143 142 %token<tok> REALDECIMALconstant REALFRACTIONconstant FLOATINGconstant 143 %token<tok> ZERO ONE // CFA 144 144 145 145 // multi-character operators … … 151 151 %token ELLIPSIS // ... 152 152 153 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %=153 %token 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 160 %type<tok> identifier no_attr_identifier zero_one 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 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 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 175 174 %type<en> comma_expression comma_expression_opt 176 %type<en> argument_expression_list argument_expression default_initialize_opt175 %type<en> argument_expression_list argument_expression assignment_opt 177 176 %type<fctl> for_control_expression 178 177 %type<en> subrange … … 182 181 %type<en> asm_clobbers_list_opt 183 182 %type<flag> asm_volatile_opt 184 %type<en> handler_predicate_opt185 183 186 184 // statements … … 360 358 ; 361 359 360 zero_one: // CFA 361 ZERO 362 | ONE 363 ; 364 362 365 string_literal: 363 366 string_literal_list { $$ = build_constantStr( *$1 ); } … … 379 382 IDENTIFIER // typedef name cannot be used as a variable name 380 383 { $$ = new ExpressionNode( build_varref( $1 ) ); } 384 | zero_one 385 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); } 381 386 | tuple 382 387 | '(' comma_expression ')' … … 478 483 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 479 484 } 485 | zero_one fraction_constants 486 { 487 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) ); 488 } 480 489 ; 481 490 … … 528 537 | ALIGNOF unary_expression // GCC, variable alignment 529 538 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 530 | ALIGNOF '(' type_no_function ')' // GCC, type alignment539 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 531 540 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 532 541 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' … … 560 569 | '(' type_no_function ')' cast_expression 561 570 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 562 // VIRTUAL cannot be opt because of look ahead issues563 | '(' VIRTUAL ')' cast_expression564 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); }565 | '(' VIRTUAL type_no_function ')' cast_expression566 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); }567 571 // | '(' type_no_function ')' tuple 568 572 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 569 573 ; 570 574 571 exponential_expression:575 multiplicative_expression: 572 576 cast_expression 573 | exponential_expression '\\' cast_expression 574 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 575 ; 576 577 multiplicative_expression: 578 exponential_expression 579 | multiplicative_expression '*' exponential_expression 577 | multiplicative_expression '*' cast_expression 580 578 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 581 | multiplicative_expression '/' exponential_expression579 | multiplicative_expression '/' cast_expression 582 580 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 583 | multiplicative_expression '%' exponential_expression581 | multiplicative_expression '%' cast_expression 584 582 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 585 583 ; … … 680 678 '=' { $$ = OperKinds::Assign; } 681 679 | ATassign { $$ = OperKinds::AtAssn; } 682 | EXPassign { $$ = OperKinds::ExpAssn; }683 680 | MULTassign { $$ = OperKinds::MulAssn; } 684 681 | DIVassign { $$ = OperKinds::DivAssn; } … … 942 939 943 940 with_statement: 944 WITH '(' tuple_expression_list ')'compound_statement941 WITH identifier_list compound_statement 945 942 { $$ = (StatementNode *)0; } // FIX ME 946 943 ; … … 969 966 970 967 handler_clause: 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; } 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 ) ) ); } 982 978 ; 983 979 … … 1506 1502 | IMAGINARY // C99 1507 1503 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1504 | VALIST // GCC, __builtin_va_list 1505 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1508 1506 | ZERO_T 1509 1507 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1510 1508 | ONE_T 1511 1509 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1512 | VALIST // GCC, __builtin_va_list1513 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1514 1510 ; 1515 1511 … … 1849 1845 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1850 1846 parameter_declaration 1851 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt1847 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt 1852 1848 { $$ = $1->addName( $2 ); } 1853 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt1849 | cfa_abstract_tuple identifier_or_type_name assignment_opt 1854 1850 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1855 1851 { $$ = $1->addName( $2 ); } 1856 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt1852 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt 1857 1853 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1858 1854 | cfa_function_specifier … … 1871 1867 parameter_declaration: 1872 1868 // No SUE declaration in parameter list. 1873 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt1869 declaration_specifier_nobody identifier_parameter_declarator assignment_opt 1874 1870 { 1875 1871 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1876 1872 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1877 1873 } 1878 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt1874 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt 1879 1875 { 1880 1876 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1884 1880 1885 1881 abstract_parameter_declaration: 1886 declaration_specifier_nobody default_initialize_opt1882 declaration_specifier_nobody assignment_opt 1887 1883 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1888 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt1884 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt 1889 1885 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1890 1886 ; … … 1930 1926 | '=' initializer 1931 1927 { $$ = $2; } 1932 | '=' VOID1933 { $$ = nullptr; }1934 1928 | ATassign initializer 1935 1929 { $$ = $2->set_maybeConstructed( false ); } … … 2228 2222 // empty 2229 2223 { $$ = (StatementNode *)0; } // FIX ME 2230 | WITH '(' tuple_expression_list ')'2224 | WITH identifier_list 2231 2225 { $$ = (StatementNode *)0; } // FIX ME 2232 2226 ; … … 3051 3045 ; 3052 3046 3053 default_initialize_opt:3047 assignment_opt: 3054 3048 // empty 3055 3049 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.