Changes in src/Parser/parser.yy [9335ecc:ce8c12f]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r9335ecc rce8c12f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // parser.yy --7 // cfa.y -- 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 : Wed Jun 28 22:11:22 201713 // Update Count : 2 41412 // Last Modified On : Thu Mar 30 15:42:32 2017 13 // Update Count : 2318 14 14 // 15 15 … … 48 48 #include <cstdio> 49 49 #include <stack> 50 #include "lex.h" 51 #include "parser.h" 50 52 #include "ParseNode.h" 51 53 #include "TypedefTable.h" … … 83 85 } // for 84 86 } // distExt 85 86 bool forall = false; // aggregate have one or more forall qualifiers ?87 87 %} 88 89 // Types declaration90 %union91 {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 }107 88 108 89 //************************* TERMINAL TOKENS ******************************** … … 157 138 %token ATassign // @= 158 139 159 %type<tok> identifier no_attr_identifier zero_one 160 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 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 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_list */handler_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 indirect_type207 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name 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> type_declaration_specifier type_type_specifier type_name typegen_name 262 %type<decl> typedef typedef_declaration typedef_expression 261 %type<decl> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression 263 262 264 263 %type<decl> variable_type_redeclarator type_ptr type_array type_function 265 264 266 265 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function 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 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 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 // CFA 352 ; 353 354 no_01_identifier: 355 IDENTIFIER 356 | ATTR_IDENTIFIER // CFA 351 357 ; 352 358 353 359 no_attr_identifier: 354 360 IDENTIFIER 361 | zero_one // CFA 355 362 ; 356 363 … … 358 365 ZERO 359 366 | ONE 360 ;367 ; 361 368 362 369 string_literal: … … 386 393 | '(' compound_statement ')' // GCC, lambda expression 387 394 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 388 | primary_expression '{' argument_expression_list '}' // CFA , constructor call395 | primary_expression '{' argument_expression_list '}' // CFA 389 396 { 390 397 Token fn; … … 392 399 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 393 400 } 394 | type_name '.' no_attr_identifier // CFA, nested type395 { $$ = nullptr; } // FIX ME396 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector397 { $$ = nullptr; } // FIX ME398 401 ; 399 402 … … 426 429 | postfix_expression DECR 427 430 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 428 | '(' type_n o_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal431 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 429 432 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 430 433 | '^' primary_expression '{' argument_expression_list '}' // CFA … … 478 481 | no_attr_identifier fraction_constants 479 482 { 480 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );481 }482 | zero_one fraction_constants483 {484 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );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 } 485 488 } 486 489 ; … … 530 533 | SIZEOF unary_expression 531 534 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 532 | SIZEOF '(' type_n o_function ')'535 | SIZEOF '(' type_name_no_function ')' 533 536 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 534 537 | ALIGNOF unary_expression // GCC, variable alignment 535 538 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 536 | ALIGNOF '(' type_n o_function ')' // GCC, type alignment539 | ALIGNOF '(' type_name_no_function ')' // GCC, type alignment 537 540 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 538 | OFFSETOF '(' type_n o_function ',' no_attr_identifier ')'541 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 539 542 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 540 543 | ATTR_IDENTIFIER … … 542 545 | ATTR_IDENTIFIER '(' argument_expression ')' 543 546 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 544 | ATTR_IDENTIFIER '(' type ')'547 | ATTR_IDENTIFIER '(' type_name ')' 545 548 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 546 549 // | ANDAND IDENTIFIER // GCC, address of label 547 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2 ) ); }550 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); } 548 551 ; 549 552 … … 564 567 cast_expression: 565 568 unary_expression 566 | '(' type_n o_function ')' cast_expression569 | '(' type_name_no_function ')' cast_expression 567 570 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 568 // | '(' type_n o_function ')' tuple571 // | '(' type_name_no_function ')' tuple 569 572 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 570 573 ; … … 653 656 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 654 657 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 658 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 659 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 655 660 ; 656 661 … … 664 669 | unary_expression assignment_operator assignment_expression 665 670 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 671 // | tuple assignment_opt // CFA, tuple expression 672 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); } 666 673 ; 667 674 … … 929 936 { $$ = new StatementNode( build_throw( $2 ) ); } 930 937 | THROWRESUME assignment_expression_opt ';' // handles reresume 931 { $$ = new StatementNode( build_ resume( $2 ) ); }938 { $$ = new StatementNode( build_throw( $2 ) ); } 932 939 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 933 { $$ = new StatementNode( build_ resume_at( $2, $4) ); }940 { $$ = new StatementNode( build_throw( $2 ) ); } 934 941 ; 935 942 936 943 exception_statement: 937 TRY compound_statement handler_ clause944 TRY compound_statement handler_list 938 945 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 939 946 | TRY compound_statement finally_clause 940 947 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 941 | TRY compound_statement handler_ clausefinally_clause948 | TRY compound_statement handler_list finally_clause 942 949 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 943 950 ; 944 951 945 //handler_list:946 //handler_clause947 //// 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_statement949 //{ $$ = new StatementNode( build_catch( 0, $5, true ) ); }950 //| handler_clause CATCH '(' ELLIPSIS ')' compound_statement951 //{ $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }952 //| CATCHRESUME '(' ELLIPSIS ')' compound_statement953 //{ $$ = new StatementNode( build_catch( 0, $5, true ) ); }954 //| handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement955 //{ $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }956 //;952 handler_list: 953 handler_clause 954 // 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_statement 956 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 957 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement 958 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 959 | CATCHRESUME '(' ELLIPSIS ')' compound_statement 960 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 961 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement 962 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 963 ; 957 964 958 965 handler_clause: 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 ) ); } 966 CATCH '(' push push exception_declaration pop ')' compound_statement pop 967 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 967 968 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 968 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); }969 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 969 970 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 970 { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); }971 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 971 972 | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 972 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); }973 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 973 974 ; 974 975 … … 1349 1350 basic_declaration_specifier 1350 1351 | sue_declaration_specifier 1351 | type_declaration_specifier 1352 | typedef_declaration_specifier 1353 | typegen_declaration_specifier 1352 1354 ; 1353 1355 … … 1360 1362 basic_declaration_specifier 1361 1363 | sue_declaration_specifier_nobody 1362 | type_declaration_specifier 1364 | typedef_declaration_specifier 1365 | typegen_declaration_specifier 1363 1366 ; 1364 1367 … … 1366 1369 basic_type_specifier 1367 1370 | sue_type_specifier 1368 | type_type_specifier 1371 | typedef_type_specifier 1372 | typegen_type_specifier 1369 1373 ; 1370 1374 … … 1377 1381 basic_type_specifier 1378 1382 | sue_type_specifier_nobody 1379 | type_type_specifier 1383 | typedef_type_specifier 1384 | typegen_type_specifier 1380 1385 ; 1381 1386 … … 1512 1517 1513 1518 basic_type_specifier: 1514 direct_type 1515 | type_qualifier_list_opt indirect_type type_qualifier_list_opt1519 direct_type_name 1520 | type_qualifier_list_opt indirect_type_name type_qualifier_list_opt 1516 1521 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 1517 1522 ; 1518 1523 1519 direct_type :1524 direct_type_name: 1520 1525 // A semantic check is necessary for conflicting type qualifiers. 1521 1526 basic_type_name 1522 1527 | type_qualifier_list basic_type_name 1523 1528 { $$ = $2->addQualifiers( $1 ); } 1524 | direct_type type_qualifier1525 { $$ = $1->addQualifiers( $2 ); } 1526 | direct_type basic_type_name1529 | direct_type_name type_qualifier 1530 { $$ = $1->addQualifiers( $2 ); } 1531 | direct_type_name basic_type_name 1527 1532 { $$ = $1->addType( $2 ); } 1528 1533 ; 1529 1534 1530 indirect_type :1531 TYPEOF '(' type ')'// GCC: typeof(x) y;1535 indirect_type_name: 1536 TYPEOF '(' type_name ')' // GCC: typeof(x) y; 1532 1537 { $$ = $3; } 1533 1538 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1534 1539 { $$ = DeclarationNode::newTypeof( $3 ); } 1535 | ATTR_TYPEGENname '(' type ')'// CFA: e.g., @type(x) y;1540 | ATTR_TYPEGENname '(' type_name ')' // CFA: e.g., @type(x) y; 1536 1541 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1537 1542 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; … … 1551 1556 sue_type_specifier: // struct, union, enum + type specifier 1552 1557 elaborated_type 1553 | type_qualifier_list 1554 { if ( $1->type != nullptr && $1->type->forall ) forall = true; } // remember generic type 1555 elaborated_type 1556 { $$ = $3->addQualifiers( $1 ); } 1558 | type_qualifier_list elaborated_type 1559 { $$ = $2->addQualifiers( $1 ); } 1557 1560 | sue_type_specifier type_qualifier 1558 1561 { $$ = $1->addQualifiers( $2 ); } … … 1577 1580 ; 1578 1581 1579 type _declaration_specifier:1580 type _type_specifier1581 | declaration_qualifier_list type _type_specifier1582 typedef_declaration_specifier: 1583 typedef_type_specifier 1584 | declaration_qualifier_list typedef_type_specifier 1582 1585 { $$ = $2->addQualifiers( $1 ); } 1583 | type _declaration_specifier storage_class// remaining OBSOLESCENT (see 2)1584 { $$ = $1->addQualifiers( $2 ); } 1585 | type _declaration_specifier storage_class type_qualifier_list1586 | typedef_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1587 { $$ = $1->addQualifiers( $2 ); } 1588 | typedef_declaration_specifier storage_class type_qualifier_list 1586 1589 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1587 1590 ; 1588 1591 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: 1592 typedef_type_specifier: // typedef types 1598 1593 TYPEDEFname 1599 1594 { $$ = DeclarationNode::newFromTypedef( $1 ); } 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 ); } 1595 | type_qualifier_list TYPEDEFname 1596 { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); } 1597 | typedef_type_specifier type_qualifier 1598 { $$ = $1->addQualifiers( $2 ); } 1616 1599 ; 1617 1600 … … 1630 1613 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1631 1614 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1632 { 1633 typedefTable.makeTypedef( *$3 ); // create typedef 1634 if ( forall ) typedefTable.changeKind( *$3, TypedefTable::TG ); // possibly update 1635 forall = false; // reset 1636 } 1615 { typedefTable.makeTypedef( *$3 ); } 1637 1616 '{' field_declaration_list '}' 1638 1617 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1639 | aggregate_key attribute_list_opt '(' type_ list ')' '{' field_declaration_list '}' // CFA1618 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1640 1619 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1641 1620 | aggregate_type_nobody … … 1643 1622 1644 1623 aggregate_type_nobody: // struct, union - {...} 1645 aggregate_key attribute_list_opt no_attr_identifier 1624 aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1646 1625 { 1647 1626 typedefTable.makeTypedef( *$3 ); 1648 1627 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1649 1628 } 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 1629 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1656 1630 { $$ = $3->addQualifiers( $2 ); } 1657 1631 ; … … 1891 1865 ; 1892 1866 1867 no_01_identifier_or_type_name: 1868 no_01_identifier 1869 | TYPEDEFname 1870 | TYPEGENname 1871 ; 1872 1893 1873 no_attr_identifier_or_type_name: 1894 1874 no_attr_identifier … … 1897 1877 ; 1898 1878 1899 type_n o_function:// sizeof, alignof, cast (constructor)1879 type_name_no_function: // sizeof, alignof, cast (constructor) 1900 1880 cfa_abstract_declarator_tuple // CFA 1901 1881 | type_specifier … … 1904 1884 ; 1905 1885 1906 type :// typeof, assertion1907 type_n o_function1886 type_name: // typeof, assertion 1887 type_name_no_function 1908 1888 | cfa_abstract_function // CFA 1909 1889 ; … … 1945 1925 designation: 1946 1926 designator_list ':' // C99, CFA uses ":" instead of "=" 1947 | no_attr_identifier ':'// GCC, field name1927 | no_attr_identifier_or_type_name ':' // GCC, field name 1948 1928 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1949 1929 ; … … 1957 1937 1958 1938 designator: 1959 '.' no_attr_identifier // C99, field name1939 '.' no_attr_identifier_or_type_name // C99, field name 1960 1940 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1961 1941 | '[' push assignment_expression pop ']' // C99, single array element … … 1988 1968 // on type arguments of polymorphic functions. 1989 1969 1970 typegen_declaration_specifier: // CFA 1971 typegen_type_specifier 1972 | declaration_qualifier_list typegen_type_specifier 1973 { $$ = $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_list 1977 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1978 ; 1979 1980 typegen_type_specifier: // CFA 1981 typegen_name 1982 | type_qualifier_list typegen_name 1983 { $$ = $2->addQualifiers( $1 ); } 1984 | typegen_type_specifier type_qualifier 1985 { $$ = $1->addQualifiers( $2 ); } 1986 ; 1987 1988 typegen_name: // CFA 1989 TYPEGENname '(' type_name_list ')' 1990 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1991 ; 1992 1990 1993 type_parameter_list: // CFA 1991 type_parameter 1992 { $$ = $1; } 1993 | type_parameter_list ',' type_parameter 1994 type_parameter assignment_opt 1995 | type_parameter_list ',' type_parameter assignment_opt 1994 1996 { $$ = $1->appendList( $3 ); } 1995 ;1996 1997 type_initializer_opt: // CFA1998 // empty1999 { $$ = nullptr; }2000 | '=' type2001 { $$ = $2; }2002 1997 ; 2003 1998 … … 2005 2000 type_class no_attr_identifier_or_type_name 2006 2001 { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); } 2007 type_initializer_optassertion_list_opt2008 { $$ = DeclarationNode::newTypeParam( $1, $2 )->add TypeInitializer( $4 )->addAssertions( $5); }2002 assertion_list_opt 2003 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); } 2009 2004 | type_specifier identifier_parameter_declarator 2010 2005 ; … … 2029 2024 2030 2025 assertion: // CFA 2031 '|' no_attr_identifier_or_type_name '(' type_ list ')'2026 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 2032 2027 { 2033 2028 typedefTable.openTrait( *$2 ); … … 2036 2031 | '|' '{' push trait_declaration_list '}' 2037 2032 { $$ = $4; } 2038 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_ list ')'2033 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')' 2039 2034 { $$ = nullptr; } 2040 2035 ; 2041 2036 2042 type_ list:// CFA2043 type 2037 type_name_list: // CFA 2038 type_name 2044 2039 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 2045 2040 | assignment_expression 2046 | type_ list ',' type2041 | type_name_list ',' type_name 2047 2042 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 2048 | type_ list ',' assignment_expression2043 | type_name_list ',' assignment_expression 2049 2044 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 2050 2045 ; … … 2062 2057 type_declarator_name assertion_list_opt 2063 2058 { $$ = $1->addAssertions( $2 ); } 2064 | type_declarator_name assertion_list_opt '=' type 2059 | type_declarator_name assertion_list_opt '=' type_name 2065 2060 { $$ = $1->addAssertions( $2 )->addType( $4 ); } 2066 2061 ; … … 2072 2067 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2073 2068 } 2074 | no_ attr_identifier_or_type_name '(' push type_parameter_list pop ')'2069 | no_01_identifier_or_type_name '(' push type_parameter_list pop ')' 2075 2070 { 2076 2071 typedefTable.addToEnclosingScope( *$1, TypedefTable::TG ); … … 2098 2093 ; 2099 2094 2100 trait_declaration_list: // CFA2095 trait_declaration_list: // CFA 2101 2096 trait_declaration 2102 2097 | trait_declaration_list push trait_declaration … … 2104 2099 ; 2105 2100 2106 trait_declaration: // CFA2101 trait_declaration: // CFA 2107 2102 cfa_trait_declaring_list pop ';' 2108 2103 | trait_declaring_list pop ';' … … 2382 2377 variable_ptr: 2383 2378 ptrref_operator variable_declarator 2384 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2379 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2385 2380 | ptrref_operator type_qualifier_list variable_declarator 2386 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2381 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2387 2382 | '(' variable_ptr ')' attribute_list_opt 2388 2383 { $$ = $2->addQualifiers( $4 ); } // redundant parenthesis … … 2430 2425 function_ptr: 2431 2426 ptrref_operator function_declarator 2432 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2427 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2433 2428 | ptrref_operator type_qualifier_list function_declarator 2434 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2429 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2435 2430 | '(' function_ptr ')' 2436 2431 { $$ = $2; } … … 2470 2465 KR_function_ptr: 2471 2466 ptrref_operator KR_function_declarator 2472 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2467 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2473 2468 | ptrref_operator type_qualifier_list KR_function_declarator 2474 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2469 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2475 2470 | '(' KR_function_ptr ')' 2476 2471 { $$ = $2; } … … 2514 2509 type_ptr: 2515 2510 ptrref_operator variable_type_redeclarator 2516 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2511 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2517 2512 | ptrref_operator type_qualifier_list variable_type_redeclarator 2518 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2513 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2519 2514 | '(' type_ptr ')' attribute_list_opt 2520 2515 { $$ = $2->addQualifiers( $4 ); } … … 2558 2553 identifier_parameter_ptr: 2559 2554 ptrref_operator identifier_parameter_declarator 2560 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2555 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2561 2556 | ptrref_operator type_qualifier_list identifier_parameter_declarator 2562 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2557 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2563 2558 | '(' identifier_parameter_ptr ')' attribute_list_opt 2564 2559 { $$ = $2->addQualifiers( $4 ); } … … 2618 2613 type_parameter_ptr: 2619 2614 ptrref_operator type_parameter_redeclarator 2620 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2615 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2621 2616 | ptrref_operator type_qualifier_list type_parameter_redeclarator 2622 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2617 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2623 2618 | '(' type_parameter_ptr ')' attribute_list_opt 2624 2619 { $$ = $2->addQualifiers( $4 ); } … … 2661 2656 abstract_ptr: 2662 2657 ptrref_operator 2663 { $$ = DeclarationNode::newPointer( 0 ); }2658 { $$ = DeclarationNode::newPointer( 0, $1 ); } 2664 2659 | ptrref_operator type_qualifier_list 2665 { $$ = DeclarationNode::newPointer( $2 ); }2660 { $$ = DeclarationNode::newPointer( $2, $1 ); } 2666 2661 | ptrref_operator abstract_declarator 2667 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2662 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2668 2663 | ptrref_operator type_qualifier_list abstract_declarator 2669 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2664 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2670 2665 | '(' abstract_ptr ')' attribute_list_opt 2671 2666 { $$ = $2->addQualifiers( $4 ); } … … 2750 2745 abstract_parameter_ptr: 2751 2746 ptrref_operator 2752 { $$ = DeclarationNode::newPointer( nullptr ); }2747 { $$ = DeclarationNode::newPointer( nullptr, $1 ); } 2753 2748 | ptrref_operator type_qualifier_list 2754 { $$ = DeclarationNode::newPointer( $2 ); }2749 { $$ = DeclarationNode::newPointer( $2, $1 ); } 2755 2750 | ptrref_operator abstract_parameter_declarator 2756 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr ) ); }2751 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); } 2757 2752 | ptrref_operator type_qualifier_list abstract_parameter_declarator 2758 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2753 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2759 2754 | '(' abstract_parameter_ptr ')' attribute_list_opt 2760 2755 { $$ = $2->addQualifiers( $4 ); } … … 2829 2824 variable_abstract_ptr: 2830 2825 ptrref_operator 2831 { $$ = DeclarationNode::newPointer( 0 ); }2826 { $$ = DeclarationNode::newPointer( 0, $1 ); } 2832 2827 | ptrref_operator type_qualifier_list 2833 { $$ = DeclarationNode::newPointer( $2 ); }2828 { $$ = DeclarationNode::newPointer( $2, $1 ); } 2834 2829 | ptrref_operator variable_abstract_declarator 2835 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }2830 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2836 2831 | ptrref_operator type_qualifier_list variable_abstract_declarator 2837 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }2832 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2838 2833 | '(' variable_abstract_ptr ')' attribute_list_opt 2839 2834 { $$ = $2->addQualifiers( $4 ); } … … 2875 2870 // No SUE declaration in parameter list. 2876 2871 ptrref_operator type_specifier_nobody 2877 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2872 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2878 2873 | type_qualifier_list ptrref_operator type_specifier_nobody 2879 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2874 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2880 2875 | ptrref_operator cfa_abstract_function 2881 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2876 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2882 2877 | type_qualifier_list ptrref_operator cfa_abstract_function 2883 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2878 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2884 2879 | ptrref_operator cfa_identifier_parameter_declarator_tuple 2885 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2880 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2886 2881 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 2887 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2882 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2888 2883 ; 2889 2884 … … 2963 2958 cfa_abstract_ptr: // CFA 2964 2959 ptrref_operator type_specifier 2965 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2960 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2966 2961 | type_qualifier_list ptrref_operator type_specifier 2967 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2962 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2968 2963 | ptrref_operator cfa_abstract_function 2969 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2964 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2970 2965 | type_qualifier_list ptrref_operator cfa_abstract_function 2971 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2966 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2972 2967 | ptrref_operator cfa_abstract_declarator_tuple 2973 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }2968 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 2974 2969 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 2975 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }2970 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 2976 2971 ; 2977 2972
Note:
See TracChangeset
for help on using the changeset viewer.