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