Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r7bf7fb9 rac71a86  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  7 09:37:48 2016
    13 // Update Count     : 1764
     12// Last Modified On : Thu Aug 18 23:49:10 2016
     13// Update Count     : 1909
    1414//
    1515
     
    4343#define YYDEBUG_LEXER_TEXT (yylval)                                             // lexer loads this up each time
    4444#define YYDEBUG 1                                                                               // get the pretty debugging code to compile
    45 extern char *yytext;
    4645
    4746#undef __GNUC_MINOR__
     
    5655#include "LinkageSpec.h"
    5756
    58 DeclarationNode *theTree = 0;                                                   // the resulting parse tree
    59 LinkageSpec::Type linkage = LinkageSpec::Cforall;
    60 std::stack< LinkageSpec::Type > linkageStack;
    61 TypedefTable typedefTable;
     57extern DeclarationNode * parseTree;
     58extern LinkageSpec::Spec linkage;
     59extern TypedefTable typedefTable;
     60
     61std::stack< LinkageSpec::Spec > linkageStack;
    6262
    6363void appendStr( std::string &to, std::string *from ) {
     
    121121        DeclarationNode::TypeClass tclass;
    122122        StatementNode *sn;
    123         ConstantNode *constant;
     123        ConstantExpr *constant;
     124        ForCtl *fctl;
    124125        LabelNode *label;
    125126        InitializerNode *in;
     
    133134
    134135// expressions
    135 %type<constant> constant
     136%type<en> constant
    136137%type<en> tuple                                                 tuple_expression_list
    137138%type<op> ptrref_operator                               unary_operator                          assignment_operator
     
    142143%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    143144%type<en> comma_expression                              comma_expression_opt
    144 %type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
     145%type<en> argument_expression_list              argument_expression                     assignment_opt
     146%type<fctl> for_control_expression
    145147%type<en> subrange
    146148%type<en> asm_operands_opt asm_operands_list asm_operand
    147149%type<label> label_list
    148 %type<constant> asm_clobbers_list_opt
     150%type<en> asm_clobbers_list_opt
    149151%type<flag> asm_volatile_opt
    150152
     
    159161%type<sn> case_value_list                               case_label                                      case_label_list
    160162%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    161 %type<pn> handler_list                                  handler_clause                          finally_clause
     163%type<sn> handler_list                                  handler_clause                          finally_clause
    162164
    163165// declarations
     
    221223%type<decl> paren_identifier paren_type
    222224
    223 %type<decl> storage_class storage_class_name storage_class_list
     225%type<decl> storage_class storage_class_list
    224226
    225227%type<decl> sue_declaration_specifier sue_type_specifier
     
    309311constant:
    310312                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    311 INTEGERconstant                                                                 { $$ = build_constantInteger( *$1 ); }
    312         | FLOATINGconstant                                                      { $$ = build_constantFloat( *$1 ); }
    313         | CHARACTERconstant                                                     { $$ = 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) ) ); }
    314316        ;
    315317
     
    336338
    337339string_literal_list:                                                                    // juxtaposed strings are concatenated
    338         STRINGliteral                                                           { $$ = build_constantStr( *$1 ); }
     340        STRINGliteral                                                           { $$ = build_constantStr( assign_strptr($1) ); }
    339341        | string_literal_list STRINGliteral
    340342                {
    341                         appendStr( $1->get_expr()->get_constant()->get_value(), $2 );
     343                        appendStr( $1->get_constant()->get_value(), $2 );
    342344                        delete $2;                                                                      // allocated by lexer
    343345                        $$ = $1;
     
    349351primary_expression:
    350352        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    351                 { $$ = new VarRefNode( $1 ); }
     353                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    352354        | zero_one
    353                 { $$ = new VarRefNode( $1 ); }
     355                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    354356        | '(' comma_expression ')'
    355357                { $$ = $2; }
    356358        | '(' compound_statement ')'                                            // GCC, lambda expression
    357                 { $$ = new ValofExprNode( $2 ); }
     359        { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    358360        ;
    359361
     
    365367                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
    366368                // equivalent to the old x[i,j].
    367                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
     369                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
    368370        | postfix_expression '(' argument_expression_list ')'
    369                 { $$ = new CompositeExprNode( build_func( $1, $3 ) ); }
     371                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    370372        // ambiguity with .0 so space required after field-selection, e.g.
    371373                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    372374        | postfix_expression '.' no_attr_identifier
    373                 { $$ = new CompositeExprNode( build_fieldSel( $1, new VarRefNode( $3 ) ) ); }
     375                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    374376        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    375377        | postfix_expression ARROW no_attr_identifier
    376                 { $$ = new CompositeExprNode( build_pfieldSel( $1, new VarRefNode( $3 ) ) ); }
     378                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    377379        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    378380        | postfix_expression ICR
    379                 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     381                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
    380382        | postfix_expression DECR
    381                 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
     383                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
    382384        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
    383                 { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); }
     385                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
    384386        | postfix_expression '{' argument_expression_list '}' // CFA
    385387                {
    386388                        Token fn;
    387389                        fn.str = new std::string( "?{}" ); // location undefined
    388                         $$ = new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $1 )->set_link( $3 ) ) );
     390                        $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) );
    389391                }
    390392        ;
     
    393395        argument_expression
    394396        | argument_expression_list ',' argument_expression
    395                 { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
     397                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    396398        ;
    397399
     
    400402                { $$ = 0; }                                                                             // use default argument
    401403        | assignment_expression
    402         | no_attr_identifier ':' assignment_expression
    403                 { $$ = $3->set_argName( $1 ); }
    404                 // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    405                 // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    406                 // with an appropriate semantic check.
    407         | '[' push assignment_expression pop ']' ':' assignment_expression
    408                 { $$ = $7->set_argName( $3 ); }
    409         | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    410                 { $$ = $9->set_argName( new CompositeExprNode( build_tuple( (ExpressionNode *)$3->set_link( $5 ) ) ) ); }
    411404        ;
    412405
    413406field_list:                                                                                             // CFA, tuple field selector
    414407        field
    415         | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_link( $3 ); }
     408        | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    416409        ;
    417410
    418411field:                                                                                                  // CFA, tuple field selector
    419412        no_attr_identifier
    420                 { $$ = new VarRefNode( $1 ); }
     413                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    421414        // ambiguity with .0 so space required after field-selection, e.g.
    422415                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    423416        | no_attr_identifier '.' field
    424                 { $$ = new CompositeExprNode( build_fieldSel( $3, new VarRefNode( $1 ) ) ); }
     417                { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
    425418        | no_attr_identifier '.' '[' push field_list pop ']'
    426                 { $$ = new CompositeExprNode( build_fieldSel( $5, new VarRefNode( $1 ) ) ); }
     419                { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
    427420        | no_attr_identifier ARROW field
    428                 { $$ = new CompositeExprNode( build_pfieldSel( $3, new VarRefNode( $1 ) ) ); }
     421                { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
    429422        | no_attr_identifier ARROW '[' push field_list pop ']'
    430                 { $$ = new CompositeExprNode( build_pfieldSel( $5, new VarRefNode( $1 ) ) ); }
     423                { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
    431424        ;
    432425
     
    438431                { $$ = $1; }
    439432        | string_literal_list
    440                 { $$ = $1; }
     433                { $$ = new ExpressionNode( $1 ); }
    441434        | EXTENSION cast_expression                                                     // GCC
    442435                { $$ = $2->set_extension( true ); }
     
    448441                        switch ( $1 ) {
    449442                          case OperKinds::AddressOf:
    450                                 $$ = new CompositeExprNode( build_addressOf( $2 ) );
     443                                $$ = new ExpressionNode( build_addressOf( $2 ) );
    451444                                break;
    452445                          case OperKinds::PointTo:
    453                                 $$ = new CompositeExprNode( build_unary_val( $1, $2 ) );
     446                                $$ = new ExpressionNode( build_unary_val( $1, $2 ) );
    454447                                break;
    455448                          default:
     
    458451                }
    459452        | unary_operator cast_expression
    460                         { $$ = new CompositeExprNode( build_unary_val( $1, $2 ) ); }
     453                { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
    461454        | ICR unary_expression
    462                 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }
     455                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }
    463456        | DECR unary_expression
    464                 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
     457                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
    465458        | SIZEOF unary_expression
    466                 { $$ = new CompositeExprNode( build_sizeOf( $2 ) ); }
     459                { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); }
    467460        | SIZEOF '(' type_name_no_function ')'
    468                 { $$ = new CompositeExprNode( build_sizeOf( new TypeValueNode( $3 ) ) ); }
     461                { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); }
     462        | ALIGNOF unary_expression                                                      // GCC, variable alignment
     463                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
     464        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
     465                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    469466        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
    470                 { $$ = new CompositeExprNode( build_offsetOf( new TypeValueNode( $3 ), new VarRefNode( $5 ) ) ); }
     467                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    471468        | ATTR_IDENTIFIER
    472                 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ) ) ); }
     469                { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), nullptr ) ); }
     470        | ATTR_IDENTIFIER '(' argument_expression ')'
     471                { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); }
    473472        | ATTR_IDENTIFIER '(' type_name ')'
    474                 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ), new TypeValueNode( $3 ) ) ); }
    475         | ATTR_IDENTIFIER '(' argument_expression ')'
    476                 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ), $3 ) ); }
    477         | ALIGNOF unary_expression                                                      // GCC, variable alignment
    478                 { $$ = new CompositeExprNode( build_alignOf( $2 ) ); }
    479         | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    480                 { $$ = new CompositeExprNode( build_alignOf( new TypeValueNode( $3 ) ) ); }
     473                { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); }
    481474//      | ANDAND IDENTIFIER                                                                     // GCC, address of label
    482 //              { $$ = new CompositeExprNode( new OperatorNode( OperKinds::LabelAddress ), new VarRefNode( $2, true ) ); }
     475//              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); }
    483476        ;
    484477
     
    500493        unary_expression
    501494        | '(' type_name_no_function ')' cast_expression
    502                 { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }
     495                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    503496        | '(' type_name_no_function ')' tuple
    504                 { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }
     497                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    505498        ;
    506499
     
    508501        cast_expression
    509502        | multiplicative_expression '*' cast_expression
    510                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
     503                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    511504        | multiplicative_expression '/' cast_expression
    512                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
     505                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    513506        | multiplicative_expression '%' cast_expression
    514                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
     507                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    515508        ;
    516509
     
    518511        multiplicative_expression
    519512        | additive_expression '+' multiplicative_expression
    520                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
     513                { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
    521514        | additive_expression '-' multiplicative_expression
    522                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
     515                { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
    523516        ;
    524517
     
    526519        additive_expression
    527520        | shift_expression LS additive_expression
    528                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
     521                { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
    529522        | shift_expression RS additive_expression
    530                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
     523                { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
    531524        ;
    532525
     
    534527        shift_expression
    535528        | relational_expression '<' shift_expression
    536                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
     529                { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
    537530        | relational_expression '>' shift_expression
    538                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
     531                { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
    539532        | relational_expression LE shift_expression
    540                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
     533                { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
    541534        | relational_expression GE shift_expression
    542                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
     535                { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
    543536        ;
    544537
     
    546539        relational_expression
    547540        | equality_expression EQ relational_expression
    548                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
     541                { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
    549542        | equality_expression NE relational_expression
    550                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
     543                { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
    551544        ;
    552545
     
    554547        equality_expression
    555548        | AND_expression '&' equality_expression
    556                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
     549                { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
    557550        ;
    558551
     
    560553        AND_expression
    561554        | exclusive_OR_expression '^' AND_expression
    562                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
     555                { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
    563556        ;
    564557
     
    566559        exclusive_OR_expression
    567560        | inclusive_OR_expression '|' exclusive_OR_expression
    568                 { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
     561                { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
    569562        ;
    570563
     
    572565        inclusive_OR_expression
    573566        | logical_AND_expression ANDAND inclusive_OR_expression
    574                 { $$ = new CompositeExprNode( build_and_or( $1, $3, true ) ); }
     567                { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); }
    575568        ;
    576569
     
    578571        logical_AND_expression
    579572        | logical_OR_expression OROR logical_AND_expression
    580                 { $$ = new CompositeExprNode( build_and_or( $1, $3, false ) ); }
     573                { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); }
    581574        ;
    582575
     
    584577        logical_OR_expression
    585578        | logical_OR_expression '?' comma_expression ':' conditional_expression
    586                 { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }
     579                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    587580                // FIX ME: this hack computes $1 twice
    588581        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    589                 { $$ = new CompositeExprNode( build_cond( $1, $1, $4 ) ); }
     582                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
    590583        | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    591                 { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }
     584                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    592585        ;
    593586
     
    600593        conditional_expression
    601594        | unary_expression assignment_operator assignment_expression
    602                 { $$ = new CompositeExprNode( build_binary_ptr( $2, $1, $3 ) ); }
     595                { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
    603596        | tuple assignment_opt                                                          // CFA, tuple expression
    604                 { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
     597                { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
    605598        ;
    606599
    607600assignment_expression_opt:
    608601        // empty
    609                 { $$ = new NullExprNode; }
     602                { $$ = nullptr; }
    610603        | assignment_expression
    611604        ;
     
    629622                // comma_expression in new_identifier_parameter_array and new_abstract_array
    630623        '[' ']'
    631                 { $$ = new CompositeExprNode( build_tuple() ); }
     624                { $$ = new ExpressionNode( build_tuple() ); }
    632625        | '[' push assignment_expression pop ']'
    633                 { $$ = new CompositeExprNode( build_tuple( $3 ) ); }
     626                { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    634627        | '[' push ',' tuple_expression_list pop ']'
    635                 { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)(new NullExprNode)->set_link( $4 ) ) ); }
     628                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
    636629        | '[' push assignment_expression ',' tuple_expression_list pop ']'
    637                 { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)$3->set_link( $5 ) ) ); }
     630                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); }
    638631        ;
    639632
     
    641634        assignment_expression_opt
    642635        | tuple_expression_list ',' assignment_expression_opt
    643                 { $$ = (ExpressionNode *)$1->set_link( $3 ); }
     636                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    644637        ;
    645638
     
    647640        assignment_expression
    648641        | comma_expression ',' assignment_expression
    649                 { $$ = new CompositeExprNode( build_comma( $1, $3 ) ); }
     642                { $$ = new ExpressionNode( build_comma( $1, $3 ) ); }
    650643        ;
    651644
     
    671664                        Token fn;
    672665                        fn.str = new std::string( "^?{}" ); // location undefined
    673                         $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $2 )->set_link( $4 ) ) ), 0 );
     666                        $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    674667                }
    675668        ;
     
    685678compound_statement:
    686679        '{' '}'
    687                 { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
     680                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    688681        | '{'
    689682                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     
    692685          local_label_declaration_opt                                           // GCC, local labels
    693686          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    694                 { $$ = new CompoundStmtNode( $5 ); }
     687                { $$ = new StatementNode( build_compound( $5 ) ); }
    695688        ;
    696689
     
    698691        block_item
    699692        | block_item_list push block_item
    700                 { if ( $1 != 0 ) { $1->set_link( $3 ); $$ = $1; } }
     693                { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
    701694        ;
    702695
     
    706699        | EXTENSION declaration                                                         // GCC
    707700                {       // mark all fields in list
    708                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
     701                        for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
    709702                                iter->set_extension( true );
    710703                        $$ = new StatementNode( $2 );
     
    718711        statement
    719712        | statement_list statement
    720                 { if ( $1 != 0 ) { $1->set_link( $2 ); $$ = $1; } }
     713                { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
    721714        ;
    722715
    723716expression_statement:
    724717        comma_expression_opt ';'
    725                 { $$ = new StatementNode( StatementNode::Exp, $1, 0 ); }
     718                { $$ = new StatementNode( build_expr( $1 ) ); }
    726719        ;
    727720
     
    729722        IF '(' comma_expression ')' statement                           %prec THEN
    730723                // explicitly deal with the shift/reduce conflict on if/else
    731                 { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
     724                { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
    732725        | IF '(' comma_expression ')' statement ELSE statement
    733                 { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
     726                { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
    734727        | SWITCH '(' comma_expression ')' case_clause           // CFA
    735                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     728                { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    736729        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    737730                {
    738                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     731                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    739732                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    740733                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    742735                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    743736                        // statement.
    744                         $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
     737                        $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    745738                }
    746739        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    747                 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
     740                { $$ = new StatementNode( build_switch( $3, $5 ) ); }
    748741        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    749742                {
    750                         StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    751                         $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
     743                        StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     744                        $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    752745                }
    753746        ;
     
    759752        constant_expression                                                     { $$ = $1; }
    760753        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    761                 { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }
     754                { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
    762755        | subrange                                                                                      // CFA, subrange
    763756        ;
    764757
    765758case_value_list:                                                                                // CFA
    766         case_value                                                                      { $$ = new StatementNode( StatementNode::Case, $1, 0 ); }
     759        case_value                                                                      { $$ = new StatementNode( build_case( $1 ) ); }
    767760                // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5"
    768         | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); }
     761        | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); }
    769762        ;
    770763
    771764case_label:                                                                                             // CFA
    772765        CASE case_value_list ':'                                        { $$ = $2; }
    773         | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
     766        | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
    774767                // A semantic check is required to ensure only one default clause per switch/choose statement.
    775768        ;
     
    777770case_label_list:                                                                                // CFA
    778771        case_label
    779         | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_link( $2 )); }
     772        | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_last( $2 )); }
    780773        ;
    781774
    782775case_clause:                                                                                    // CFA
    783         case_label_list statement                                       { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
     776        case_label_list statement                                       { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
    784777        ;
    785778
     
    792785switch_clause_list:                                                                             // CFA
    793786        case_label_list statement_list
    794                 { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
     787                { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
    795788        | switch_clause_list case_label_list statement_list
    796                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); }
     789                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    797790        ;
    798791
     
    807800                { $$ = $1->append_last_case( $2 ); }
    808801        | case_label_list statement_list fall_through_opt
    809                 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }
     802                { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
    810803        | choose_clause_list case_label_list fall_through
    811                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
     804                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    812805        | choose_clause_list case_label_list statement_list fall_through_opt
    813                 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }
     806                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
    814807        ;
    815808
    816809fall_through_opt:                                                                               // CFA
    817810        // empty
    818                 { $$ = new StatementNode( StatementNode::Break ); }     // insert implicit break
     811                { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break
    819812        | fall_through
    820813        ;
     
    829822iteration_statement:
    830823        WHILE '(' comma_expression ')' statement
    831                 { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
     824                { $$ = new StatementNode( build_while( $3, $5 ) ); }
    832825        | DO statement WHILE '(' comma_expression ')' ';'
    833                 { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
     826                { $$ = new StatementNode( build_while( $5, $2 ) ); }
    834827        | FOR '(' push for_control_expression ')' statement
    835                 { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
     828                { $$ = new StatementNode( build_for( $4, $6 ) ); }
    836829        ;
    837830
    838831for_control_expression:
    839832        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    840                 { $$ = new ForCtlExprNode( $1, $4, $6 ); }
     833                { $$ = new ForCtl( $1, $4, $6 ); }
    841834        | declaration comma_expression_opt ';' comma_expression_opt // C99
    842                 { $$ = new ForCtlExprNode( $1, $2, $4 ); }
    843         ;
     835                { $$ = new ForCtl( $1, $2, $4 ); }
     836        ;
    844837
    845838jump_statement:
    846839        GOTO IDENTIFIER ';'
    847                 { $$ = new StatementNode( StatementNode::Goto, $2 ); }
     840                { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Goto ) ); }
    848841        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    849842                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
    850843                // whereas normal operator precedence yields goto (*i)+3;
    851                 { $$ = new StatementNode( StatementNode::Goto, $3 ); }
     844                { $$ = new StatementNode( build_computedgoto( $3 ) ); }
    852845        | CONTINUE ';'
    853846                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    854                 { $$ = new StatementNode( StatementNode::Continue ); }
     847                { $$ = new StatementNode( build_branch( "", BranchStmt::Continue ) ); }
    855848        | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
    856849                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    857850                // the target of the transfer appears only at the start of an iteration statement.
    858                 { $$ = new StatementNode( StatementNode::Continue, $2 ); }
     851                { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Continue ) ); }
    859852        | BREAK ';'
    860853                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    861                 { $$ = new StatementNode( StatementNode::Break ); }
     854                { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); }
    862855        | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
    863856                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    864857                // the target of the transfer appears only at the start of an iteration statement.
    865                 { $$ = new StatementNode( StatementNode::Break, $2 ); }
     858                { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Break ) ); }
    866859        | RETURN comma_expression_opt ';'
    867                 { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
    868         | THROW assignment_expression_opt ';'
    869                 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    870 //      | THROW ';'
    871 //              { $$ = new StatementNode( StatementNode::Throw ); }
    872         | THROWRESUME assignment_expression_opt ';'
    873                 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    874         | THROWRESUME assignment_expression_opt AT assignment_expression ';'
    875                 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    876 //      | THROWRESUME ';'
    877 //              { $$ = new StatementNode( StatementNode::Throw ); }
     860                { $$ = new StatementNode( build_return( $2 ) ); }
     861        | THROW assignment_expression_opt ';'                           // handles rethrow
     862                { $$ = new StatementNode( build_throw( $2 ) ); }
     863        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
     864                { $$ = new StatementNode( build_throw( $2 ) ); }
     865        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
     866                { $$ = new StatementNode( build_throw( $2 ) ); }
    878867        ;
    879868
    880869exception_statement:
    881870        TRY compound_statement handler_list
    882                 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
     871                { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
    883872        | TRY compound_statement finally_clause
    884                 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
     873                { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
    885874        | TRY compound_statement handler_list finally_clause
    886                 {
    887                         $3->set_link( $4 );
    888                         $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 ))));
    889                 }
     875                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
    890876        ;
    891877
    892878handler_list:
    893                 // There must be at least one catch clause
    894879        handler_clause
    895880                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    896881        | CATCH '(' ELLIPSIS ')' compound_statement
    897                 { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     882                { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    898883        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    899                 { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
     884                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    900885        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    901                 { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     886                { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    902887        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    903                 { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
     888                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    904889        ;
    905890
    906891handler_clause:
    907892        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    908                 { $$ = StatementNode::newCatchStmt( $5, $8 ); }
     893                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    909894        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    910                 { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
     895        { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    911896        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    912                 { $$ = StatementNode::newCatchStmt( $5, $8 ); }
     897                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    913898        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    914                 { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
     899                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    915900        ;
    916901
     
    918903        FINALLY compound_statement
    919904                {
    920                         $$ = new StatementNode( StatementNode::Finally, 0, $2 );
    921                         std::cout << "Just created a finally node" << std::endl;
     905                        $$ = new StatementNode( build_finally( $2 ) );
    922906                }
    923907        ;
     
    947931asm_statement:
    948932        ASM asm_volatile_opt '(' string_literal_list ')' ';'
    949                 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
     933                { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); }
    950934        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
    951                 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
     935                { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); }
    952936        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    953                 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
     937                { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); }
    954938        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    955                 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
     939                { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); }
    956940        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    957         { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
     941                { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); }
    958942        ;
    959943
     
    974958        asm_operand
    975959        | asm_operands_list ',' asm_operand
    976                 { $$ = (ExpressionNode *)$1->set_link( $3 ); }
     960                { $$ = (ExpressionNode *)$1->set_last( $3 ); }
    977961        ;
    978962
    979963asm_operand:                                                                                    // GCC
    980964        string_literal_list '(' constant_expression ')'
    981                 { $$ = new AsmExprNode( 0, $1, $3 ); }
     965                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    982966        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
    983                 { $$ = new AsmExprNode( $2, $4, $6 ); }
     967        { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    984968        ;
    985969
     
    988972                { $$ = 0; }                                                                             // use default argument
    989973        | string_literal_list
    990                 { $$ = $1; }
     974                { $$ = new ExpressionNode( $1 ); }
    991975        | asm_clobbers_list_opt ',' string_literal_list
    992                 { $$ = (ConstantNode *)$1->set_link( $3 ); }
     976                { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
    993977        ;
    994978
    995979label_list:
    996980        no_attr_identifier
    997                 { $$ = new LabelNode(); $$->append_label( $1 ); }
     981                { $$ = new LabelNode(); $$->labels.push_back( assign_strptr($1) ); }
    998982        | label_list ',' no_attr_identifier
    999                 { $$ = $1; $1->append_label( $3 ); }
     983                { $$ = $1; $1->labels.push_back( assign_strptr($3) ); }
    1000984        ;
    1001985
     
    13401324
    13411325storage_class:
    1342         storage_class_name
    1343         ;
    1344 
    1345 storage_class_name:
    13461326        EXTERN
    13471327                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
     
    15131493        | EXTENSION field_declaring_list ';'                            // GCC
    15141494                {       // mark all fields in list
    1515                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
     1495                        for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
    15161496                                iter->set_extension( true );
    15171497                        $$ = $2;
     
    17591739        | initializer
    17601740        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    1761         | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
     1741        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    17621742        | initializer_list ',' designation initializer
    1763                 { $$ = (InitializerNode *)( $1->set_link( $4->set_designators( $3 ) ) ); }
     1743                { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
    17641744        ;
    17651745
     
    17771757        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    17781758        | no_attr_identifier_or_type_name ':'                           // GCC, field name
    1779                 { $$ = new VarRefNode( $1 ); }
     1759                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    17801760        ;
    17811761
     
    17831763        designator
    17841764        | designator_list designator
    1785                 { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
    1786         //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
     1765                { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
     1766        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    17871767        ;
    17881768
    17891769designator:
    1790                 // lexer ambiguity: designator ".0" is floating-point constant or designator for name 0 only ".0" and ".1"
    1791                 // allowed => semantic check
    1792         FLOATINGconstant
    1793                 { $$ = new DesignatorNode( new VarRefNode( $1 ) ); }
    1794         | '.' no_attr_identifier_or_type_name                           // C99, field name
    1795                 { $$ = new DesignatorNode( new VarRefNode( $2 ) ); }
     1770        '.' no_attr_identifier_or_type_name                                     // C99, field name
     1771                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    17961772        | '[' push assignment_expression pop ']'                        // C99, single array element
    17971773                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1798                 { $$ = new DesignatorNode( $3, true ); }
     1774                { $$ = $3; }
    17991775        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1800                 { $$ = new DesignatorNode( $3, true ); }
     1776                { $$ = $3; }
    18011777        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1802                 { $$ = new DesignatorNode( new CompositeExprNode( build_range( $3, $5 ) ), true ); }
     1778                { $$ = new ExpressionNode( build_range( $3, $5 ) ); }
    18031779        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1804                 { $$ = new DesignatorNode( $4 ); }
     1780                { $$ = $4; }
    18051781        ;
    18061782
     
    18901866type_name_list:                                                                                 // CFA
    18911867        type_name
    1892                 { $$ = new TypeValueNode( $1 ); }
     1868                { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
    18931869        | assignment_expression
    18941870        | type_name_list ',' type_name
    1895                 { $$ = (ExpressionNode *)( $1->set_link( new TypeValueNode( $3 ))); }
     1871                { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
    18961872        | type_name_list ',' assignment_expression
    1897                 { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
     1873                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
    18981874        ;
    18991875
     
    19941970                {}                                                                                              // empty input file
    19951971        | external_definition_list
    1996                 {
    1997                         if ( theTree ) {
    1998                                 theTree->appendList( $1 );
    1999                         } else {
    2000                                 theTree = $1;
    2001                         }
    2002                 }
     1972                { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1;  }
    20031973        ;
    20041974
     
    20061976        external_definition
    20071977        | external_definition_list push external_definition
    2008                 { $$ = ( $1 != NULL ) ? $1->appendList( $3 ) : $3; }
     1978                { $$ = $1 != nullptr ? $1->appendList( $3 ) : $3; }
    20091979        ;
    20101980
     
    20221992        | EXTERN STRINGliteral
    20231993                {
    2024                         linkageStack.push( linkage );
    2025                         linkage = LinkageSpec::fromString( *$2 );
     1994                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     1995                        linkage = LinkageSpec::fromString( assign_strptr($2) );
    20261996                }
    20271997          '{' external_definition_list_opt '}'                          // C++-style linkage specifier
     
    20332003        | EXTENSION external_definition
    20342004                {       // mark all fields in list
    2035                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
     2005                        for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
    20362006                                iter->set_extension( true );
    20372007                        $$ = $2;
     
    21292099subrange:
    21302100        constant_expression '~' constant_expression                     // CFA, integer subrange
    2131                 { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }
     2101                { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
    21322102        ;
    21332103
     
    21682138any_word:                                                                                               // GCC
    21692139        identifier_or_type_name {}
    2170         | storage_class_name {}
     2140        | storage_class {}
    21712141        | basic_type_name {}
    21722142        | type_qualifier {}
     
    28682838// ----end of grammar----
    28692839
     2840extern char *yytext;
     2841
    28702842void yyerror( const char * ) {
    28712843        std::cout << "Error ";
Note: See TracChangeset for help on using the changeset viewer.