Changeset 84d58c5
- Timestamp:
- May 25, 2017, 3:32:42 PM (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:
- 7f612112
- Parents:
- a4943d8c
- Location:
- src
- Files:
-
- 5 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
ra4943d8c r84d58c5 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 18 18:06:17201713 // Update Count : 23 3812 // Last Modified On : Thu May 25 15:21:59 2017 13 // Update Count : 2398 14 14 // 15 15 … … 159 159 } 160 160 161 %type<tok> identifier no_ 01_identifier no_attr_identifierzero_one162 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name no_01_identifier_or_type_nameattr_name161 %type<tok> identifier no_attr_identifier zero_one 162 %type<tok> identifier_or_type_name no_attr_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 _name indirect_type_name209 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type 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> typedef typedef_type_specifier typedef_declaration typedef_declaration_specifier typedef_expression 263 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name 264 %type<decl> typedef typedef_declaration typedef_expression 264 265 265 266 %type<decl> variable_type_redeclarator type_ptr type_array type_function 266 267 267 268 %type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function 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 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 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 // CFA354 ;355 356 no_01_identifier:357 IDENTIFIER358 | ATTR_IDENTIFIER // CFA359 353 ; 360 354 361 355 no_attr_identifier: 362 356 IDENTIFIER 363 | zero_one // CFA364 357 ; 365 358 … … 367 360 ZERO 368 361 | ONE 369 ;362 ; 370 363 371 364 string_literal: … … 395 388 | '(' compound_statement ')' // GCC, lambda expression 396 389 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 397 | primary_expression '{' argument_expression_list '}' // CFA 390 | primary_expression '{' argument_expression_list '}' // CFA, constructor call 398 391 { 399 392 Token fn; … … 401 394 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 402 395 } 396 | type_name '.' no_attr_identifier // CFA, nested type 397 { $$ = nullptr; } // FIX ME 398 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 399 { $$ = nullptr; } // FIX ME 403 400 ; 404 401 … … 431 428 | postfix_expression DECR 432 429 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 433 | '(' type_n ame_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal430 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 434 431 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 435 432 | '^' primary_expression '{' argument_expression_list '}' // CFA … … 483 480 | no_attr_identifier fraction_constants 484 481 { 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 }482 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); 483 } 484 | zero_one fraction_constants 485 { 486 $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) ); 490 487 } 491 488 ; … … 535 532 | SIZEOF unary_expression 536 533 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 537 | SIZEOF '(' type_n ame_no_function ')'534 | SIZEOF '(' type_no_function ')' 538 535 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 539 536 | ALIGNOF unary_expression // GCC, variable alignment 540 537 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 541 | ALIGNOF '(' type_n ame_no_function ')' // GCC, type alignment538 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 542 539 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 543 | OFFSETOF '(' type_n ame_no_function ',' no_attr_identifier ')'540 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' 544 541 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 545 542 | ATTR_IDENTIFIER … … 547 544 | ATTR_IDENTIFIER '(' argument_expression ')' 548 545 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 549 | ATTR_IDENTIFIER '(' type _name')'546 | ATTR_IDENTIFIER '(' type ')' 550 547 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 551 548 // | ANDAND IDENTIFIER // GCC, address of label … … 569 566 cast_expression: 570 567 unary_expression 571 | '(' type_n ame_no_function ')' cast_expression568 | '(' type_no_function ')' cast_expression 572 569 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 // | '(' type_n ame_no_function ')' tuple570 // | '(' type_no_function ')' tuple 574 571 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 575 572 ; … … 658 655 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 659 656 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 660 // | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression661 // { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }662 657 ; 663 658 … … 671 666 | unary_expression assignment_operator assignment_expression 672 667 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 673 // | tuple assignment_opt // CFA, tuple expression674 // { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }675 668 ; 676 669 … … 1352 1345 basic_declaration_specifier 1353 1346 | sue_declaration_specifier 1354 | typedef_declaration_specifier 1355 | typegen_declaration_specifier 1347 | type_declaration_specifier 1356 1348 ; 1357 1349 … … 1364 1356 basic_declaration_specifier 1365 1357 | sue_declaration_specifier_nobody 1366 | typedef_declaration_specifier 1367 | typegen_declaration_specifier 1358 | type_declaration_specifier 1368 1359 ; 1369 1360 … … 1371 1362 basic_type_specifier 1372 1363 | sue_type_specifier 1373 | typedef_type_specifier 1374 | typegen_type_specifier 1364 | type_type_specifier 1375 1365 ; 1376 1366 … … 1383 1373 basic_type_specifier 1384 1374 | sue_type_specifier_nobody 1385 | typedef_type_specifier 1386 | typegen_type_specifier 1375 | type_type_specifier 1387 1376 ; 1388 1377 … … 1519 1508 1520 1509 basic_type_specifier: 1521 direct_type _name1522 | type_qualifier_list_opt indirect_type _nametype_qualifier_list_opt1510 direct_type 1511 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1523 1512 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } 1524 1513 ; 1525 1514 1526 direct_type _name:1515 direct_type: 1527 1516 // A semantic check is necessary for conflicting type qualifiers. 1528 1517 basic_type_name 1529 1518 | type_qualifier_list basic_type_name 1530 1519 { $$ = $2->addQualifiers( $1 ); } 1531 | direct_type _nametype_qualifier1520 | direct_type type_qualifier 1532 1521 { $$ = $1->addQualifiers( $2 ); } 1533 | direct_type _namebasic_type_name1522 | direct_type basic_type_name 1534 1523 { $$ = $1->addType( $2 ); } 1535 1524 ; 1536 1525 1537 indirect_type _name:1538 TYPEOF '(' type _name ')'// GCC: typeof(x) y;1526 indirect_type: 1527 TYPEOF '(' type ')' // GCC: typeof(x) y; 1539 1528 { $$ = $3; } 1540 1529 | TYPEOF '(' comma_expression ')' // GCC: typeof(a+b) y; 1541 1530 { $$ = DeclarationNode::newTypeof( $3 ); } 1542 | ATTR_TYPEGENname '(' type _name ')'// CFA: e.g., @type(x) y;1531 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type(x) y; 1543 1532 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1544 1533 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; … … 1584 1573 ; 1585 1574 1586 type def_declaration_specifier:1587 type def_type_specifier1588 | declaration_qualifier_list type def_type_specifier1575 type_declaration_specifier: 1576 type_type_specifier 1577 | declaration_qualifier_list type_type_specifier 1589 1578 { $$ = $2->addQualifiers( $1 ); } 1590 | type def_declaration_specifier storage_class// remaining OBSOLESCENT (see 2)1579 | type_declaration_specifier storage_class // remaining OBSOLESCENT (see 2) 1591 1580 { $$ = $1->addQualifiers( $2 ); } 1592 | type def_declaration_specifier storage_class type_qualifier_list1581 | type_declaration_specifier storage_class type_qualifier_list 1593 1582 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); } 1594 1583 ; 1595 1584 1596 typedef_type_specifier: // typedef types 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: 1597 1594 TYPEDEFname 1598 1595 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1599 | type_qualifier_list TYPEDEFname 1600 { $$ = DeclarationNode::newFromTypedef( $2 )->addQualifiers( $1 ); } 1601 | typedef_type_specifier type_qualifier 1602 { $$ = $1->addQualifiers( $2 ); } 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 '(' type_list ')' 1609 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1603 1610 ; 1604 1611 … … 1624 1631 '{' field_declaration_list '}' 1625 1632 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1626 | aggregate_key attribute_list_opt '(' type_ name_list ')' '{' field_declaration_list '}' // CFA1633 | aggregate_key attribute_list_opt '(' type_list ')' '{' field_declaration_list '}' // CFA 1627 1634 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1628 1635 | aggregate_type_nobody … … 1630 1637 1631 1638 aggregate_type_nobody: // struct, union - {...} 1632 aggregate_key attribute_list_opt no_attr_identifier _or_type_name1639 aggregate_key attribute_list_opt no_attr_identifier 1633 1640 { 1634 1641 typedefTable.makeTypedef( *$3 ); 1635 1642 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1636 1643 } 1637 | aggregate_key attribute_list_opt typegen_name // CFA, S/R conflict 1644 | aggregate_key attribute_list_opt TYPEDEFname 1645 { 1646 typedefTable.makeTypedef( *$3 ); 1647 $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 ); 1648 } 1649 | aggregate_key attribute_list_opt typegen_name // CFA 1638 1650 { $$ = $3->addQualifiers( $2 ); } 1639 1651 ; … … 1873 1885 ; 1874 1886 1875 no_01_identifier_or_type_name:1876 no_01_identifier1877 | TYPEDEFname1878 | TYPEGENname1879 ;1880 1881 1887 no_attr_identifier_or_type_name: 1882 1888 no_attr_identifier … … 1885 1891 ; 1886 1892 1887 type_n ame_no_function:// sizeof, alignof, cast (constructor)1893 type_no_function: // sizeof, alignof, cast (constructor) 1888 1894 cfa_abstract_declarator_tuple // CFA 1889 1895 | type_specifier … … 1892 1898 ; 1893 1899 1894 type _name:// typeof, assertion1895 type_n ame_no_function1900 type: // typeof, assertion 1901 type_no_function 1896 1902 | cfa_abstract_function // CFA 1897 1903 ; … … 1933 1939 designation: 1934 1940 designator_list ':' // C99, CFA uses ":" instead of "=" 1935 | no_attr_identifier _or_type_name ':'// GCC, field name1941 | no_attr_identifier ':' // GCC, field name 1936 1942 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1937 1943 ; … … 1945 1951 1946 1952 designator: 1947 '.' no_attr_identifier _or_type_name// C99, field name1953 '.' no_attr_identifier // C99, field name 1948 1954 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1949 1955 | '[' push assignment_expression pop ']' // C99, single array element … … 1976 1982 // on type arguments of polymorphic functions. 1977 1983 1978 typegen_declaration_specifier: // CFA1979 typegen_type_specifier1980 | declaration_qualifier_list typegen_type_specifier1981 { $$ = $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_list1985 { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }1986 ;1987 1988 typegen_type_specifier: // CFA1989 typegen_name1990 | type_qualifier_list typegen_name1991 { $$ = $2->addQualifiers( $1 ); }1992 | typegen_type_specifier type_qualifier1993 { $$ = $1->addQualifiers( $2 ); }1994 ;1995 1996 typegen_name: // CFA1997 TYPEGENname '(' type_name_list ')'1998 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }1999 ;2000 2001 1984 type_parameter_list: // CFA 2002 type_parameter assignment_opt2003 | type_parameter_list ',' type_parameter assignment_opt1985 type_parameter type_initializer_opt 1986 | type_parameter_list ',' type_parameter type_initializer_opt 2004 1987 { $$ = $1->appendList( $3 ); } 1988 ; 1989 1990 type_initializer_opt: // CFA 1991 // empty 1992 { $$ = nullptr; } 1993 | '=' type 1994 { $$ = $2; } 2005 1995 ; 2006 1996 … … 2032 2022 2033 2023 assertion: // CFA 2034 '|' no_attr_identifier_or_type_name '(' type_ name_list ')'2024 '|' no_attr_identifier_or_type_name '(' type_list ')' 2035 2025 { 2036 2026 typedefTable.openTrait( *$2 ); … … 2039 2029 | '|' '{' push trait_declaration_list '}' 2040 2030 { $$ = $4; } 2041 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_ name_list ')'2031 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')' 2042 2032 { $$ = nullptr; } 2043 2033 ; 2044 2034 2045 type_ name_list:// CFA2046 type _name2035 type_list: // CFA 2036 type 2047 2037 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 2048 2038 | assignment_expression 2049 | type_ name_list ',' type_name2039 | type_list ',' type 2050 2040 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 2051 | type_ name_list ',' assignment_expression2041 | type_list ',' assignment_expression 2052 2042 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 2053 2043 ; … … 2065 2055 type_declarator_name assertion_list_opt 2066 2056 { $$ = $1->addAssertions( $2 ); } 2067 | type_declarator_name assertion_list_opt '=' type _name2057 | type_declarator_name assertion_list_opt '=' type 2068 2058 { $$ = $1->addAssertions( $2 )->addType( $4 ); } 2069 2059 ; … … 2075 2065 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2076 2066 } 2077 | no_ 01_identifier_or_type_name '(' push type_parameter_list pop ')'2067 | no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' 2078 2068 { 2079 2069 typedefTable.addToEnclosingScope( *$1, TypedefTable::TG ); … … 2101 2091 ; 2102 2092 2103 trait_declaration_list: // CFA2093 trait_declaration_list: // CFA 2104 2094 trait_declaration 2105 2095 | trait_declaration_list push trait_declaration … … 2107 2097 ; 2108 2098 2109 trait_declaration: // CFA2099 trait_declaration: // CFA 2110 2100 cfa_trait_declaring_list pop ';' 2111 2101 | trait_declaring_list pop ';'
Note: See TracChangeset
for help on using the changeset viewer.