Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r2298f728 r4ed70597  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:30:40 2016
    13 // Update Count     : 1991
     12// Last Modified On : Fri Aug 26 16:45:44 2016
     13// Update Count     : 1964
    1414//
    1515
     
    5454#include "TypeData.h"
    5555#include "LinkageSpec.h"
    56 using namespace std;
    5756
    5857extern DeclarationNode * parseTree;
     
    6059extern TypedefTable typedefTable;
    6160
    62 stack< LinkageSpec::Spec > linkageStack;
    63 
    64 void appendStr( string *to, string *from ) {
     61std::stack< LinkageSpec::Spec > linkageStack;
     62
     63void appendStr( std::string *to, std::string *from ) {
    6564        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    6665        to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) );
     
    360359                { $$ = $2; }
    361360        | '(' compound_statement ')'                                            // GCC, lambda expression
    362                 { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     361        { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    363362        ;
    364363
     
    390389                {
    391390                        Token fn;
    392                         fn.str = new string( "?{}" );                           // location undefined
     391                        fn.str = new std::string( "?{}" ); // location undefined
    393392                        $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) );
    394393                }
     
    667666                {
    668667                        Token fn;
    669                         fn.str = new string( "^?{}" );                          // location undefined
     668                        fn.str = new std::string( "^?{}" ); // location undefined
    670669                        $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    671670                }
     
    897896                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    898897        | 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 ) ) ); }
    900899        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    901900                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     
    969968                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    970969        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    971                 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     970        { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    972971        ;
    973972
     
    13641363                { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); }
    13651364        | LONG
    1366                 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
     1365                { $$ = DeclarationNode::newModifier( DeclarationNode::Long ); }
    13671366        | SHORT
    1368                 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); }
     1367                { $$ = DeclarationNode::newModifier( DeclarationNode::Short ); }
    13691368        | SIGNED
    1370                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
     1369                { $$ = DeclarationNode::newModifier( DeclarationNode::Signed ); }
    13711370        | UNSIGNED
    1372                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
     1371                { $$ = DeclarationNode::newModifier( DeclarationNode::Unsigned ); }
    13731372        | VOID
    13741373                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     
    13761375                { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
    13771376        | COMPLEX                                                                                       // C99
    1378                 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
     1377                { $$ = DeclarationNode::newBasicType( DeclarationNode::Complex ); }
    13791378        | IMAGINARY                                                                                     // C99
    1380                 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
     1379                { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); }
    13811380        | VALIST                                                                                        // GCC, __builtin_va_list
    13821381                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    14681467aggregate_name:
    14691468        aggregate_key '{' field_declaration_list '}'
    1470                 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $3, true ); }
     1469                { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }
    14711470        | aggregate_key no_attr_identifier_or_type_name
    14721471                {
    14731472                        typedefTable.makeTypedef( *$2 );
    1474                         $$ = DeclarationNode::newAggregate( $1, $2, nullptr, nullptr, false );
     1473                        $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, false );
    14751474                }
    14761475        | aggregate_key no_attr_identifier_or_type_name
    14771476                { typedefTable.makeTypedef( *$2 ); }
    14781477                '{' field_declaration_list '}'
    1479                 { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }
     1478                { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }
    14801479        | 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 ); }
    14821481        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14831482                { $$ = $2; }
     
    15601559enum_name:
    15611560        enum_key '{' enumerator_list comma_opt '}'
    1562                 { $$ = DeclarationNode::newEnum( nullptr, $3 ); }
     1561                { $$ = DeclarationNode::newEnum( 0, $3 ); }
    15631562        | enum_key no_attr_identifier_or_type_name
    15641563                {
     
    18501849type_class:                                                                                             // CFA
    18511850        OTYPE
    1852                 { $$ = DeclarationNode::Otype; }
     1851                { $$ = DeclarationNode::Type; }
    18531852        | DTYPE
    18541853                { $$ = DeclarationNode::Ftype; }
     
    25212520abstract_function:
    25222521        '(' 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 ); }
    25242523        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25252524                { $$ = $2->addParamList( $6 ); }
     
    25902589abstract_parameter_function:
    25912590        '(' 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 ); }
    25932592        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25942593                { $$ = $2->addParamList( $6 ); }
     
    27942793                // empty (void) function return type.
    27952794        '[' ']' type_specifier
    2796                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2795                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    27972796        | '[' ']' 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 ) ); }
    27992798        | multi_array_dimension type_specifier
    28002799                { $$ = $2->addNewArray( $1 ); }
    28012800        | '[' ']' new_abstract_ptr
    2802                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2801                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    28032802        | '[' ']' 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 ) ); }
    28052804        | multi_array_dimension new_abstract_ptr
    28062805                { $$ = $2->addNewArray( $1 ); }
     
    28142813new_abstract_function:                                                                  // CFA
    28152814        '[' ']' '(' new_parameter_type_list_opt ')'
    2816                 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
     2815                { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
    28172816        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    2818                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     2817                { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
    28192818        | new_function_return '(' push new_parameter_type_list_opt pop ')'
    2820                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     2819                { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
    28212820        ;
    28222821
     
    28532852
    28542853void yyerror( const char * ) {
    2855         cout << "Error ";
     2854        std::cout << "Error ";
    28562855        if ( yyfilename ) {
    2857                 cout << "in file " << yyfilename << " ";
     2856                std::cout << "in file " << yyfilename << " ";
    28582857        } // 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;
    28602859}
    28612860
Note: See TracChangeset for help on using the changeset viewer.