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