Changes in src/Parser/parser.yy [bd85400:3cfe27f]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rbd85400 r3cfe27f 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 : 14 8312 // Last Modified On : Thu Mar 24 16:16:16 2016 13 // Update Count : 1498 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 … … 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 … … 1803 1807 1804 1808 type_class: // CFA 1805 TYPE1809 OTYPE 1806 1810 { $$ = DeclarationNode::Type; } 1807 1811 | DTYPE … … 1821 1825 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 1822 1826 { 1823 typedefTable.open Context( *$2 );1824 $$ = DeclarationNode::new ContextUse( $2, $4 );1825 } 1826 | '|' '{' push context_declaration_list '}'1827 typedefTable.openTrait( *$2 ); 1828 $$ = DeclarationNode::newTraitUse( $2, $4 ); 1829 } 1830 | '|' '{' push trait_declaration_list '}' 1827 1831 { $$ = $4; } 1828 | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')'1832 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')' 1829 1833 { $$ = 0; } 1830 1834 ; … … 1841 1845 1842 1846 type_declaring_list: // CFA 1843 TYPE type_declarator1844 { $$ = $2; } 1845 | storage_class_list TYPE type_declarator1847 OTYPE type_declarator 1848 { $$ = $2; } 1849 | storage_class_list OTYPE type_declarator 1846 1850 { $$ = $3->addQualifiers( $1 ); } 1847 1851 | type_declaring_list ',' type_declarator … … 1869 1873 ; 1870 1874 1871 context_specifier: // CFA1872 CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'1875 trait_specifier: // CFA 1876 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 1873 1877 { 1874 1878 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 );1879 $$ = DeclarationNode::newTrait( $2, $5, 0 ); 1880 } 1881 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' 1882 { 1883 typedefTable.enterTrait( *$2 ); 1880 1884 typedefTable.enterScope(); 1881 1885 } 1882 context_declaration_list '}'1883 { 1884 typedefTable.leave Context();1886 trait_declaration_list '}' 1887 { 1888 typedefTable.leaveTrait(); 1885 1889 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_declaration1890 $$ = DeclarationNode::newTrait( $2, $5, $10 ); 1891 } 1892 ; 1893 1894 trait_declaration_list: // CFA 1895 trait_declaration 1896 | trait_declaration_list push trait_declaration 1893 1897 { $$ = $1->appendList( $3 ); } 1894 1898 ; 1895 1899 1896 context_declaration: // CFA1897 new_ context_declaring_list pop ';'1898 | context_declaring_list pop ';'1899 ; 1900 1901 new_ context_declaring_list: // CFA1900 trait_declaration: // CFA 1901 new_trait_declaring_list pop ';' 1902 | trait_declaring_list pop ';' 1903 ; 1904 1905 new_trait_declaring_list: // CFA 1902 1906 new_variable_specifier 1903 1907 { … … 1910 1914 $$ = $1; 1911 1915 } 1912 | new_ context_declaring_list pop ',' push identifier_or_type_name1916 | new_trait_declaring_list pop ',' push identifier_or_type_name 1913 1917 { 1914 1918 typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID ); … … 1917 1921 ; 1918 1922 1919 context_declaring_list: // CFA1923 trait_declaring_list: // CFA 1920 1924 type_specifier declarator 1921 1925 { … … 1923 1927 $$ = $2->addType( $1 ); 1924 1928 } 1925 | context_declaring_list pop ',' push declarator1929 | trait_declaring_list pop ',' push declarator 1926 1930 { 1927 1931 typedefTable.addToEnclosingScope2( TypedefTable::ID );
Note:
See TracChangeset
for help on using the changeset viewer.