Changes in src/Parser/parser.yy [45161b4d:bd85400]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r45161b4d rbd85400 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 13 16:58:43201613 // Update Count : 1 51912 // Last Modified On : Mon Feb 1 18:22:42 2016 13 // Update Count : 1483 14 14 // 15 15 … … 51 51 #include <cstdio> 52 52 #include <stack> 53 #include "TypedefTable.h" 53 54 #include "lex.h" 54 #include "parser.h"55 55 #include "ParseNode.h" 56 #include "TypedefTable.h"57 56 #include "TypeData.h" 58 57 #include "LinkageSpec.h" … … 75 74 %token FORALL LVALUE // CFA 76 75 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 77 %token VALIST // GCC78 76 %token BOOL COMPLEX IMAGINARY // C99 79 77 %token TYPEOF LABEL // GCC 80 78 %token ENUM STRUCT UNION 81 %token OTYPE FTYPE DTYPE TRAIT// CFA79 %token TYPE FTYPE DTYPE CONTEXT // CFA 82 80 %token SIZEOF OFFSETOF 83 81 %token ATTRIBUTE EXTENSION // GCC … … 173 171 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name 174 172 175 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier173 %type<decl> context_declaration context_declaration_list context_declaring_list context_specifier 176 174 177 175 %type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list … … 199 197 %type<decl> new_array_parameter_1st_dimension 200 198 201 %type<decl> new_ trait_declaring_list new_declaration new_field_declaring_list199 %type<decl> new_context_declaring_list new_declaration new_field_declaring_list 202 200 %type<decl> new_function_declaration new_function_return new_function_specifier 203 201 … … 372 370 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); } 373 371 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99 374 { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); }372 { $$ = 0; } 375 373 | postfix_expression '{' argument_expression_list '}' // CFA 376 374 { … … 450 448 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); } 451 449 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 452 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }450 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); } 453 451 | ATTR_IDENTIFIER 454 452 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); } … … 1022 1020 | new_function_declaration pop ';' 1023 1021 | type_declaring_list pop ';' 1024 | trait_specifier pop ';'1022 | context_specifier pop ';' 1025 1023 ; 1026 1024 … … 1029 1027 { 1030 1028 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1031 $$ = $1 ->addInitializer( $2 );1029 $$ = $1; 1032 1030 } 1033 1031 | declaration_qualifier_list new_variable_specifier initializer_opt … … 1036 1034 { 1037 1035 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1038 $$ = $2->addQualifiers( $1 ) ->addInitializer( $3 );;1036 $$ = $2->addQualifiers( $1 ); 1039 1037 } 1040 1038 | new_variable_declaration pop ',' push identifier_or_type_name initializer_opt 1041 1039 { 1042 1040 typedefTable.addToEnclosingScope( *$5, TypedefTable::ID ); 1043 $$ = $1->appendList( $1->cloneType( $5 ) ->addInitializer( $6 ));1041 $$ = $1->appendList( $1->cloneType( $5 ) ); 1044 1042 } 1045 1043 ; … … 1347 1345 | IMAGINARY // C99 1348 1346 { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); } 1349 | VALIST // GCC, __builtin_va_list1350 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1351 1347 ; 1352 1348 … … 1438 1434 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3 ); } 1439 1435 | aggregate_key no_attr_identifier_or_type_name 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); } 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 ); } 1448 1439 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1449 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }1440 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); } 1450 1441 | aggregate_key typegen_name // CFA, S/R conflict 1451 1442 { $$ = $2; } … … 1525 1516 enum_key '{' enumerator_list comma_opt '}' 1526 1517 { $$ = DeclarationNode::newEnum( 0, $3 ); } 1518 | enum_key no_attr_identifier_or_type_name '{' enumerator_list comma_opt '}' 1519 { $$ = DeclarationNode::newEnum( $2, $4 ); } 1527 1520 | enum_key no_attr_identifier_or_type_name 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 ); } 1521 { $$ = DeclarationNode::newEnum( $2, 0 ); } 1536 1522 ; 1537 1523 … … 1817 1803 1818 1804 type_class: // CFA 1819 OTYPE1805 TYPE 1820 1806 { $$ = DeclarationNode::Type; } 1821 1807 | DTYPE … … 1835 1821 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 1836 1822 { 1837 typedefTable.open Trait( *$2 );1838 $$ = DeclarationNode::new TraitUse( $2, $4 );1839 } 1840 | '|' '{' push trait_declaration_list '}'1823 typedefTable.openContext( *$2 ); 1824 $$ = DeclarationNode::newContextUse( $2, $4 ); 1825 } 1826 | '|' '{' push context_declaration_list '}' 1841 1827 { $$ = $4; } 1842 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'1828 | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')' 1843 1829 { $$ = 0; } 1844 1830 ; … … 1855 1841 1856 1842 type_declaring_list: // CFA 1857 OTYPE type_declarator1858 { $$ = $2; } 1859 | storage_class_list OTYPE type_declarator1843 TYPE type_declarator 1844 { $$ = $2; } 1845 | storage_class_list TYPE type_declarator 1860 1846 { $$ = $3->addQualifiers( $1 ); } 1861 1847 | type_declaring_list ',' type_declarator … … 1883 1869 ; 1884 1870 1885 trait_specifier: // CFA1886 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'1871 context_specifier: // CFA 1872 CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 1887 1873 { 1888 1874 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1889 $$ = DeclarationNode::new Trait( $2, $5, 0 );1890 } 1891 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'1892 { 1893 typedefTable.enter Trait( *$2 );1875 $$ = DeclarationNode::newContext( $2, $5, 0 ); 1876 } 1877 | CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' 1878 { 1879 typedefTable.enterContext( *$2 ); 1894 1880 typedefTable.enterScope(); 1895 1881 } 1896 trait_declaration_list '}'1897 { 1898 typedefTable.leave Trait();1882 context_declaration_list '}' 1883 { 1884 typedefTable.leaveContext(); 1899 1885 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1900 $$ = DeclarationNode::new Trait( $2, $5, $10 );1901 } 1902 ; 1903 1904 trait_declaration_list: // CFA1905 trait_declaration1906 | trait_declaration_list push trait_declaration1886 $$ = DeclarationNode::newContext( $2, $5, $10 ); 1887 } 1888 ; 1889 1890 context_declaration_list: // CFA 1891 context_declaration 1892 | context_declaration_list push context_declaration 1907 1893 { $$ = $1->appendList( $3 ); } 1908 1894 ; 1909 1895 1910 trait_declaration: // CFA1911 new_ trait_declaring_list pop ';'1912 | trait_declaring_list pop ';'1913 ; 1914 1915 new_ trait_declaring_list: // CFA1896 context_declaration: // CFA 1897 new_context_declaring_list pop ';' 1898 | context_declaring_list pop ';' 1899 ; 1900 1901 new_context_declaring_list: // CFA 1916 1902 new_variable_specifier 1917 1903 { … … 1924 1910 $$ = $1; 1925 1911 } 1926 | new_ trait_declaring_list pop ',' push identifier_or_type_name1912 | new_context_declaring_list pop ',' push identifier_or_type_name 1927 1913 { 1928 1914 typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID ); … … 1931 1917 ; 1932 1918 1933 trait_declaring_list: // CFA1919 context_declaring_list: // CFA 1934 1920 type_specifier declarator 1935 1921 { … … 1937 1923 $$ = $2->addType( $1 ); 1938 1924 } 1939 | trait_declaring_list pop ',' push declarator1925 | context_declaring_list pop ',' push declarator 1940 1926 { 1941 1927 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 2823 2809 std::cout << "Error "; 2824 2810 if ( yyfilename ) { 2825 std::cout << "in file " << yyfilename << " ";2811 std::cout << "in file " << yyfilename << " "; 2826 2812 } // if 2827 2813 std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
Note:
See TracChangeset
for help on using the changeset viewer.