Changes in src/Parser/parser.yy [67cf18c:fdca7c6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r67cf18c rfdca7c6 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 25 15:21:59201713 // Update Count : 23 9812 // Last Modified On : Thu May 18 18:06:17 2017 13 // Update Count : 2338 14 14 // 15 15 … … 159 159 } 160 160 161 %type<tok> identifier no_ attr_identifierzero_one162 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name161 %type<tok> identifier no_01_identifier no_attr_identifier zero_one 162 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name no_01_identifier_or_type_name attr_name 163 163 %type<constant> string_literal 164 164 %type<str> string_literal_list … … 207 207 %type<en> bit_subrange_size_opt bit_subrange_size 208 208 209 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type209 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name 210 210 211 211 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier … … 261 261 %type<decl> type_declarator type_declarator_name type_declaring_list 262 262 263 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name 264 %type<decl> typedef typedef_declaration typedef_expression 263 %type<decl> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression 265 264 266 265 %type<decl> variable_type_redeclarator type_ptr type_array type_function 267 266 268 267 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function 269 270 %type<decl> type type_no_function 271 %type<decl> type_parameter type_parameter_list type_initializer_opt 272 273 %type<en> type_list 268 %type<decl> typegen_declaration_specifier typegen_type_specifier typegen_name 269 270 %type<decl> type_name type_name_no_function 271 %type<decl> type_parameter type_parameter_list 272 273 %type<en> type_name_list 274 274 275 275 %type<decl> type_qualifier type_qualifier_name type_qualifier_list_opt type_qualifier_list … … 351 351 IDENTIFIER 352 352 | ATTR_IDENTIFIER // CFA 353 | zero_one // CFA 354 ; 355 356 no_01_identifier: 357 IDENTIFIER 358 | ATTR_IDENTIFIER // CFA 353 359 ; 354 360 355 361 no_attr_identifier: 356 362 IDENTIFIER 363 | zero_one // CFA 357 364 ; 358 365 … … 360 367 ZERO 361 368 | ONE 362 369 ; 363 370 364 371 string_literal: … … 388 395 | '(' compound_statement ')' // GCC, lambda expression 389 396 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 390 | primary_expression '{' argument_expression_list '}' // CFA , constructor call397 | primary_expression '{' argument_expression_list '}' // CFA 391 398 { 392 399 Token fn; … … 394 401 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 395 402 } 396 | type_name '.' no_attr_identifier // CFA, nested type397 { $$ = nullptr; } // FIX ME398 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector399 { $$ = nullptr; } // FIX ME400 403 ; 401 404 … … 428 431 | postfix_expression DECR 429 432 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 430 | '(' type_n o_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal433 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 431 434 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 432 435 | '^' primary_expression '{' argument_expression_list '}' // CFA … … 480 483 | no_attr_identifier fraction_constants 481 484 { 482 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );483 }484 | zero_one fraction_constants485 {486 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );485 if( (*$1) == "0" || (*$1) == "1" ) { 486 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) ); 487 } else { 488 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 489 } 487 490 } 488 491 ; … … 532 535 | SIZEOF unary_expression 533 536 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 534 | SIZEOF '(' type_n o_function ')'537 | SIZEOF '(' type_name_no_function ')' 535 538 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 536 539 | ALIGNOF unary_expression // GCC, variable alignment 537 540 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 538 | ALIGNOF '(' type_n o_function ')' // GCC, type alignment541 | ALIGNOF '(' type_name_no_function ')' // GCC, type alignment 539 542 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 540 | OFFSETOF '(' type_n o_function ',' no_attr_identifier ')'543 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 541 544 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 542 545 | ATTR_IDENTIFIER … … 544 547 | ATTR_IDENTIFIER '(' argument_expression ')' 545 548 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 546 | ATTR_IDENTIFIER '(' type ')'549 | ATTR_IDENTIFIER '(' type_name ')' 547 550 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 548 551 // | ANDAND IDENTIFIER // GCC, address of label … … 566 569 cast_expression: 567 570 unary_expression 568 | '(' type_n o_function ')' cast_expression571 | '(' type_name_no_function ')' cast_expression 569 572 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 570 // | '(' type_n o_function ')' tuple573 // | '(' type_name_no_function ')' tuple 571 574 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 572 575 ; … … 655 658 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 656 659 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 660 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 661 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 657 662 ; 658 663 … … 666 671 | unary_expression assignment_operator assignment_expression 667 672 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 673 // | tuple assignment_opt // CFA, tuple expression 674 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); } 668 675 ; 669 676 … … 1345 1352 basic_declaration_specifier 1346 1353 | sue_declaration_specifier 1347 | type_declaration_specifier 1354 | typedef_declaration_specifier 1355 | typegen_declaration_specifier 1348 1356 ; 1349 1357 … … 1356 1364 basic_declaration_specifier 1357 1365 | sue_declaration_specifier_nobody 1358 | type_declaration_specifier 1366 | typedef_declaration_specifier 1367 | typegen_declaration_specifier 1359 1368 ; 1360 1369 … … 1362 1371 basic_type_specifier 1363 1372 | sue_type_specifier 1364 | type_type_specifier 1373 | typedef_type_specifier 1374 | typegen_type_specifier 1365 1375 ; 1366 1376 … … 1373 1383 basic_type_specifier 1374 1384 | sue_type_specifier_nobody 1375 | type_type_specifier 1385 | typedef_type_specifier 1386 | typegen_type_specifier 1376 1387 ; 1377 1388 … … 1508 1519 1509 1520 basic_type_specifier: 1510 direct_type 1511 | type_qualifier_list_opt indirect_type type_qualifier_list_opt1521 direct_type_name 1522 | type_qualifier_list_opt indirect_type_name type_qualifier_list_opt 1512 1523 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 1513 1524 ; 1514 1525 1515 direct_type :1526 direct_type_name: 1516 1527 // A semantic check is necessary for conflicting type qualifiers. 1517 1528 basic_type_name 1518 1529 | type_qualifier_list basic_type_name 1519 1530 { $$ = $2->addQualifiers( $1 ); } 1520 | direct_type type_qualifier1521 { $$ = $1->addQualifiers( $2 ); } 1522 | direct_type basic_type_name1531 | direct_type_name type_qualifier 1532 { $$ = $1->addQualifiers( $2 ); } 1533 | direct_type_name basic_type_name 1523 1534 { $$ = $1->addType( $2 ); } 1524 1535 ; 1525 1536 1526 indirect_type :1527 TYPEOF '(' type ')'// GCC: typeof(x) y;1537 indirect_type_name: 1538 TYPEOF '(' type_name ')' // GCC: typeof(x) y; 1528 1539 { $$ = $3; } 1529 1540 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1530 1541 { $$ = DeclarationNode::newTypeof( $3 ); } 1531 | ATTR_TYPEGENname '(' type ')'// CFA: e.g., @type(x) y;1542 | ATTR_TYPEGENname '(' type_name ')' // CFA: e.g., @type(x) y; 1532 1543 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1533 1544 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; … … 1573 1584 ; 1574 1585 1575 type _declaration_specifier:1576 type _type_specifier1577 | declaration_qualifier_list type _type_specifier1586 typedef_declaration_specifier: 1587 typedef_type_specifier 1588 | declaration_qualifier_list typedef_type_specifier 1578 1589 { $$ = $2->addQualifiers( $1 ); } 1579 | type _declaration_specifier storage_class// remaining OBSOLESCENT (see 2)1580 { $$ = $1->addQualifiers( $2 ); } 1581 | type _declaration_specifier storage_class type_qualifier_list1590 | typedef_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1591 { $$ = $1->addQualifiers( $2 ); } 1592 | typedef_declaration_specifier storage_class type_qualifier_list 1582 1593 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1583 1594 ; 1584 1595 1585 type_type_specifier: // typedef types 1586 type_name 1587 | type_qualifier_list type_name 1588 { $$ = $2->addQualifiers( $1 ); } 1589 | type_type_specifier type_qualifier 1590 { $$ = $1->addQualifiers( $2 ); } 1591 ; 1592 1593 type_name: 1596 typedef_type_specifier: // typedef types 1594 1597 TYPEDEFname 1595 1598 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1596 | '.' TYPEDEFname 1597 { $$ = DeclarationNode::newFromTypedef( $2 ); } // FIX ME 1598 | type_name '.' TYPEDEFname 1599 { $$ = DeclarationNode::newFromTypedef( $3 ); } // FIX ME 1600 | typegen_name 1601 | '.' typegen_name 1602 { $$ = $2; } // FIX ME 1603 | type_name '.' typegen_name 1604 { $$ = $3; } // FIX ME 1605 ; 1606 1607 typegen_name: // CFA 1608 TYPEGENname '(' ')' 1609 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1610 | TYPEGENname '(' type_list ')' 1611 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1599 | type_qualifier_list TYPEDEFname 1600 { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); } 1601 | typedef_type_specifier type_qualifier 1602 { $$ = $1->addQualifiers( $2 ); } 1612 1603 ; 1613 1604 … … 1633 1624 '{' field_declaration_list '}' 1634 1625 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1635 | aggregate_key attribute_list_opt '(' type_ list ')' '{' field_declaration_list '}' // CFA1626 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1636 1627 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1637 1628 | aggregate_type_nobody … … 1639 1630 1640 1631 aggregate_type_nobody: // struct, union - {...} 1641 aggregate_key attribute_list_opt no_attr_identifier 1632 aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1642 1633 { 1643 1634 typedefTable.makeTypedef( *$3 ); 1644 1635 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1645 1636 } 1646 | aggregate_key attribute_list_opt TYPEDEFname 1647 { 1648 typedefTable.makeTypedef( *$3 ); 1649 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1650 } 1651 | aggregate_key attribute_list_opt typegen_name // CFA 1637 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1652 1638 { $$ = $3->addQualifiers( $2 ); } 1653 1639 ; … … 1887 1873 ; 1888 1874 1875 no_01_identifier_or_type_name: 1876 no_01_identifier 1877 | TYPEDEFname 1878 | TYPEGENname 1879 ; 1880 1889 1881 no_attr_identifier_or_type_name: 1890 1882 no_attr_identifier … … 1893 1885 ; 1894 1886 1895 type_n o_function:// sizeof, alignof, cast (constructor)1887 type_name_no_function: // sizeof, alignof, cast (constructor) 1896 1888 cfa_abstract_declarator_tuple // CFA 1897 1889 | type_specifier … … 1900 1892 ; 1901 1893 1902 type :// typeof, assertion1903 type_n o_function1894 type_name: // typeof, assertion 1895 type_name_no_function 1904 1896 | cfa_abstract_function // CFA 1905 1897 ; … … 1941 1933 designation: 1942 1934 designator_list ':' // C99, CFA uses ":" instead of "=" 1943 | no_attr_identifier ':'// GCC, field name1935 | no_attr_identifier_or_type_name ':' // GCC, field name 1944 1936 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1945 1937 ; … … 1953 1945 1954 1946 designator: 1955 '.' no_attr_identifier 1947 '.' no_attr_identifier_or_type_name // C99, field name 1956 1948 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1957 1949 | '[' push assignment_expression pop ']' // C99, single array element … … 1984 1976 // on type arguments of polymorphic functions. 1985 1977 1978 typegen_declaration_specifier: // CFA 1979 typegen_type_specifier 1980 | declaration_qualifier_list typegen_type_specifier 1981 { $$ = $2->addQualifiers( $1 ); } 1982 | typegen_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1983 { $$ = $1->addQualifiers( $2 ); } 1984 | typegen_declaration_specifier storage_class type_qualifier_list 1985 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1986 ; 1987 1988 typegen_type_specifier: // CFA 1989 typegen_name 1990 | type_qualifier_list typegen_name 1991 { $$ = $2->addQualifiers( $1 ); } 1992 | typegen_type_specifier type_qualifier 1993 { $$ = $1->addQualifiers( $2 ); } 1994 ; 1995 1996 typegen_name: // CFA 1997 TYPEGENname '(' type_name_list ')' 1998 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1999 ; 2000 1986 2001 type_parameter_list: // CFA 1987 type_parameter 1988 { $$ = $1; } 1989 | type_parameter_list ',' type_parameter 2002 type_parameter assignment_opt 2003 | type_parameter_list ',' type_parameter assignment_opt 1990 2004 { $$ = $1->appendList( $3 ); } 1991 ;1992 1993 type_initializer_opt: // CFA1994 // empty1995 { $$ = nullptr; }1996 | '=' type1997 { $$ = $2; }1998 2005 ; 1999 2006 … … 2001 2008 type_class no_attr_identifier_or_type_name 2002 2009 { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); } 2003 type_initializer_optassertion_list_opt2004 { $$ = DeclarationNode::newTypeParam( $1, $2 )->add TypeInitializer( $4 )->addAssertions( $5); }2010 assertion_list_opt 2011 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addAssertions( $4 ); } 2005 2012 | type_specifier identifier_parameter_declarator 2006 2013 ; … … 2025 2032 2026 2033 assertion: // CFA 2027 '|' no_attr_identifier_or_type_name '(' type_ list ')'2034 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 2028 2035 { 2029 2036 typedefTable.openTrait( *$2 ); … … 2032 2039 | '|' '{' push trait_declaration_list '}' 2033 2040 { $$ = $4; } 2034 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_ list ')'2041 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')' 2035 2042 { $$ = nullptr; } 2036 2043 ; 2037 2044 2038 type_ list:// CFA2039 type 2045 type_name_list: // CFA 2046 type_name 2040 2047 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 2041 2048 | assignment_expression 2042 | type_ list ',' type2049 | type_name_list ',' type_name 2043 2050 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 2044 | type_ list ',' assignment_expression2051 | type_name_list ',' assignment_expression 2045 2052 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 2046 2053 ; … … 2058 2065 type_declarator_name assertion_list_opt 2059 2066 { $$ = $1->addAssertions( $2 ); } 2060 | type_declarator_name assertion_list_opt '=' type 2067 | type_declarator_name assertion_list_opt '=' type_name 2061 2068 { $$ = $1->addAssertions( $2 )->addType( $4 ); } 2062 2069 ; … … 2068 2075 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2069 2076 } 2070 | no_ attr_identifier_or_type_name '(' push type_parameter_list pop ')'2077 | no_01_identifier_or_type_name '(' push type_parameter_list pop ')' 2071 2078 { 2072 2079 typedefTable.addToEnclosingScope( *$1, TypedefTable::TG ); … … 2094 2101 ; 2095 2102 2096 trait_declaration_list: 2103 trait_declaration_list: // CFA 2097 2104 trait_declaration 2098 2105 | trait_declaration_list push trait_declaration … … 2100 2107 ; 2101 2108 2102 trait_declaration: 2109 trait_declaration: // CFA 2103 2110 cfa_trait_declaring_list pop ';' 2104 2111 | trait_declaring_list pop ';'
Note: See TracChangeset
for help on using the changeset viewer.