Changeset 9236060 for src/Parser/parser.yy
- Timestamp:
- Aug 14, 2017, 2:03:39 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rfd344aa r9236060 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 MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 120 %token FORALL 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 … … 1500 1504 | IMAGINARY // C99 1501 1505 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1502 | VALIST // GCC, __builtin_va_list1503 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1504 1506 | ZERO_T 1505 1507 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1506 1508 | ONE_T 1507 1509 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1510 | VALIST // GCC, __builtin_va_list 1511 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1508 1512 ; 1509 1513 … … 1843 1847 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1844 1848 parameter_declaration 1845 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1849 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1846 1850 { $$ = $1->addName( $2 ); } 1847 | cfa_abstract_tuple identifier_or_type_name assignment_opt1851 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1848 1852 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1849 1853 { $$ = $1->addName( $2 ); } 1850 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1854 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1851 1855 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1852 1856 | cfa_function_specifier … … 1865 1869 parameter_declaration: 1866 1870 // No SUE declaration in parameter list. 1867 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1871 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1868 1872 { 1869 1873 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1870 1874 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1871 1875 } 1872 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1876 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1873 1877 { 1874 1878 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1878 1882 1879 1883 abstract_parameter_declaration: 1880 declaration_specifier_nobody assignment_opt1884 declaration_specifier_nobody default_initialize_opt 1881 1885 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1882 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1886 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1883 1887 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1884 1888 ; … … 1924 1928 | '=' initializer 1925 1929 { $$ = $2; } 1930 | '=' VOID 1931 { $$ = nullptr; } 1926 1932 | ATassign initializer 1927 1933 { $$ = $2->set_maybeConstructed( false ); } … … 2220 2226 // empty 2221 2227 { $$ = (StatementNode *)0; } // FIX ME 2222 | WITH identifier_list2228 | WITH '(' tuple_expression_list ')' 2223 2229 { $$ = (StatementNode *)0; } // FIX ME 2224 2230 ; … … 3043 3049 ; 3044 3050 3045 assignment_opt:3051 default_initialize_opt: 3046 3052 // empty 3047 3053 { $$ = nullptr; }
Note: See TracChangeset
for help on using the changeset viewer.