Changeset 66f8528 for src/Parser/parser.yy
- Timestamp:
- Dec 15, 2016, 5:16:42 PM (9 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:
- 43385ca, f7ff3fb
- Parents:
- 5802a4f (diff), 596f987b (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
-
src/Parser/parser.yy (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r5802a4f r66f8528 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Oct 26 17:35:53201613 // Update Count : 20 6612 // Last Modified On : Wed Dec 14 21:28:22 2016 13 // Update Count : 2090 14 14 // 15 15 … … 78 78 %token RESTRICT // C99 79 79 %token FORALL LVALUE // CFA 80 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 80 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 81 81 %token VALIST // GCC 82 82 %token BOOL COMPLEX IMAGINARY // C99 … … 153 153 %type<fctl> for_control_expression 154 154 %type<en> subrange 155 %type<constant> asm_name_opt 155 156 %type<en> asm_operands_opt asm_operands_list asm_operand 156 157 %type<label> label_list … … 362 363 { $$ = new ExpressionNode( build_varref( $1 ) ); } 363 364 | zero_one 364 { $$ = new ExpressionNode( build_ varref($1 ) ); }365 { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); } 365 366 | tuple 366 367 | '(' comma_expression ')' … … 412 413 argument_expression: 413 414 // empty 414 { $$ = 0; }// use default argument415 { $$ = nullptr; } // use default argument 415 416 | assignment_expression 416 417 ; … … 443 444 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 444 445 | no_attr_identifier fraction_constants 445 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); } 446 { 447 if( (*$1) == "0" || (*$1) == "1" ) { 448 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) ); 449 } else { 450 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 451 } 452 } 446 453 ; 447 454 … … 678 685 comma_expression_opt: 679 686 // empty 680 { $$ = 0; }687 { $$ = nullptr; } 681 688 | comma_expression 682 689 ; … … 714 721 | '{' 715 722 // Two scopes are necessary because the block itself has a scope, but every declaration within the block also 716 // requires its own scope 723 // requires its own scope. 717 724 push push 718 725 local_label_declaration_opt // GCC, local labels … … 768 775 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 769 776 // statement. 770 $$ = $7 != 0? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;777 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 771 778 } 772 779 | CHOOSE '(' comma_expression ')' case_clause // CFA … … 775 782 { 776 783 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 777 $$ = $7 != 0? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;784 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 778 785 } 779 786 ; … … 812 819 switch_clause_list_opt: // CFA 813 820 // empty 814 { $$ = 0; }821 { $$ = nullptr; } 815 822 | switch_clause_list 816 823 ; … … 825 832 choose_clause_list_opt: // CFA 826 833 // empty 827 { $$ = 0; }834 { $$ = nullptr; } 828 835 | choose_clause_list 829 836 ; … … 848 855 fall_through: // CFA 849 856 FALLTHRU 850 { $$ = 0; }857 { $$ = nullptr; } 851 858 | FALLTHRU ';' 852 { $$ = 0; }859 { $$ = nullptr; } 853 860 ; 854 861 … … 984 991 asm_operands_opt: // GCC 985 992 // empty 986 { $$ = 0; }// use default argument993 { $$ = nullptr; } // use default argument 987 994 | asm_operands_list 988 995 ; … … 1003 1010 asm_clobbers_list_opt: // GCC 1004 1011 // empty 1005 { $$ = 0; }// use default argument1012 { $$ = nullptr; } // use default argument 1006 1013 | string_literal 1007 1014 { $$ = new ExpressionNode( $1 ); } 1008 1015 | asm_clobbers_list_opt ',' string_literal 1016 // set_last return ParseNode * 1009 1017 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 1010 1018 ; … … 1027 1035 declaration_list_opt: // used at beginning of switch statement 1028 1036 pop 1029 { $$ = 0; }1037 { $$ = nullptr; } 1030 1038 | declaration_list 1031 1039 ; … … 1039 1047 old_declaration_list_opt: // used to declare parameter types in K&R style functions 1040 1048 pop 1041 { $$ = 0; }1049 { $$ = nullptr; } 1042 1050 | old_declaration_list 1043 1051 ; … … 1114 1122 { 1115 1123 typedefTable.setNextIdentifier( *$2 ); 1116 $$ = $1->addName( $2 ) ;1124 $$ = $1->addName( $2 )->addAsmName( $3 ); 1117 1125 } 1118 1126 | new_abstract_tuple identifier_or_type_name asm_name_opt 1119 1127 { 1120 1128 typedefTable.setNextIdentifier( *$2 ); 1121 $$ = $1->addName( $2 ) ;1129 $$ = $1->addName( $2 )->addAsmName( $3 ); 1122 1130 } 1123 1131 | type_qualifier_list new_abstract_tuple identifier_or_type_name asm_name_opt 1124 1132 { 1125 1133 typedefTable.setNextIdentifier( *$3 ); 1126 $$ = $2->addQualifiers( $1 )->addName( $3 ) ;1134 $$ = $2->addQualifiers( $1 )->addName( $3 )->addAsmName( $4 ); 1127 1135 } 1128 1136 ; … … 1275 1283 { 1276 1284 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1277 $$ = ( $2->addType( $1 ))->add Initializer( $4 );1285 $$ = ( $2->addType( $1 ))->addAsmName( $3 )->addInitializer( $4 ); 1278 1286 } 1279 1287 | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt 1280 1288 { 1281 1289 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1282 $$ = $1->appendList( $1->cloneBaseType( $4->add Initializer( $6 ) ) );1290 $$ = $1->appendList( $1->cloneBaseType( $4->addAsmName( $5 )->addInitializer( $6 ) ) ); 1283 1291 } 1284 1292 ; … … 1300 1308 type_qualifier_list_opt: // GCC, used in asm_statement 1301 1309 // empty 1302 { $$ = 0; }1310 { $$ = nullptr; } 1303 1311 | type_qualifier_list 1304 1312 ; … … 1410 1418 | VALIST // GCC, __builtin_va_list 1411 1419 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1420 | ZERO_T 1421 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1422 | ONE_T 1423 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1412 1424 ; 1413 1425 … … 1522 1534 field_declaration_list: 1523 1535 // empty 1524 { $$ = 0; }1536 { $$ = nullptr; } 1525 1537 | field_declaration_list field_declaration 1526 { $$ = $1 != 0? $1->appendList( $2 ) : $2; }1538 { $$ = $1 ? $1->appendList( $2 ) : $2; } 1527 1539 ; 1528 1540 … … 1573 1585 bit_subrange_size_opt: 1574 1586 // empty 1575 { $$ = 0; }1587 { $$ = nullptr; } 1576 1588 | bit_subrange_size 1577 1589 { $$ = $1; } … … 1610 1622 enumerator_value_opt: 1611 1623 // empty 1612 { $$ = 0; }1624 { $$ = nullptr; } 1613 1625 | '=' constant_expression 1614 1626 { $$ = $2; } … … 1619 1631 new_parameter_type_list_opt: // CFA 1620 1632 // empty 1621 { $$ = 0; }1633 { $$ = nullptr; } 1622 1634 | new_parameter_type_list 1623 1635 ; … … 1654 1666 parameter_type_list_opt: 1655 1667 // empty 1656 { $$ = 0; }1668 { $$ = nullptr; } 1657 1669 | parameter_type_list 1658 1670 ; … … 1702 1714 { 1703 1715 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1704 $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ));1716 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1705 1717 } 1706 1718 | declaration_specifier type_parameter_redeclarator assignment_opt 1707 1719 { 1708 1720 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1709 $$ = $2->addType( $1 )->addInitializer( new InitializerNode( $3 ));1721 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1710 1722 } 1711 1723 ; … … 1763 1775 initializer_opt: 1764 1776 // empty 1765 { $$ = 0; }1777 { $$ = nullptr; } 1766 1778 | '=' initializer 1767 1779 { $$ = $2; } … … 1777 1789 initializer_list: 1778 1790 // empty 1779 { $$ = 0; }1791 { $$ = nullptr; } 1780 1792 | initializer 1781 1793 | designation initializer { $$ = $2->set_designators( $1 ); } … … 1888 1900 assertion_list_opt: // CFA 1889 1901 // empty 1890 { $$ = 0; }1902 { $$ = nullptr; } 1891 1903 | assertion_list_opt assertion 1892 { $$ = $1 != 0? $1->appendList( $2 ) : $2; }1904 { $$ = $1 ? $1->appendList( $2 ) : $2; } 1893 1905 ; 1894 1906 … … 1902 1914 { $$ = $4; } 1903 1915 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')' 1904 { $$ = 0; }1916 { $$ = nullptr; } 1905 1917 ; 1906 1918 … … 2011 2023 {} // empty input file 2012 2024 | external_definition_list 2013 { parseTree = parseTree != nullptr? parseTree->appendList( $1 ) : $1; }2025 { parseTree = parseTree ? parseTree->appendList( $1 ) : $1; } 2014 2026 ; 2015 2027 … … 2017 2029 external_definition 2018 2030 | external_definition_list push external_definition 2019 { $$ = $1 != nullptr? $1->appendList( $3 ) : $3; }2031 { $$ = $1 ? $1->appendList( $3 ) : $3; } 2020 2032 ; 2021 2033 2022 2034 external_definition_list_opt: 2023 2035 // empty 2024 { $$ = 0; }2036 { $$ = nullptr; } 2025 2037 | external_definition_list 2026 2038 ; … … 2145 2157 asm_name_opt: // GCC 2146 2158 // empty 2147 | ASM '(' string_literal_list ')' attribute_list_opt { delete $3; } // FIX ME: unimplemented 2159 { $$ = nullptr; } 2160 | ASM '(' string_literal ')' attribute_list_opt 2161 { $$ = $3; } 2148 2162 ; 2149 2163 2150 2164 attribute_list_opt: // GCC 2151 2165 // empty 2152 { $$ = 0; }2166 { $$ = nullptr; } 2153 2167 | attribute_list 2154 2168 ; … … 2163 2177 ATTRIBUTE '(' '(' attribute_parameter_list ')' ')' 2164 2178 // { $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); } 2165 { $$ = 0; }2179 { $$ = nullptr; } 2166 2180 ; 2167 2181 … … 2872 2886 assignment_opt: 2873 2887 // empty 2874 { $$ = 0; }2888 { $$ = nullptr; } 2875 2889 | '=' assignment_expression 2876 2890 { $$ = $2; }
Note:
See TracChangeset
for help on using the changeset viewer.