Changes in src/Parser/parser.yy [2037f82:e82aa9df]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r2037f82 re82aa9df 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 18 23:49:10201613 // Update Count : 1 90912 // Last Modified On : Mon Aug 15 15:18:19 2016 13 // Update Count : 1891 14 14 // 15 15 … … 43 43 #define YYDEBUG_LEXER_TEXT (yylval) // lexer loads this up each time 44 44 #define YYDEBUG 1 // get the pretty debugging code to compile 45 extern char *yytext; 45 46 46 47 #undef __GNUC_MINOR__ … … 55 56 #include "LinkageSpec.h" 56 57 57 extern DeclarationNode * parseTree; 58 extern LinkageSpec::Spec linkage; 59 extern TypedefTable typedefTable; 60 61 std::stack< LinkageSpec::Spec > linkageStack; 58 DeclarationNode *theTree = 0; // the resulting parse tree 59 LinkageSpec::Type linkage = LinkageSpec::Cforall; 60 std::stack< LinkageSpec::Type > linkageStack; 61 TypedefTable typedefTable; 62 62 63 63 void appendStr( std::string &to, std::string *from ) { … … 223 223 %type<decl> paren_identifier paren_type 224 224 225 %type<decl> storage_class storage_class_ list225 %type<decl> storage_class storage_class_name storage_class_list 226 226 227 227 %type<decl> sue_declaration_specifier sue_type_specifier … … 311 311 constant: 312 312 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 313 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( assign_strptr($1)) ); }314 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( assign_strptr($1)) ); }315 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( assign_strptr($1)) ); }313 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 314 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); } 315 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1 ) ); } 316 316 ; 317 317 … … 338 338 339 339 string_literal_list: // juxtaposed strings are concatenated 340 STRINGliteral { $$ = build_constantStr( assign_strptr($1)); }340 STRINGliteral { $$ = build_constantStr( *$1 ); } 341 341 | string_literal_list STRINGliteral 342 342 { … … 699 699 | EXTENSION declaration // GCC 700 700 { // mark all fields in list 701 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )701 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() ) 702 702 iter->set_extension( true ); 703 703 $$ = new StatementNode( $2 ); … … 838 838 jump_statement: 839 839 GOTO IDENTIFIER ';' 840 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Goto ) ); }840 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Goto ) ); } 841 841 | GOTO '*' comma_expression ';' // GCC, computed goto 842 842 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3); … … 849 849 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 850 850 // the target of the transfer appears only at the start of an iteration statement. 851 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Continue ) ); }851 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Continue ) ); delete $2; } 852 852 | BREAK ';' 853 853 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. … … 856 856 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 857 857 // the target of the transfer appears only at the start of an iteration statement. 858 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Break ) ); }858 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Break ) ); delete $2; } 859 859 | RETURN comma_expression_opt ';' 860 860 { $$ = new StatementNode( build_return( $2 ) ); } … … 979 979 label_list: 980 980 no_attr_identifier 981 { $$ = new LabelNode(); $$->labels.push_back( assign_strptr($1)); }981 { $$ = new LabelNode(); $$->labels.push_back( *$1 ); } 982 982 | label_list ',' no_attr_identifier 983 { $$ = $1; $1->labels.push_back( assign_strptr($3)); }983 { $$ = $1; $1->labels.push_back( *$3 ); } 984 984 ; 985 985 … … 1324 1324 1325 1325 storage_class: 1326 storage_class_name 1327 ; 1328 1329 storage_class_name: 1326 1330 EXTERN 1327 1331 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } … … 1493 1497 | EXTENSION field_declaring_list ';' // GCC 1494 1498 { // mark all fields in list 1495 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )1499 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() ) 1496 1500 iter->set_extension( true ); 1497 1501 $$ = $2; … … 1970 1974 {} // empty input file 1971 1975 | external_definition_list 1972 { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1; } 1976 { 1977 if ( theTree ) { 1978 theTree->appendList( $1 ); 1979 } else { 1980 theTree = $1; 1981 } 1982 } 1973 1983 ; 1974 1984 … … 1976 1986 external_definition 1977 1987 | external_definition_list push external_definition 1978 { $$ = $1 != nullptr? $1->appendList( $3 ) : $3; }1988 { $$ = ( $1 != NULL ) ? $1->appendList( $3 ) : $3; } 1979 1989 ; 1980 1990 … … 1992 2002 | EXTERN STRINGliteral 1993 2003 { 1994 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall"1995 linkage = LinkageSpec::fromString( assign_strptr($2));2004 linkageStack.push( linkage ); 2005 linkage = LinkageSpec::fromString( *$2 ); 1996 2006 } 1997 2007 '{' external_definition_list_opt '}' // C++-style linkage specifier … … 2003 2013 | EXTENSION external_definition 2004 2014 { // mark all fields in list 2005 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )2015 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() ) 2006 2016 iter->set_extension( true ); 2007 2017 $$ = $2; … … 2137 2147 2138 2148 any_word: // GCC 2139 identifier_or_type_name { delete $1;}2140 | storage_class { delete $1;}2141 | basic_type_name { delete $1;}2142 | type_qualifier { delete $1;}2149 identifier_or_type_name {} 2150 | storage_class_name {} 2151 | basic_type_name {} 2152 | type_qualifier {} 2143 2153 ; 2144 2154 … … 2838 2848 // ----end of grammar---- 2839 2849 2840 extern char *yytext;2841 2842 2850 void yyerror( const char * ) { 2843 2851 std::cout << "Error ";
Note:
See TracChangeset
for help on using the changeset viewer.