Changes in src/Parser/parser.yy [dd020c0:e7cc8cb]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rdd020c0 re7cc8cb 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 3 21:35:28201713 // Update Count : 2 22212 // Last Modified On : Thu Feb 16 15:56:33 2017 13 // Update Count : 2186 14 14 // 15 15 … … 196 196 197 197 %type<aggKey> aggregate_key 198 %type<decl> aggregate_type aggregate_type_nobody198 %type<decl> aggregate_type 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 ion_specifier_nobody declarator declaring_list210 211 %type<decl> elaborated_type elaborated_type_nobody212 213 %type<decl> enumerator_list enum_type enum_type_nobody209 %type<decl> declaration_specifier declarator declaring_list 210 211 %type<decl> elaborated_type 212 213 %type<decl> enumerator_list enum_type 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_ declaration_specifier_nobody sue_type_specifier sue_type_specifier_nobody253 %type<decl> sue_declaration_specifier sue_type_specifier 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 type_specifier_nobody270 %type<decl> type_qualifier type_qualifier_name type_qualifier_list type_qualifier_list_opt type_specifier 271 271 272 272 %type<decl> variable_declarator variable_ptr variable_array variable_function … … 973 973 974 974 exception_declaration: 975 // No SUE declaration in parameter list. 976 type_specifier_nobody 977 | type_specifier_nobody declarator 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 978 982 { 979 983 typedefTable.addToEnclosingScope( TypedefTable::ID ); 980 984 $$ = $2->addType( $1 ); 981 985 } 982 | type_specifier _nobodyvariable_abstract_declarator986 | type_specifier variable_abstract_declarator 983 987 { $$ = $2->addType( $1 ); } 984 988 | cfa_abstract_declarator_tuple no_attr_identifier // CFA … … 1345 1349 ; 1346 1350 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 1351 type_specifier: // declaration specifier - storage class 1360 1352 basic_type_specifier 1361 1353 | sue_type_specifier 1362 | typedef_type_specifier1363 | typegen_type_specifier1364 ;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_specifier1373 | sue_type_specifier_nobody1374 1354 | typedef_type_specifier 1375 1355 | typegen_type_specifier … … 1400 1380 type_qualifier_name: 1401 1381 CONST 1402 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Const ); }1382 { $$ = DeclarationNode::newQualifier( DeclarationNode::Const ); } 1403 1383 | RESTRICT 1404 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Restrict ); }1384 { $$ = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 1405 1385 | VOLATILE 1406 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Volatile ); }1386 { $$ = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 1407 1387 | LVALUE // CFA 1408 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Lvalue ); }1388 { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 1409 1389 | ATOMIC 1410 { $$ = DeclarationNode::new TypeQualifier( DeclarationNode::Atomic ); }1390 { $$ = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 1411 1391 | FORALL '(' 1412 1392 { … … 1448 1428 | REGISTER 1449 1429 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 1430 | INLINE // C99 1431 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); } 1432 { $$ = new DeclarationNode; $$->isInline = true; } 1433 | FORTRAN // C99 1434 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 1435 | NORETURN // C11 1436 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Noreturn ); } 1437 { $$ = new DeclarationNode; $$->isNoreturn = true; } 1450 1438 | THREADLOCAL // C11 1451 1439 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 1452 // Put function specifiers here to simplify parsing rules, but separate them semantically.1453 | INLINE // C991454 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }1455 | FORTRAN // C991456 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }1457 | NORETURN // C111458 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }1459 1440 ; 1460 1441 … … 1533 1514 ; 1534 1515 1535 sue_declaration_specifier: // struct, union, enum + storage class + type specifier1516 sue_declaration_specifier: 1536 1517 sue_type_specifier 1537 1518 | declaration_qualifier_list sue_type_specifier … … 1543 1524 ; 1544 1525 1545 sue_type_specifier: // struct, union, enum + type specifier1546 elaborated_type 1526 sue_type_specifier: 1527 elaborated_type // struct, union, enum 1547 1528 | type_qualifier_list elaborated_type 1548 1529 { $$ = $2->addQualifiers( $1 ); } 1549 1530 | sue_type_specifier type_qualifier 1550 { $$ = $1->addQualifiers( $2 ); }1551 ;1552 1553 sue_declaration_specifier_nobody: // struct, union, enum - {...} + storage class + type specifier1554 sue_type_specifier_nobody1555 | declaration_qualifier_list sue_type_specifier_nobody1556 { $$ = $2->addQualifiers( $1 ); }1557 | sue_declaration_specifier_nobody storage_class // remaining OBSOLESCENT (see 2)1558 { $$ = $1->addQualifiers( $2 ); }1559 | sue_declaration_specifier_nobody storage_class type_qualifier_list1560 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }1561 ;1562 1563 sue_type_specifier_nobody: // struct, union, enum - {...} + type specifier1564 elaborated_type_nobody1565 | type_qualifier_list elaborated_type_nobody1566 { $$ = $2->addQualifiers( $1 ); }1567 | sue_type_specifier_nobody type_qualifier1568 1531 { $$ = $1->addQualifiers( $2 ); } 1569 1532 ; … … 1588 1551 ; 1589 1552 1590 elaborated_type: // struct, union, enum1553 elaborated_type: 1591 1554 aggregate_type 1592 1555 | enum_type 1593 1556 ; 1594 1557 1595 elaborated_type_nobody: // struct, union, enum - {...} 1596 aggregate_type_nobody 1597 | enum_type_nobody 1598 ; 1599 1600 aggregate_type: // struct, union 1558 aggregate_type: 1601 1559 aggregate_key attribute_list_opt '{' field_declaration_list '}' 1602 1560 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $4, true )->addQualifiers( $2 ); } 1561 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1562 { 1563 typedefTable.makeTypedef( *$3 ); 1564 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1565 } 1603 1566 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1604 1567 { typedefTable.makeTypedef( *$3 ); } … … 1607 1570 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1608 1571 { $$ = DeclarationNode::newAggregate( $1, nullptr, $4, $7, false )->addQualifiers( $2 ); } 1609 | aggregate_type_nobody1610 ;1611 1612 aggregate_type_nobody: // struct, union - {...}1613 aggregate_key attribute_list_opt no_attr_identifier_or_type_name1614 {1615 typedefTable.makeTypedef( *$3 );1616 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );1617 }1618 1572 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1619 1573 { $$ = $3->addQualifiers( $2 ); } … … 1693 1647 ; 1694 1648 1695 enum_type: // enum1649 enum_type: 1696 1650 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 1697 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 1651 { $$ = DeclarationNode::newEnum( nullptr, $4 )->addQualifiers( $2 ); } 1652 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1653 { 1654 typedefTable.makeTypedef( *$3 ); 1655 $$ = DeclarationNode::newEnum( $3, 0 )->addQualifiers( $2 ); 1656 } 1698 1657 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1699 1658 { typedefTable.makeTypedef( *$3 ); } 1700 1659 '{' enumerator_list comma_opt '}' 1701 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); } 1702 | enum_type_nobody 1703 ; 1704 1705 enum_type_nobody: // enum - {...} 1706 ENUM attribute_list_opt no_attr_identifier_or_type_name 1707 { 1708 typedefTable.makeTypedef( *$3 ); 1709 $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); 1710 } 1660 { $$ = DeclarationNode::newEnum( $3, $6 )->addQualifiers( $2 ); } 1711 1661 ; 1712 1662 … … 1809 1759 1810 1760 parameter_declaration: 1811 // No SUE declaration in parameter list. 1812 declaration_specifier_nobody identifier_parameter_declarator assignment_opt 1761 declaration_specifier identifier_parameter_declarator assignment_opt 1813 1762 { 1814 1763 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1815 1764 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1816 1765 } 1817 | declaration_specifier _nobodytype_parameter_redeclarator assignment_opt1766 | declaration_specifier type_parameter_redeclarator assignment_opt 1818 1767 { 1819 1768 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1823 1772 1824 1773 abstract_parameter_declaration: 1825 declaration_specifier _nobodyassignment_opt1774 declaration_specifier assignment_opt 1826 1775 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1827 | declaration_specifier _nobodyabstract_parameter_declarator assignment_opt1776 | declaration_specifier abstract_parameter_declarator assignment_opt 1828 1777 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1829 1778 ; … … 2849 2798 2850 2799 cfa_identifier_parameter_ptr: // CFA 2851 // No SUE declaration in parameter list. 2852 ptrref_operator type_specifier_nobody 2800 ptrref_operator type_specifier 2853 2801 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 2854 | type_qualifier_list ptrref_operator type_specifier _nobody2802 | type_qualifier_list ptrref_operator type_specifier 2855 2803 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); } 2856 2804 | ptrref_operator cfa_abstract_function … … 2867 2815 // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to 2868 2816 // shift/reduce conflict with new-style empty (void) function return type. 2869 '[' ']' type_specifier _nobody2817 '[' ']' type_specifier 2870 2818 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2871 | cfa_array_parameter_1st_dimension type_specifier _nobody2819 | cfa_array_parameter_1st_dimension type_specifier 2872 2820 { $$ = $2->addNewArray( $1 ); } 2873 | '[' ']' multi_array_dimension type_specifier _nobody2821 | '[' ']' multi_array_dimension type_specifier 2874 2822 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2875 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier _nobody2823 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier 2876 2824 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } 2877 | multi_array_dimension type_specifier _nobody2825 | multi_array_dimension type_specifier 2878 2826 { $$ = $2->addNewArray( $1 ); } 2879 2827
Note:
See TracChangeset
for help on using the changeset viewer.