Changeset 0f9e4403 for src/Parser/parser.yy
- Timestamp:
- Apr 15, 2016, 12:03:11 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 29ad0ac
- Parents:
- c5833e8 (diff), 37f0da8 (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
-
src/Parser/parser.yy (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rc5833e8 r0f9e4403 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 1 18:22:42201613 // Update Count : 1 48312 // Last Modified On : Wed Apr 13 16:58:43 2016 13 // Update Count : 1519 14 14 // 15 15 … … 51 51 #include <cstdio> 52 52 #include <stack> 53 #include "lex.h" 54 #include "parser.h" 55 #include "ParseNode.h" 53 56 #include "TypedefTable.h" 54 #include "lex.h"55 #include "ParseNode.h"56 57 #include "TypeData.h" 57 58 #include "LinkageSpec.h" … … 74 75 %token FORALL LVALUE // CFA 75 76 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 77 %token VALIST // GCC 76 78 %token BOOL COMPLEX IMAGINARY // C99 77 79 %token TYPEOF LABEL // GCC 78 80 %token ENUM STRUCT UNION 79 %token TYPE FTYPE DTYPE CONTEXT// CFA81 %token OTYPE FTYPE DTYPE TRAIT // CFA 80 82 %token SIZEOF OFFSETOF 81 83 %token ATTRIBUTE EXTENSION // GCC … … 171 173 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name 172 174 173 %type<decl> context_declaration context_declaration_list context_declaring_list context_specifier175 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier 174 176 175 177 %type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list … … 197 199 %type<decl> new_array_parameter_1st_dimension 198 200 199 %type<decl> new_ context_declaring_list new_declaration new_field_declaring_list201 %type<decl> new_trait_declaring_list new_declaration new_field_declaring_list 200 202 %type<decl> new_function_declaration new_function_return new_function_specifier 201 203 … … 370 372 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); } 371 373 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99 372 { $$ = 0; }374 { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); } 373 375 | postfix_expression '{' argument_expression_list '}' // CFA 374 376 { … … 448 450 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); } 449 451 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 450 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }452 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); } 451 453 | ATTR_IDENTIFIER 452 454 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); } … … 1020 1022 | new_function_declaration pop ';' 1021 1023 | type_declaring_list pop ';' 1022 | context_specifier pop ';'1024 | trait_specifier pop ';' 1023 1025 ; 1024 1026 … … 1027 1029 { 1028 1030 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1029 $$ = $1 ;1031 $$ = $1->addInitializer( $2 ); 1030 1032 } 1031 1033 | declaration_qualifier_list new_variable_specifier initializer_opt … … 1034 1036 { 1035 1037 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1036 $$ = $2->addQualifiers( $1 ) ;1038 $$ = $2->addQualifiers( $1 )->addInitializer( $3 );; 1037 1039 } 1038 1040 | new_variable_declaration pop ',' push identifier_or_type_name initializer_opt 1039 1041 { 1040 1042 typedefTable.addToEnclosingScope( *$5, TypedefTable::ID ); 1041 $$ = $1->appendList( $1->cloneType( $5 ) );1043 $$ = $1->appendList( $1->cloneType( $5 )->addInitializer( $6 ) ); 1042 1044 } 1043 1045 ; … … 1345 1347 | IMAGINARY // C99 1346 1348 { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); } 1349 | VALIST // GCC, __builtin_va_list 1350 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1347 1351 ; 1348 1352 … … 1434 1438 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3 ); } 1435 1439 | aggregate_key no_attr_identifier_or_type_name 1436 { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0 ); } 1437 | aggregate_key no_attr_identifier_or_type_name '{' field_declaration_list '}' 1438 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $4 ); } 1440 { 1441 typedefTable.makeTypedef( *$2 ); 1442 $$ = DeclarationNode::newAggregate( $1, $2, 0, 0 ); 1443 } 1444 | aggregate_key no_attr_identifier_or_type_name 1445 { typedefTable.makeTypedef( *$2 ); } 1446 '{' field_declaration_list '}' 1447 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5); } 1439 1448 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1440 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }1449 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); } 1441 1450 | aggregate_key typegen_name // CFA, S/R conflict 1442 1451 { $$ = $2; } … … 1516 1525 enum_key '{' enumerator_list comma_opt '}' 1517 1526 { $$ = DeclarationNode::newEnum( 0, $3 ); } 1518 | enum_key no_attr_identifier_or_type_name '{' enumerator_list comma_opt '}'1519 { $$ = DeclarationNode::newEnum( $2, $4 ); }1520 1527 | enum_key no_attr_identifier_or_type_name 1521 { $$ = DeclarationNode::newEnum( $2, 0 ); } 1528 { 1529 typedefTable.makeTypedef( *$2 ); 1530 $$ = DeclarationNode::newEnum( $2, 0 ); 1531 } 1532 | enum_key no_attr_identifier_or_type_name 1533 { typedefTable.makeTypedef( *$2 ); } 1534 '{' enumerator_list comma_opt '}' 1535 { $$ = DeclarationNode::newEnum( $2, $5 ); } 1522 1536 ; 1523 1537 … … 1803 1817 1804 1818 type_class: // CFA 1805 TYPE1819 OTYPE 1806 1820 { $$ = DeclarationNode::Type; } 1807 1821 | DTYPE … … 1821 1835 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 1822 1836 { 1823 typedefTable.open Context( *$2 );1824 $$ = DeclarationNode::new ContextUse( $2, $4 );1825 } 1826 | '|' '{' push context_declaration_list '}'1837 typedefTable.openTrait( *$2 ); 1838 $$ = DeclarationNode::newTraitUse( $2, $4 ); 1839 } 1840 | '|' '{' push trait_declaration_list '}' 1827 1841 { $$ = $4; } 1828 | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')'1842 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')' 1829 1843 { $$ = 0; } 1830 1844 ; … … 1841 1855 1842 1856 type_declaring_list: // CFA 1843 TYPE type_declarator1844 { $$ = $2; } 1845 | storage_class_list TYPE type_declarator1857 OTYPE type_declarator 1858 { $$ = $2; } 1859 | storage_class_list OTYPE type_declarator 1846 1860 { $$ = $3->addQualifiers( $1 ); } 1847 1861 | type_declaring_list ',' type_declarator … … 1869 1883 ; 1870 1884 1871 context_specifier: // CFA1872 CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'1885 trait_specifier: // CFA 1886 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 1873 1887 { 1874 1888 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1875 $$ = DeclarationNode::new Context( $2, $5, 0 );1876 } 1877 | CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'1878 { 1879 typedefTable.enter Context( *$2 );1889 $$ = DeclarationNode::newTrait( $2, $5, 0 ); 1890 } 1891 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' 1892 { 1893 typedefTable.enterTrait( *$2 ); 1880 1894 typedefTable.enterScope(); 1881 1895 } 1882 context_declaration_list '}'1883 { 1884 typedefTable.leave Context();1896 trait_declaration_list '}' 1897 { 1898 typedefTable.leaveTrait(); 1885 1899 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1886 $$ = DeclarationNode::new Context( $2, $5, $10 );1887 } 1888 ; 1889 1890 context_declaration_list: // CFA1891 context_declaration1892 | context_declaration_list push context_declaration1900 $$ = DeclarationNode::newTrait( $2, $5, $10 ); 1901 } 1902 ; 1903 1904 trait_declaration_list: // CFA 1905 trait_declaration 1906 | trait_declaration_list push trait_declaration 1893 1907 { $$ = $1->appendList( $3 ); } 1894 1908 ; 1895 1909 1896 context_declaration: // CFA1897 new_ context_declaring_list pop ';'1898 | context_declaring_list pop ';'1899 ; 1900 1901 new_ context_declaring_list: // CFA1910 trait_declaration: // CFA 1911 new_trait_declaring_list pop ';' 1912 | trait_declaring_list pop ';' 1913 ; 1914 1915 new_trait_declaring_list: // CFA 1902 1916 new_variable_specifier 1903 1917 { … … 1910 1924 $$ = $1; 1911 1925 } 1912 | new_ context_declaring_list pop ',' push identifier_or_type_name1926 | new_trait_declaring_list pop ',' push identifier_or_type_name 1913 1927 { 1914 1928 typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID ); … … 1917 1931 ; 1918 1932 1919 context_declaring_list: // CFA1933 trait_declaring_list: // CFA 1920 1934 type_specifier declarator 1921 1935 { … … 1923 1937 $$ = $2->addType( $1 ); 1924 1938 } 1925 | context_declaring_list pop ',' push declarator1939 | trait_declaring_list pop ',' push declarator 1926 1940 { 1927 1941 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 2809 2823 std::cout << "Error "; 2810 2824 if ( yyfilename ) { 2811 std::cout << "in file " << yyfilename << " ";2825 std::cout << "in file " << yyfilename << " "; 2812 2826 } // if 2813 2827 std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
Note:
See TracChangeset
for help on using the changeset viewer.