Changeset b1e63ac5 for src/Parser/parser.yy
- Timestamp:
- Jul 4, 2017, 9:40:16 AM (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:
- 208e5be
- Parents:
- 9c951e3 (diff), f7cb0bc (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
r9c951e3 rb1e63ac5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // cfa.y --7 // parser.yy -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 30 15:42:32 201713 // Update Count : 2 31812 // Last Modified On : Wed Jun 28 22:11:22 2017 13 // Update Count : 2414 14 14 // 15 15 … … 48 48 #include <cstdio> 49 49 #include <stack> 50 #include "lex.h"51 #include "parser.h"52 50 #include "ParseNode.h" 53 51 #include "TypedefTable.h" … … 85 83 } // for 86 84 } // distExt 85 86 bool forall = false; // aggregate have one or more forall qualifiers ? 87 87 %} 88 89 // Types declaration 90 %union 91 { 92 Token tok; 93 ParseNode * pn; 94 ExpressionNode * en; 95 DeclarationNode * decl; 96 DeclarationNode::Aggregate aggKey; 97 DeclarationNode::TypeClass tclass; 98 StatementNode * sn; 99 ConstantExpr * constant; 100 ForCtl * fctl; 101 LabelNode * label; 102 InitializerNode * in; 103 OperKinds op; 104 std::string * str; 105 bool flag; 106 } 88 107 89 108 //************************* TERMINAL TOKENS ******************************** … … 138 157 %token ATassign // @= 139 158 140 // Types declaration 141 %union 142 { 143 Token tok; 144 ParseNode * pn; 145 ExpressionNode * en; 146 DeclarationNode * decl; 147 DeclarationNode::Aggregate aggKey; 148 DeclarationNode::TypeClass tclass; 149 StatementNode * sn; 150 ConstantExpr * constant; 151 ForCtl * fctl; 152 LabelNode * label; 153 InitializerNode * in; 154 OperKinds op; 155 std::string * str; 156 bool flag; 157 } 158 159 %type<tok> identifier no_01_identifier no_attr_identifier zero_one 160 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name no_01_identifier_or_type_name attr_name 159 %type<tok> identifier no_attr_identifier zero_one 160 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 161 161 %type<constant> string_literal 162 162 %type<str> string_literal_list … … 191 191 %type<sn> case_value_list case_label case_label_list 192 192 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 193 %type<sn> handler_listhandler_clause finally_clause193 %type<sn> /* handler_list */ handler_clause finally_clause 194 194 195 195 // declarations … … 205 205 %type<en> bit_subrange_size_opt bit_subrange_size 206 206 207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type _name indirect_type_name207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type 208 208 209 209 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier … … 259 259 %type<decl> type_declarator type_declarator_name type_declaring_list 260 260 261 %type<decl> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression 261 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name 262 %type<decl> typedef typedef_declaration typedef_expression 262 263 263 264 %type<decl> variable_type_redeclarator type_ptr type_array type_function 264 265 265 266 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function 266 %type<decl> typegen_declaration_specifier typegen_type_specifier typegen_name 267 268 %type<decl> type_name type_name_no_function 269 %type<decl> type_parameter type_parameter_list 270 271 %type<en> type_name_list 267 268 %type<decl> type type_no_function 269 %type<decl> type_parameter type_parameter_list type_initializer_opt 270 271 %type<en> type_list 272 272 273 273 %type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list … … 349 349 IDENTIFIER 350 350 | ATTR_IDENTIFIER // CFA 351 | zero_one // CFA352 ;353 354 no_01_identifier:355 IDENTIFIER356 | ATTR_IDENTIFIER // CFA357 351 ; 358 352 359 353 no_attr_identifier: 360 354 IDENTIFIER 361 | zero_one // CFA362 355 ; 363 356 … … 365 358 ZERO 366 359 | ONE 367 ;360 ; 368 361 369 362 string_literal: … … 393 386 | '(' compound_statement ')' // GCC, lambda expression 394 387 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 395 | primary_expression '{' argument_expression_list '}' // CFA 388 | primary_expression '{' argument_expression_list '}' // CFA, constructor call 396 389 { 397 390 Token fn; … … 399 392 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 400 393 } 394 | type_name '.' no_attr_identifier // CFA, nested type 395 { $$ = nullptr; } // FIX ME 396 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 397 { $$ = nullptr; } // FIX ME 401 398 ; 402 399 … … 429 426 | postfix_expression DECR 430 427 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 431 | '(' type_n ame_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal428 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 432 429 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 433 430 | '^' primary_expression '{' argument_expression_list '}' // CFA … … 481 478 | no_attr_identifier fraction_constants 482 479 { 483 if( (*$1) == "0" || (*$1) == "1" ) {484 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );485 } else {486 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );487 }480 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 481 } 482 | zero_one fraction_constants 483 { 484 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) ); 488 485 } 489 486 ; … … 533 530 | SIZEOF unary_expression 534 531 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 535 | SIZEOF '(' type_n ame_no_function ')'532 | SIZEOF '(' type_no_function ')' 536 533 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 537 534 | ALIGNOF unary_expression // GCC, variable alignment 538 535 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 539 | ALIGNOF '(' type_n ame_no_function ')' // GCC, type alignment536 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 540 537 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 541 | OFFSETOF '(' type_n ame_no_function ',' no_attr_identifier ')'538 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' 542 539 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 543 540 | ATTR_IDENTIFIER … … 545 542 | ATTR_IDENTIFIER '(' argument_expression ')' 546 543 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 547 | ATTR_IDENTIFIER '(' type _name')'544 | ATTR_IDENTIFIER '(' type ')' 548 545 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 549 546 // | ANDAND IDENTIFIER // GCC, address of label 550 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 , true) ); }547 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); } 551 548 ; 552 549 … … 567 564 cast_expression: 568 565 unary_expression 569 | '(' type_n ame_no_function ')' cast_expression566 | '(' type_no_function ')' cast_expression 570 567 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 571 // | '(' type_n ame_no_function ')' tuple568 // | '(' type_no_function ')' tuple 572 569 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 570 ; … … 656 653 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 657 654 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 658 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression659 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }660 655 ; 661 656 … … 669 664 | unary_expression assignment_operator assignment_expression 670 665 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 671 // | tuple assignment_opt // CFA, tuple expression672 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }673 666 ; 674 667 … … 936 929 { $$ = new StatementNode( build_throw( $2 ) ); } 937 930 | THROWRESUME assignment_expression_opt ';' // handles reresume 938 { $$ = new StatementNode( build_ throw( $2 ) ); }931 { $$ = new StatementNode( build_resume( $2 ) ); } 939 932 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 940 { $$ = new StatementNode( build_ throw( $2) ); }933 { $$ = new StatementNode( build_resume_at( $2, $4 ) ); } 941 934 ; 942 935 943 936 exception_statement: 944 TRY compound_statement handler_ list937 TRY compound_statement handler_clause 945 938 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 946 939 | TRY compound_statement finally_clause 947 940 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 948 | TRY compound_statement handler_ listfinally_clause941 | TRY compound_statement handler_clause finally_clause 949 942 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 950 943 ; 951 944 952 handler_list:953 handler_clause954 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.955 | CATCH '(' ELLIPSIS ')' compound_statement956 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }957 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement958 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }959 | CATCHRESUME '(' ELLIPSIS ')' compound_statement960 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }961 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement962 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }963 ;945 //handler_list: 946 // handler_clause 947 // // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block. 948 // | CATCH '(' ELLIPSIS ')' compound_statement 949 // { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 950 // | handler_clause CATCH '(' ELLIPSIS ')' compound_statement 951 // { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 952 // | CATCHRESUME '(' ELLIPSIS ')' compound_statement 953 // { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 954 // | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement 955 // { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 956 // ; 964 957 965 958 handler_clause: 966 CATCH '(' push push exception_declaration pop ')' compound_statement pop 967 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 959 // TEMPORARY, TEST EXCEPTIONS 960 CATCH '(' push push INTEGERconstant pop ')' compound_statement pop 961 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); } 962 | handler_clause CATCH '(' push push INTEGERconstant pop ')' compound_statement pop 963 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 964 965 | CATCH '(' push push exception_declaration pop ')' compound_statement pop 966 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); } 968 967 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 969 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }968 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); } 970 969 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 971 { $$ = new StatementNode( build_catch( $5, $8 ) ); }970 { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); } 972 971 | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 973 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }972 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); } 974 973 ; 975 974 … … 1350 1349 basic_declaration_specifier 1351 1350 | sue_declaration_specifier 1352 | typedef_declaration_specifier 1353 | typegen_declaration_specifier 1351 | type_declaration_specifier 1354 1352 ; 1355 1353 … … 1362 1360 basic_declaration_specifier 1363 1361 | sue_declaration_specifier_nobody 1364 | typedef_declaration_specifier 1365 | typegen_declaration_specifier 1362 | type_declaration_specifier 1366 1363 ; 1367 1364 … … 1369 1366 basic_type_specifier 1370 1367 | sue_type_specifier 1371 | typedef_type_specifier 1372 | typegen_type_specifier 1368 | type_type_specifier 1373 1369 ; 1374 1370 … … 1381 1377 basic_type_specifier 1382 1378 | sue_type_specifier_nobody 1383 | typedef_type_specifier 1384 | typegen_type_specifier 1379 | type_type_specifier 1385 1380 ; 1386 1381 … … 1517 1512 1518 1513 basic_type_specifier: 1519 direct_type _name1520 | type_qualifier_list_opt indirect_type _nametype_qualifier_list_opt1514 direct_type 1515 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1521 1516 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 1522 1517 ; 1523 1518 1524 direct_type _name:1519 direct_type: 1525 1520 // A semantic check is necessary for conflicting type qualifiers. 1526 1521 basic_type_name 1527 1522 | type_qualifier_list basic_type_name 1528 1523 { $$ = $2->addQualifiers( $1 ); } 1529 | direct_type _nametype_qualifier1524 | direct_type type_qualifier 1530 1525 { $$ = $1->addQualifiers( $2 ); } 1531 | direct_type _namebasic_type_name1526 | direct_type basic_type_name 1532 1527 { $$ = $1->addType( $2 ); } 1533 1528 ; 1534 1529 1535 indirect_type _name:1536 TYPEOF '(' type _name ')'// GCC: typeof(x) y;1530 indirect_type: 1531 TYPEOF '(' type ')' // GCC: typeof(x) y; 1537 1532 { $$ = $3; } 1538 1533 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1539 1534 { $$ = DeclarationNode::newTypeof( $3 ); } 1540 | ATTR_TYPEGENname '(' type _name ')'// CFA: e.g., @type(x) y;1535 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1541 1536 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1542 1537 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; … … 1556 1551 sue_type_specifier: // struct, union, enum + type specifier 1557 1552 elaborated_type 1558 | type_qualifier_list elaborated_type 1559 { $$ = $2->addQualifiers( $1 ); } 1553 | type_qualifier_list 1554 { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type 1555 elaborated_type 1556 { $$ = $3->addQualifiers( $1 ); } 1560 1557 | sue_type_specifier type_qualifier 1561 1558 { $$ = $1->addQualifiers( $2 ); } … … 1580 1577 ; 1581 1578 1582 type def_declaration_specifier:1583 type def_type_specifier1584 | declaration_qualifier_list type def_type_specifier1579 type_declaration_specifier: 1580 type_type_specifier 1581 | declaration_qualifier_list type_type_specifier 1585 1582 { $$ = $2->addQualifiers( $1 ); } 1586 | type def_declaration_specifier storage_class// remaining OBSOLESCENT (see 2)1583 | type_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1587 1584 { $$ = $1->addQualifiers( $2 ); } 1588 | type def_declaration_specifier storage_class type_qualifier_list1585 | type_declaration_specifier storage_class type_qualifier_list 1589 1586 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1590 1587 ; 1591 1588 1592 typedef_type_specifier: // typedef types 1589 type_type_specifier: // typedef types 1590 type_name 1591 | type_qualifier_list type_name 1592 { $$ = $2->addQualifiers( $1 ); } 1593 | type_type_specifier type_qualifier 1594 { $$ = $1->addQualifiers( $2 ); } 1595 ; 1596 1597 type_name: 1593 1598 TYPEDEFname 1594 1599 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1595 | type_qualifier_list TYPEDEFname 1596 { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); } 1597 | typedef_type_specifier type_qualifier 1598 { $$ = $1->addQualifiers( $2 ); } 1600 | '.' TYPEDEFname 1601 { $$ = DeclarationNode::newFromTypedef( $2 ); } // FIX ME 1602 | type_name '.' TYPEDEFname 1603 { $$ = DeclarationNode::newFromTypedef( $3 ); } // FIX ME 1604 | typegen_name 1605 | '.' typegen_name 1606 { $$ = $2; } // FIX ME 1607 | type_name '.' typegen_name 1608 { $$ = $3; } // FIX ME 1609 ; 1610 1611 typegen_name: // CFA 1612 TYPEGENname '(' ')' 1613 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1614 | TYPEGENname '(' type_list ')' 1615 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1599 1616 ; 1600 1617 … … 1613 1630 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1614 1631 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1615 { typedefTable.makeTypedef( *$3 ); } 1632 { 1633 typedefTable.makeTypedef( *$3 ); // create typedef 1634 if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update 1635 forall = false; // reset 1636 } 1616 1637 '{' field_declaration_list '}' 1617 1638 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1618 | aggregate_key attribute_list_opt '(' type_ name_list ')' '{' field_declaration_list '}' // CFA1639 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list '}' // CFA 1619 1640 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1620 1641 | aggregate_type_nobody … … 1622 1643 1623 1644 aggregate_type_nobody: // struct, union - {...} 1624 aggregate_key attribute_list_opt no_attr_identifier _or_type_name1645 aggregate_key attribute_list_opt no_attr_identifier 1625 1646 { 1626 1647 typedefTable.makeTypedef( *$3 ); 1627 1648 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1628 1649 } 1629 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1650 | aggregate_key attribute_list_opt TYPEDEFname 1651 { 1652 typedefTable.makeTypedef( *$3 ); 1653 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1654 } 1655 | aggregate_key attribute_list_opt typegen_name // CFA 1630 1656 { $$ = $3->addQualifiers( $2 ); } 1631 1657 ; … … 1865 1891 ; 1866 1892 1867 no_01_identifier_or_type_name:1868 no_01_identifier1869 | TYPEDEFname1870 | TYPEGENname1871 ;1872 1873 1893 no_attr_identifier_or_type_name: 1874 1894 no_attr_identifier … … 1877 1897 ; 1878 1898 1879 type_n ame_no_function:// sizeof, alignof, cast (constructor)1899 type_no_function: // sizeof, alignof, cast (constructor) 1880 1900 cfa_abstract_declarator_tuple // CFA 1881 1901 | type_specifier … … 1884 1904 ; 1885 1905 1886 type _name:// typeof, assertion1887 type_n ame_no_function1906 type: // typeof, assertion 1907 type_no_function 1888 1908 | cfa_abstract_function // CFA 1889 1909 ; … … 1925 1945 designation: 1926 1946 designator_list ':' // C99, CFA uses ":" instead of "=" 1927 | no_attr_identifier _or_type_name ':'// GCC, field name1947 | no_attr_identifier ':' // GCC, field name 1928 1948 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1929 1949 ; … … 1937 1957 1938 1958 designator: 1939 '.' no_attr_identifier _or_type_name// C99, field name1959 '.' no_attr_identifier // C99, field name 1940 1960 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1941 1961 | '[' push assignment_expression pop ']' // C99, single array element … … 1968 1988 // on type arguments of polymorphic functions. 1969 1989 1970 typegen_declaration_specifier: // CFA1971 typegen_type_specifier1972 | declaration_qualifier_list typegen_type_specifier1973 { $$ = $2->addQualifiers( $1 ); }1974 | typegen_declaration_specifier storage_class // remaining OBSOLESCENT (see 2)1975 { $$ = $1->addQualifiers( $2 ); }1976 | typegen_declaration_specifier storage_class type_qualifier_list1977 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }1978 ;1979 1980 typegen_type_specifier: // CFA1981 typegen_name1982 | type_qualifier_list typegen_name1983 { $$ = $2->addQualifiers( $1 ); }1984 | typegen_type_specifier type_qualifier1985 { $$ = $1->addQualifiers( $2 ); }1986 ;1987 1988 typegen_name: // CFA1989 TYPEGENname '(' type_name_list ')'1990 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }1991 ;1992 1993 1990 type_parameter_list: // CFA 1994 type_parameter assignment_opt 1995 | type_parameter_list ',' type_parameter assignment_opt 1991 type_parameter 1992 { $$ = $1; } 1993 | type_parameter_list ',' type_parameter 1996 1994 { $$ = $1->appendList( $3 ); } 1995 ; 1996 1997 type_initializer_opt: // CFA 1998 // empty 1999 { $$ = nullptr; } 2000 | '=' type 2001 { $$ = $2; } 1997 2002 ; 1998 2003 … … 2000 2005 type_class no_attr_identifier_or_type_name 2001 2006 { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); } 2002 assertion_list_opt2003 { $$ = DeclarationNode::newTypeParam( $1, $2 )->add Assertions( $4); }2007 type_initializer_opt assertion_list_opt 2008 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2004 2009 | type_specifier identifier_parameter_declarator 2005 2010 ; … … 2024 2029 2025 2030 assertion: // CFA 2026 '|' no_attr_identifier_or_type_name '(' type_ name_list ')'2031 '|' no_attr_identifier_or_type_name '(' type_list ')' 2027 2032 { 2028 2033 typedefTable.openTrait( *$2 ); … … 2031 2036 | '|' '{' push trait_declaration_list '}' 2032 2037 { $$ = $4; } 2033 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_ name_list ')'2038 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')' 2034 2039 { $$ = nullptr; } 2035 2040 ; 2036 2041 2037 type_ name_list:// CFA2038 type _name2042 type_list: // CFA 2043 type 2039 2044 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 2040 2045 | assignment_expression 2041 | type_ name_list ',' type_name2046 | type_list ',' type 2042 2047 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 2043 | type_ name_list ',' assignment_expression2048 | type_list ',' assignment_expression 2044 2049 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 2045 2050 ; … … 2057 2062 type_declarator_name assertion_list_opt 2058 2063 { $$ = $1->addAssertions( $2 ); } 2059 | type_declarator_name assertion_list_opt '=' type _name2064 | type_declarator_name assertion_list_opt '=' type 2060 2065 { $$ = $1->addAssertions( $2 )->addType( $4 ); } 2061 2066 ; … … 2067 2072 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2068 2073 } 2069 | no_ 01_identifier_or_type_name '(' push type_parameter_list pop ')'2074 | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' 2070 2075 { 2071 2076 typedefTable.addToEnclosingScope( *$1, TypedefTable::TG ); … … 2093 2098 ; 2094 2099 2095 trait_declaration_list: // CFA2100 trait_declaration_list: // CFA 2096 2101 trait_declaration 2097 2102 | trait_declaration_list push trait_declaration … … 2099 2104 ; 2100 2105 2101 trait_declaration: // CFA2106 trait_declaration: // CFA 2102 2107 cfa_trait_declaring_list pop ';' 2103 2108 | trait_declaring_list pop ';'
Note: See TracChangeset
for help on using the changeset viewer.