Changes in src/Parser/parser.yy [2298f728:4ed70597]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r2298f728 r4ed70597 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 24 11:30:40201613 // Update Count : 19 9112 // Last Modified On : Fri Aug 26 16:45:44 2016 13 // Update Count : 1964 14 14 // 15 15 … … 54 54 #include "TypeData.h" 55 55 #include "LinkageSpec.h" 56 using namespace std;57 56 58 57 extern DeclarationNode * parseTree; … … 60 59 extern TypedefTable typedefTable; 61 60 62 st ack< LinkageSpec::Spec > linkageStack;63 64 void appendStr( st ring *to,string *from ) {61 std::stack< LinkageSpec::Spec > linkageStack; 62 63 void appendStr( std::string *to, std::string *from ) { 65 64 // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string. 66 65 to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) ); … … 360 359 { $$ = $2; } 361 360 | '(' compound_statement ')' // GCC, lambda expression 362 { $$ = new ExpressionNode( build_valexpr( $2 ) ); }361 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 363 362 ; 364 363 … … 390 389 { 391 390 Token fn; 392 fn.str = new st ring( "?{}" );// location undefined391 fn.str = new std::string( "?{}" ); // location undefined 393 392 $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ); 394 393 } … … 667 666 { 668 667 Token fn; 669 fn.str = new st ring( "^?{}" );// location undefined668 fn.str = new std::string( "^?{}" ); // location undefined 670 669 $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) ); 671 670 } … … 897 896 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 898 897 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 899 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }898 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 900 899 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 901 900 { $$ = new StatementNode( build_catch( $5, $8 ) ); } … … 969 968 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); } 970 969 | '[' constant_expression ']' string_literal '(' constant_expression ')' 971 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }970 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); } 972 971 ; 973 972 … … 1364 1363 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1365 1364 | LONG 1366 { $$ = DeclarationNode::new Length( DeclarationNode::Long ); }1365 { $$ = DeclarationNode::newModifier( DeclarationNode::Long ); } 1367 1366 | SHORT 1368 { $$ = DeclarationNode::new Length( DeclarationNode::Short ); }1367 { $$ = DeclarationNode::newModifier( DeclarationNode::Short ); } 1369 1368 | SIGNED 1370 { $$ = DeclarationNode::new SignedNess( DeclarationNode::Signed ); }1369 { $$ = DeclarationNode::newModifier( DeclarationNode::Signed ); } 1371 1370 | UNSIGNED 1372 { $$ = DeclarationNode::new SignedNess( DeclarationNode::Unsigned ); }1371 { $$ = DeclarationNode::newModifier( DeclarationNode::Unsigned ); } 1373 1372 | VOID 1374 1373 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 1376 1375 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1377 1376 | COMPLEX // C99 1378 { $$ = DeclarationNode::new ComplexType( DeclarationNode::Complex ); }1377 { $$ = DeclarationNode::newBasicType( DeclarationNode::Complex ); } 1379 1378 | IMAGINARY // C99 1380 { $$ = DeclarationNode::new ComplexType( DeclarationNode::Imaginary ); }1379 { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); } 1381 1380 | VALIST // GCC, __builtin_va_list 1382 1381 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1468 1467 aggregate_name: 1469 1468 aggregate_key '{' field_declaration_list '}' 1470 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $3, true ); }1469 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); } 1471 1470 | aggregate_key no_attr_identifier_or_type_name 1472 1471 { 1473 1472 typedefTable.makeTypedef( *$2 ); 1474 $$ = DeclarationNode::newAggregate( $1, $2, nullptr, nullptr, false );1473 $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, false ); 1475 1474 } 1476 1475 | aggregate_key no_attr_identifier_or_type_name 1477 1476 { typedefTable.makeTypedef( *$2 ); } 1478 1477 '{' field_declaration_list '}' 1479 { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }1478 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); } 1480 1479 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1481 { $$ = DeclarationNode::newAggregate( $1, nullptr, $3, $6, false ); }1480 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); } 1482 1481 | aggregate_key typegen_name // CFA, S/R conflict 1483 1482 { $$ = $2; } … … 1560 1559 enum_name: 1561 1560 enum_key '{' enumerator_list comma_opt '}' 1562 { $$ = DeclarationNode::newEnum( nullptr, $3 ); }1561 { $$ = DeclarationNode::newEnum( 0, $3 ); } 1563 1562 | enum_key no_attr_identifier_or_type_name 1564 1563 { … … 1850 1849 type_class: // CFA 1851 1850 OTYPE 1852 { $$ = DeclarationNode:: Otype; }1851 { $$ = DeclarationNode::Type; } 1853 1852 | DTYPE 1854 1853 { $$ = DeclarationNode::Ftype; } … … 2521 2520 abstract_function: 2522 2521 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2523 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr); }2522 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); } 2524 2523 | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2525 2524 { $$ = $2->addParamList( $6 ); } … … 2590 2589 abstract_parameter_function: 2591 2590 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2592 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr); }2591 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); } 2593 2592 | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2594 2593 { $$ = $2->addParamList( $6 ); } … … 2794 2793 // empty (void) function return type. 2795 2794 '[' ']' type_specifier 2796 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }2795 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2797 2796 | '[' ']' multi_array_dimension type_specifier 2798 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }2797 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2799 2798 | multi_array_dimension type_specifier 2800 2799 { $$ = $2->addNewArray( $1 ); } 2801 2800 | '[' ']' new_abstract_ptr 2802 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }2801 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2803 2802 | '[' ']' multi_array_dimension new_abstract_ptr 2804 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }2803 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 2805 2804 | multi_array_dimension new_abstract_ptr 2806 2805 { $$ = $2->addNewArray( $1 ); } … … 2814 2813 new_abstract_function: // CFA 2815 2814 '[' ']' '(' new_parameter_type_list_opt ')' 2816 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr); }2815 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); } 2817 2816 | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')' 2818 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr); }2817 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); } 2819 2818 | new_function_return '(' push new_parameter_type_list_opt pop ')' 2820 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr); }2819 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); } 2821 2820 ; 2822 2821 … … 2853 2852 2854 2853 void yyerror( const char * ) { 2855 cout << "Error ";2854 std::cout << "Error "; 2856 2855 if ( yyfilename ) { 2857 cout << "in file " << yyfilename << " ";2856 std::cout << "in file " << yyfilename << " "; 2858 2857 } // if 2859 cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" <<endl;2858 std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl; 2860 2859 } 2861 2860
Note:
See TracChangeset
for help on using the changeset viewer.