Changes in src/Parser/parser.yy [e82aa9df:2037f82]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
re82aa9df r2037f82 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 15 15:18:19201613 // Update Count : 1 89112 // Last Modified On : Thu Aug 18 23:49:10 2016 13 // Update Count : 1909 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;46 45 47 46 #undef __GNUC_MINOR__ … … 56 55 #include "LinkageSpec.h" 57 56 58 DeclarationNode *theTree = 0; // the resulting parse tree 59 LinkageSpec::Type linkage = LinkageSpec::Cforall; 60 std::stack< LinkageSpec::Type > linkageStack; 61 TypedefTable typedefTable; 57 extern DeclarationNode * parseTree; 58 extern LinkageSpec::Spec linkage; 59 extern TypedefTable typedefTable; 60 61 std::stack< LinkageSpec::Spec > linkageStack; 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_ name storage_class_list225 %type<decl> storage_class 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( *$1) ); }314 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( *$1) ); }315 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( *$1) ); }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) ) ); } 316 316 ; 317 317 … … 338 338 339 339 string_literal_list: // juxtaposed strings are concatenated 340 STRINGliteral { $$ = build_constantStr( *$1); }340 STRINGliteral { $$ = build_constantStr( assign_strptr($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 != NULL; iter = (DeclarationNode *)iter->get_next() )701 for ( DeclarationNode *iter = $2; iter != nullptr; 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( *$2, BranchStmt::Goto ) ); }840 { $$ = new StatementNode( build_branch( assign_strptr($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( *$2, BranchStmt::Continue ) ); delete $2; }851 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Continue ) ); } 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( *$2, BranchStmt::Break ) ); delete $2; }858 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Break ) ); } 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( *$1); }981 { $$ = new LabelNode(); $$->labels.push_back( assign_strptr($1) ); } 982 982 | label_list ',' no_attr_identifier 983 { $$ = $1; $1->labels.push_back( *$3); }983 { $$ = $1; $1->labels.push_back( assign_strptr($3) ); } 984 984 ; 985 985 … … 1324 1324 1325 1325 storage_class: 1326 storage_class_name1327 ;1328 1329 storage_class_name:1330 1326 EXTERN 1331 1327 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } … … 1497 1493 | EXTENSION field_declaring_list ';' // GCC 1498 1494 { // mark all fields in list 1499 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )1495 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) 1500 1496 iter->set_extension( true ); 1501 1497 $$ = $2; … … 1974 1970 {} // empty input file 1975 1971 | external_definition_list 1976 { 1977 if ( theTree ) { 1978 theTree->appendList( $1 ); 1979 } else { 1980 theTree = $1; 1981 } 1982 } 1972 { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1; } 1983 1973 ; 1984 1974 … … 1986 1976 external_definition 1987 1977 | external_definition_list push external_definition 1988 { $$ = ( $1 != NULL )? $1->appendList( $3 ) : $3; }1978 { $$ = $1 != nullptr ? $1->appendList( $3 ) : $3; } 1989 1979 ; 1990 1980 … … 2002 1992 | EXTERN STRINGliteral 2003 1993 { 2004 linkageStack.push( linkage ); 2005 linkage = LinkageSpec::fromString( *$2);1994 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 1995 linkage = LinkageSpec::fromString( assign_strptr($2) ); 2006 1996 } 2007 1997 '{' external_definition_list_opt '}' // C++-style linkage specifier … … 2013 2003 | EXTENSION external_definition 2014 2004 { // mark all fields in list 2015 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )2005 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) 2016 2006 iter->set_extension( true ); 2017 2007 $$ = $2; … … 2147 2137 2148 2138 any_word: // GCC 2149 identifier_or_type_name { }2150 | storage_class _name {}2151 | basic_type_name { }2152 | type_qualifier { }2139 identifier_or_type_name { delete $1; } 2140 | storage_class { delete $1; } 2141 | basic_type_name { delete $1; } 2142 | type_qualifier { delete $1; } 2153 2143 ; 2154 2144 … … 2848 2838 // ----end of grammar---- 2849 2839 2840 extern char *yytext; 2841 2850 2842 void yyerror( const char * ) { 2851 2843 std::cout << "Error ";
Note:
See TracChangeset
for help on using the changeset viewer.