Changeset 60401b76 for src/Parser/parser.yy
- Timestamp:
- Feb 28, 2017, 4:44:00 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:
- be65cca
- Parents:
- 1e6b350 (diff), 20221d4 (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) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r1e6b350 r60401b76 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 23 15:23:49201713 // Update Count : 2 18712 // Last Modified On : Tue Feb 28 09:58:10 2017 13 // Update Count : 2208 14 14 // 15 15 … … 196 196 197 197 %type<aggKey> aggregate_key 198 %type<decl> aggregate_type198 %type<decl> aggregate_type aggregate_type_nobody 199 199 200 200 %type<decl> assertion assertion_list_opt … … 207 207 208 208 %type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list 209 %type<decl> declaration_specifier declarat or declaring_list210 211 %type<decl> elaborated_type 212 213 %type<decl> enumerator_list enum_type 209 %type<decl> declaration_specifier declaration_specifier_nobody declarator declaring_list 210 211 %type<decl> elaborated_type elaborated_type_nobody 212 213 %type<decl> enumerator_list enum_type enum_type_nobody 214 214 %type<en> enumerator_value_opt 215 215 … … 251 251 %type<decl> storage_class storage_class_list 252 252 253 %type<decl> sue_declaration_specifier sue_ type_specifier253 %type<decl> sue_declaration_specifier sue_declaration_specifier_nobody sue_type_specifier sue_type_specifier_nobody 254 254 255 255 %type<tclass> type_class … … 268 268 %type<en> type_name_list 269 269 270 %type<decl> type_qualifier type_qualifier_name type_qualifier_list type_qualifier_list_opt type_specifier 270 %type<decl> type_qualifier type_qualifier_name type_qualifier_list type_qualifier_list_opt type_specifier type_specifier_nobody 271 271 272 272 %type<decl> variable_declarator variable_ptr variable_array variable_function … … 973 973 974 974 exception_declaration: 975 // A semantic check is required to ensure type_specifier does not create a new type, e.g.: 976 // 977 // catch ( struct { int i; } x ) ... 978 // 979 // This new type cannot catch any thrown type because of name equivalence among types. 980 type_specifier 981 | type_specifier declarator 975 // No SUE declaration in parameter list. 976 type_specifier_nobody 977 | type_specifier_nobody declarator 982 978 { 983 979 typedefTable.addToEnclosingScope( TypedefTable::ID ); 984 980 $$ = $2->addType( $1 ); 985 981 } 986 | type_specifier variable_abstract_declarator982 | type_specifier_nobody variable_abstract_declarator 987 983 { $$ = $2->addType( $1 ); } 988 984 | cfa_abstract_declarator_tuple no_attr_identifier // CFA … … 1349 1345 ; 1350 1346 1351 type_specifier: // declaration specifier - storage class 1347 declaration_specifier_nobody: // type specifier + storage class - {...} 1348 // Preclude SUE declarations in restricted scopes: 1349 // 1350 // int f( struct S { int i; } s1, Struct S s2 ) { struct S s3; ... } 1351 // 1352 // because it is impossible to call f due to name equivalence. 1353 basic_declaration_specifier 1354 | sue_declaration_specifier_nobody 1355 | typedef_declaration_specifier 1356 | typegen_declaration_specifier 1357 ; 1358 1359 type_specifier: // type specifier 1352 1360 basic_type_specifier 1353 1361 | sue_type_specifier 1362 | typedef_type_specifier 1363 | typegen_type_specifier 1364 ; 1365 1366 type_specifier_nobody: // type specifier - {...} 1367 // Preclude SUE declarations in restricted scopes: 1368 // 1369 // int f( struct S { int i; } s1, Struct S s2 ) { struct S s3; ... } 1370 // 1371 // because it is impossible to call f due to name equivalence. 1372 basic_type_specifier 1373 | sue_type_specifier_nobody 1354 1374 | typedef_type_specifier 1355 1375 | typegen_type_specifier … … 1514 1534 ; 1515 1535 1516 sue_declaration_specifier: 1536 sue_declaration_specifier: // struct, union, enum + storage class + type specifier 1517 1537 sue_type_specifier 1518 1538 | declaration_qualifier_list sue_type_specifier … … 1524 1544 ; 1525 1545 1526 sue_type_specifier: 1527 elaborated_type // struct, union, enum1546 sue_type_specifier: // struct, union, enum + type specifier 1547 elaborated_type 1528 1548 | type_qualifier_list elaborated_type 1529 1549 { $$ = $2->addQualifiers( $1 ); } 1530 1550 | sue_type_specifier type_qualifier 1551 { $$ = $1->addQualifiers( $2 ); } 1552 ; 1553 1554 sue_declaration_specifier_nobody: // struct, union, enum - {...} + storage class + type specifier 1555 sue_type_specifier_nobody 1556 | declaration_qualifier_list sue_type_specifier_nobody 1557 { $$ = $2->addQualifiers( $1 ); } 1558 | sue_declaration_specifier_nobody storage_class // remaining OBSOLESCENT (see 2) 1559 { $$ = $1->addQualifiers( $2 ); } 1560 | sue_declaration_specifier_nobody storage_class type_qualifier_list 1561 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1562 ; 1563 1564 sue_type_specifier_nobody: // struct, union, enum - {...} + type specifier 1565 elaborated_type_nobody 1566 | type_qualifier_list elaborated_type_nobody 1567 { $$ = $2->addQualifiers( $1 ); } 1568 | sue_type_specifier_nobody type_qualifier 1531 1569 { $$ = $1->addQualifiers( $2 ); } 1532 1570 ; … … 1551 1589 ; 1552 1590 1553 elaborated_type: 1591 elaborated_type: // struct, union, enum 1554 1592 aggregate_type 1555 1593 | enum_type 1556 1594 ; 1557 1595 1558 aggregate_type: 1596 elaborated_type_nobody: // struct, union, enum - {...} 1597 aggregate_type_nobody 1598 | enum_type_nobody 1599 ; 1600 1601 aggregate_type: // struct, union 1559 1602 aggregate_key attribute_list_opt '{' field_declaration_list '}' 1560 1603 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $4, true )->addQualifiers( $2 ); } 1561 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name1562 {1563 typedefTable.makeTypedef( *$3 );1564 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );1565 }1566 1604 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1567 1605 { typedefTable.makeTypedef( *$3 ); } … … 1570 1608 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1571 1609 { $$ = DeclarationNode::newAggregate( $1, nullptr, $4, $7, false )->addQualifiers( $2 ); } 1610 | aggregate_type_nobody 1611 ; 1612 1613 aggregate_type_nobody: // struct, union - {...} 1614 aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1615 { 1616 typedefTable.makeTypedef( *$3 ); 1617 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1618 } 1572 1619 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1573 1620 { $$ = $3->addQualifiers( $2 ); } … … 1647 1694 ; 1648 1695 1649 enum_type: 1696 enum_type: // enum 1650 1697 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 1651 1698 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 1652 | ENUM attribute_list_opt no_attr_identifier_or_type_name1653 {1654 typedefTable.makeTypedef( *$3 );1655 $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 );1656 }1657 1699 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1658 1700 { typedefTable.makeTypedef( *$3 ); } 1659 1701 '{' enumerator_list comma_opt '}' 1660 1702 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); } 1703 | enum_type_nobody 1704 ; 1705 1706 enum_type_nobody: // enum - {...} 1707 ENUM attribute_list_opt no_attr_identifier_or_type_name 1708 { 1709 typedefTable.makeTypedef( *$3 ); 1710 $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); 1711 } 1661 1712 ; 1662 1713 … … 1759 1810 1760 1811 parameter_declaration: 1761 declaration_specifier identifier_parameter_declarator assignment_opt 1812 // No SUE declaration in parameter list. 1813 declaration_specifier_nobody identifier_parameter_declarator assignment_opt 1762 1814 { 1763 1815 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1764 1816 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1765 1817 } 1766 | declaration_specifier type_parameter_redeclarator assignment_opt1818 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt 1767 1819 { 1768 1820 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1772 1824 1773 1825 abstract_parameter_declaration: 1774 declaration_specifier assignment_opt1826 declaration_specifier_nobody assignment_opt 1775 1827 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1776 | declaration_specifier abstract_parameter_declarator assignment_opt1828 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt 1777 1829 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1778 1830 ; … … 2798 2850 2799 2851 cfa_identifier_parameter_ptr: // CFA 2800 ptrref_operator type_specifier 2852 // No SUE declaration in parameter list. 2853 ptrref_operator type_specifier_nobody 2801 2854 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 2802 | type_qualifier_list ptrref_operator type_specifier 2855 | type_qualifier_list ptrref_operator type_specifier_nobody 2803 2856 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); } 2804 2857 | ptrref_operator cfa_abstract_function … … 2815 2868 // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to 2816 2869 // shift/reduce conflict with new-style empty (void) function return type. 2817 '[' ']' type_specifier 2870 '[' ']' type_specifier_nobody 2818 2871 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2819 | cfa_array_parameter_1st_dimension type_specifier 2872 | cfa_array_parameter_1st_dimension type_specifier_nobody 2820 2873 { $$ = $2->addNewArray( $1 ); } 2821 | '[' ']' multi_array_dimension type_specifier 2874 | '[' ']' multi_array_dimension type_specifier_nobody 2822 2875 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2823 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier 2876 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 2824 2877 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } 2825 | multi_array_dimension type_specifier 2878 | multi_array_dimension type_specifier_nobody 2826 2879 { $$ = $2->addNewArray( $1 ); } 2827 2880
Note:
See TracChangeset
for help on using the changeset viewer.