Changes in src/Parser/parser.yy [3cfe27f:bd85400]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r3cfe27f rbd85400 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 24 16:16:16201613 // Update Count : 14 9812 // 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 … … 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 … … 1807 1803 1808 1804 type_class: // CFA 1809 OTYPE1805 TYPE 1810 1806 { $$ = DeclarationNode::Type; } 1811 1807 | DTYPE … … 1825 1821 '|' no_attr_identifier_or_type_name '(' type_name_list ')' 1826 1822 { 1827 typedefTable.open Trait( *$2 );1828 $$ = DeclarationNode::new TraitUse( $2, $4 );1829 } 1830 | '|' '{' push trait_declaration_list '}'1823 typedefTable.openContext( *$2 ); 1824 $$ = DeclarationNode::newContextUse( $2, $4 ); 1825 } 1826 | '|' '{' push context_declaration_list '}' 1831 1827 { $$ = $4; } 1832 | '|' '(' 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 ')' 1833 1829 { $$ = 0; } 1834 1830 ; … … 1845 1841 1846 1842 type_declaring_list: // CFA 1847 OTYPE type_declarator1848 { $$ = $2; } 1849 | storage_class_list OTYPE type_declarator1843 TYPE type_declarator 1844 { $$ = $2; } 1845 | storage_class_list TYPE type_declarator 1850 1846 { $$ = $3->addQualifiers( $1 ); } 1851 1847 | type_declaring_list ',' type_declarator … … 1873 1869 ; 1874 1870 1875 trait_specifier: // CFA1876 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 ')' '{' '}' 1877 1873 { 1878 1874 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1879 $$ = DeclarationNode::new Trait( $2, $5, 0 );1880 } 1881 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'1882 { 1883 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 ); 1884 1880 typedefTable.enterScope(); 1885 1881 } 1886 trait_declaration_list '}'1887 { 1888 typedefTable.leave Trait();1882 context_declaration_list '}' 1883 { 1884 typedefTable.leaveContext(); 1889 1885 typedefTable.addToEnclosingScope( *$2, TypedefTable::ID ); 1890 $$ = DeclarationNode::new Trait( $2, $5, $10 );1891 } 1892 ; 1893 1894 trait_declaration_list: // CFA1895 trait_declaration1896 | 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 1897 1893 { $$ = $1->appendList( $3 ); } 1898 1894 ; 1899 1895 1900 trait_declaration: // CFA1901 new_ trait_declaring_list pop ';'1902 | trait_declaring_list pop ';'1903 ; 1904 1905 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 1906 1902 new_variable_specifier 1907 1903 { … … 1914 1910 $$ = $1; 1915 1911 } 1916 | new_ trait_declaring_list pop ',' push identifier_or_type_name1912 | new_context_declaring_list pop ',' push identifier_or_type_name 1917 1913 { 1918 1914 typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID ); … … 1921 1917 ; 1922 1918 1923 trait_declaring_list: // CFA1919 context_declaring_list: // CFA 1924 1920 type_specifier declarator 1925 1921 { … … 1927 1923 $$ = $2->addType( $1 ); 1928 1924 } 1929 | trait_declaring_list pop ',' push declarator1925 | context_declaring_list pop ',' push declarator 1930 1926 { 1931 1927 typedefTable.addToEnclosingScope2( TypedefTable::ID );
Note:
See TracChangeset
for help on using the changeset viewer.