Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rac71a86 r7bf7fb9  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 18 23:49:10 2016
    13 // Update Count     : 1909
     12// Last Modified On : Sun Aug  7 09:37:48 2016
     13// Update Count     : 1764
    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
     45extern char *yytext;
    4546
    4647#undef __GNUC_MINOR__
     
    5556#include "LinkageSpec.h"
    5657
    57 extern DeclarationNode * parseTree;
    58 extern LinkageSpec::Spec linkage;
    59 extern TypedefTable typedefTable;
    60 
    61 std::stack< LinkageSpec::Spec > linkageStack;
     58DeclarationNode *theTree = 0;                                                   // the resulting parse tree
     59LinkageSpec::Type linkage = LinkageSpec::Cforall;
     60std::stack< LinkageSpec::Type > linkageStack;
     61TypedefTable typedefTable;
    6262
    6363void appendStr( std::string &to, std::string *from ) {
     
    121121        DeclarationNode::TypeClass tclass;
    122122        StatementNode *sn;
    123         ConstantExpr *constant;
    124         ForCtl *fctl;
     123        ConstantNode *constant;
    125124        LabelNode *label;
    126125        InitializerNode *in;
     
    134133
    135134// expressions
    136 %type<en> constant
     135%type<constant> constant
    137136%type<en> tuple                                                 tuple_expression_list
    138137%type<op> ptrref_operator                               unary_operator                          assignment_operator
     
    143142%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    144143%type<en> comma_expression                              comma_expression_opt
    145 %type<en> argument_expression_list              argument_expression                     assignment_opt
    146 %type<fctl> for_control_expression
     144%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    147145%type<en> subrange
    148146%type<en> asm_operands_opt asm_operands_list asm_operand
    149147%type<label> label_list
    150 %type<en> asm_clobbers_list_opt
     148%type<constant> asm_clobbers_list_opt
    151149%type<flag> asm_volatile_opt
    152150
     
    161159%type<sn> case_value_list                               case_label                                      case_label_list
    162160%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    163 %type<sn> handler_list                                  handler_clause                          finally_clause
     161%type<pn> handler_list                                  handler_clause                          finally_clause
    164162
    165163// declarations
     
    223221%type<decl> paren_identifier paren_type
    224222
    225 %type<decl> storage_class storage_class_list
     223%type<decl> storage_class storage_class_name storage_class_list
    226224
    227225%type<decl> sue_declaration_specifier sue_type_specifier
     
    311309constant:
    312310                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    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) ) ); }
     311INTEGERconstant                                                                 { $$ = build_constantInteger( *$1 ); }
     312        | FLOATINGconstant                                                      { $$ = build_constantFloat( *$1 ); }
     313        | CHARACTERconstant                                                     { $$ = build_constantChar( *$1 ); }
    316314        ;
    317315
     
    338336
    339337string_literal_list:                                                                    // juxtaposed strings are concatenated
    340         STRINGliteral                                                           { $$ = build_constantStr( assign_strptr($1) ); }
     338        STRINGliteral                                                           { $$ = build_constantStr( *$1 ); }
    341339        | string_literal_list STRINGliteral
    342340                {
    343                         appendStr( $1->get_constant()->get_value(), $2 );
     341                        appendStr( $1->get_expr()->get_constant()->get_value(), $2 );
    344342                        delete $2;                                                                      // allocated by lexer
    345343                        $$ = $1;
     
    351349primary_expression:
    352350        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    353                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     351                { $$ = new VarRefNode( $1 ); }
    354352        | zero_one
    355                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     353                { $$ = new VarRefNode( $1 ); }
    356354        | '(' comma_expression ')'
    357355                { $$ = $2; }
    358356        | '(' compound_statement ')'                                            // GCC, lambda expression
    359         { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     357                { $$ = new ValofExprNode( $2 ); }
    360358        ;
    361359
     
    367365                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
    368366                // equivalent to the old x[i,j].
    369                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
     367                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
    370368        | postfix_expression '(' argument_expression_list ')'
    371                 { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     369                { $$ = new CompositeExprNode( build_func( $1, $3 ) ); }
    372370        // ambiguity with .0 so space required after field-selection, e.g.
    373371                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    374372        | postfix_expression '.' no_attr_identifier
    375                 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     373                { $$ = new CompositeExprNode( build_fieldSel( $1, new VarRefNode( $3 ) ) ); }
    376374        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    377375        | postfix_expression ARROW no_attr_identifier
    378                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     376                { $$ = new CompositeExprNode( build_pfieldSel( $1, new VarRefNode( $3 ) ) ); }
    379377        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    380378        | postfix_expression ICR
    381                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     379                { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
    382380        | postfix_expression DECR
    383                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
     381                { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
    384382        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
    385                 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     383                { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); }
    386384        | postfix_expression '{' argument_expression_list '}' // CFA
    387385                {
    388386                        Token fn;
    389387                        fn.str = new std::string( "?{}" ); // location undefined
    390                         $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) );
     388                        $$ = new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $1 )->set_link( $3 ) ) );
    391389                }
    392390        ;
     
    395393        argument_expression
    396394        | argument_expression_list ',' argument_expression
    397                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     395                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    398396        ;
    399397
     
    402400                { $$ = 0; }                                                                             // use default argument
    403401        | 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 ) ) ) ); }
    404411        ;
    405412
    406413field_list:                                                                                             // CFA, tuple field selector
    407414        field
    408         | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     415        | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    409416        ;
    410417
    411418field:                                                                                                  // CFA, tuple field selector
    412419        no_attr_identifier
    413                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     420                { $$ = new VarRefNode( $1 ); }
    414421        // ambiguity with .0 so space required after field-selection, e.g.
    415422                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    416423        | no_attr_identifier '.' field
    417                 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     424                { $$ = new CompositeExprNode( build_fieldSel( $3, new VarRefNode( $1 ) ) ); }
    418425        | no_attr_identifier '.' '[' push field_list pop ']'
    419                 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
     426                { $$ = new CompositeExprNode( build_fieldSel( $5, new VarRefNode( $1 ) ) ); }
    420427        | no_attr_identifier ARROW field
    421                 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
     428                { $$ = new CompositeExprNode( build_pfieldSel( $3, new VarRefNode( $1 ) ) ); }
    422429        | no_attr_identifier ARROW '[' push field_list pop ']'
    423                 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     430                { $$ = new CompositeExprNode( build_pfieldSel( $5, new VarRefNode( $1 ) ) ); }
    424431        ;
    425432
     
    431438                { $$ = $1; }
    432439        | string_literal_list
    433                 { $$ = new ExpressionNode( $1 ); }
     440                { $$ = $1; }
    434441        | EXTENSION cast_expression                                                     // GCC
    435442                { $$ = $2->set_extension( true ); }
     
    441448                        switch ( $1 ) {
    442449                          case OperKinds::AddressOf:
    443                                 $$ = new ExpressionNode( build_addressOf( $2 ) );
     450                                $$ = new CompositeExprNode( build_addressOf( $2 ) );
    444451                                break;
    445452                          case OperKinds::PointTo:
    446                                 $$ = new ExpressionNode( build_unary_val( $1, $2 ) );
     453                                $$ = new CompositeExprNode( build_unary_val( $1, $2 ) );
    447454                                break;
    448455                          default:
     
    451458                }
    452459        | unary_operator cast_expression
    453                 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
     460                        { $$ = new CompositeExprNode( build_unary_val( $1, $2 ) ); }
    454461        | ICR unary_expression
    455                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }
     462                { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }
    456463        | DECR unary_expression
    457                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
     464                { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
    458465        | SIZEOF unary_expression
    459                 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); }
     466                { $$ = new CompositeExprNode( build_sizeOf( $2 ) ); }
    460467        | SIZEOF '(' type_name_no_function ')'
    461                 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); }
     468                { $$ = new CompositeExprNode( build_sizeOf( new TypeValueNode( $3 ) ) ); }
     469        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
     470                { $$ = new CompositeExprNode( build_offsetOf( new TypeValueNode( $3 ), new VarRefNode( $5 ) ) ); }
     471        | ATTR_IDENTIFIER
     472                { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ) ) ); }
     473        | 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 ) ); }
    462477        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    463                 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
     478                { $$ = new CompositeExprNode( build_alignOf( $2 ) ); }
    464479        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    465                 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    466         | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
    467                 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    468         | ATTR_IDENTIFIER
    469                 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), nullptr ) ); }
    470         | ATTR_IDENTIFIER '(' argument_expression ')'
    471                 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); }
    472         | ATTR_IDENTIFIER '(' type_name ')'
    473                 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); }
     480                { $$ = new CompositeExprNode( build_alignOf( new TypeValueNode( $3 ) ) ); }
    474481//      | ANDAND IDENTIFIER                                                                     // GCC, address of label
    475 //              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); }
     482//              { $$ = new CompositeExprNode( new OperatorNode( OperKinds::LabelAddress ), new VarRefNode( $2, true ) ); }
    476483        ;
    477484
     
    493500        unary_expression
    494501        | '(' type_name_no_function ')' cast_expression
    495                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     502                { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }
    496503        | '(' type_name_no_function ')' tuple
    497                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     504                { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }
    498505        ;
    499506
     
    501508        cast_expression
    502509        | multiplicative_expression '*' cast_expression
    503                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
     510                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    504511        | multiplicative_expression '/' cast_expression
    505                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
     512                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    506513        | multiplicative_expression '%' cast_expression
    507                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
     514                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    508515        ;
    509516
     
    511518        multiplicative_expression
    512519        | additive_expression '+' multiplicative_expression
    513                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
     520                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
    514521        | additive_expression '-' multiplicative_expression
    515                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
     522                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
    516523        ;
    517524
     
    519526        additive_expression
    520527        | shift_expression LS additive_expression
    521                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
     528                { $$ = new CompositeExprNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
    522529        | shift_expression RS additive_expression
    523                 { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
     530                { $$ = new CompositeExprNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
    524531        ;
    525532
     
    527534        shift_expression
    528535        | relational_expression '<' shift_expression
    529                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
     536                { $$ = new CompositeExprNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
    530537        | relational_expression '>' shift_expression
    531                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
     538                { $$ = new CompositeExprNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
    532539        | relational_expression LE shift_expression
    533                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
     540                { $$ = new CompositeExprNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
    534541        | relational_expression GE shift_expression
    535                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
     542                { $$ = new CompositeExprNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
    536543        ;
    537544
     
    539546        relational_expression
    540547        | equality_expression EQ relational_expression
    541                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
     548                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
    542549        | equality_expression NE relational_expression
    543                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
     550                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
    544551        ;
    545552
     
    547554        equality_expression
    548555        | AND_expression '&' equality_expression
    549                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
     556                { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
    550557        ;
    551558
     
    553560        AND_expression
    554561        | exclusive_OR_expression '^' AND_expression
    555                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
     562                { $$ = new CompositeExprNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
    556563        ;
    557564
     
    559566        exclusive_OR_expression
    560567        | inclusive_OR_expression '|' exclusive_OR_expression
    561                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
     568                { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
    562569        ;
    563570
     
    565572        inclusive_OR_expression
    566573        | logical_AND_expression ANDAND inclusive_OR_expression
    567                 { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); }
     574                { $$ = new CompositeExprNode( build_and_or( $1, $3, true ) ); }
    568575        ;
    569576
     
    571578        logical_AND_expression
    572579        | logical_OR_expression OROR logical_AND_expression
    573                 { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); }
     580                { $$ = new CompositeExprNode( build_and_or( $1, $3, false ) ); }
    574581        ;
    575582
     
    577584        logical_OR_expression
    578585        | logical_OR_expression '?' comma_expression ':' conditional_expression
    579                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
     586                { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }
    580587                // FIX ME: this hack computes $1 twice
    581588        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    582                 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     589                { $$ = new CompositeExprNode( build_cond( $1, $1, $4 ) ); }
    583590        | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    584                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
     591                { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }
    585592        ;
    586593
     
    593600        conditional_expression
    594601        | unary_expression assignment_operator assignment_expression
    595                 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
     602                { $$ = new CompositeExprNode( build_binary_ptr( $2, $1, $3 ) ); }
    596603        | tuple assignment_opt                                                          // CFA, tuple expression
    597                 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
     604                { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
    598605        ;
    599606
    600607assignment_expression_opt:
    601608        // empty
    602                 { $$ = nullptr; }
     609                { $$ = new NullExprNode; }
    603610        | assignment_expression
    604611        ;
     
    622629                // comma_expression in new_identifier_parameter_array and new_abstract_array
    623630        '[' ']'
    624                 { $$ = new ExpressionNode( build_tuple() ); }
     631                { $$ = new CompositeExprNode( build_tuple() ); }
    625632        | '[' push assignment_expression pop ']'
    626                 { $$ = new ExpressionNode( build_tuple( $3 ) ); }
     633                { $$ = new CompositeExprNode( build_tuple( $3 ) ); }
    627634        | '[' push ',' tuple_expression_list pop ']'
    628                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
     635                { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)(new NullExprNode)->set_link( $4 ) ) ); }
    629636        | '[' push assignment_expression ',' tuple_expression_list pop ']'
    630                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); }
     637                { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)$3->set_link( $5 ) ) ); }
    631638        ;
    632639
     
    634641        assignment_expression_opt
    635642        | tuple_expression_list ',' assignment_expression_opt
    636                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     643                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    637644        ;
    638645
     
    640647        assignment_expression
    641648        | comma_expression ',' assignment_expression
    642                 { $$ = new ExpressionNode( build_comma( $1, $3 ) ); }
     649                { $$ = new CompositeExprNode( build_comma( $1, $3 ) ); }
    643650        ;
    644651
     
    664671                        Token fn;
    665672                        fn.str = new std::string( "^?{}" ); // location undefined
    666                         $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
     673                        $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $2 )->set_link( $4 ) ) ), 0 );
    667674                }
    668675        ;
     
    678685compound_statement:
    679686        '{' '}'
    680                 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     687                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    681688        | '{'
    682689                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     
    685692          local_label_declaration_opt                                           // GCC, local labels
    686693          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    687                 { $$ = new StatementNode( build_compound( $5 ) ); }
     694                { $$ = new CompoundStmtNode( $5 ); }
    688695        ;
    689696
     
    691698        block_item
    692699        | block_item_list push block_item
    693                 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
     700                { if ( $1 != 0 ) { $1->set_link( $3 ); $$ = $1; } }
    694701        ;
    695702
     
    699706        | EXTENSION declaration                                                         // GCC
    700707                {       // mark all fields in list
    701                         for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     708                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    702709                                iter->set_extension( true );
    703710                        $$ = new StatementNode( $2 );
     
    711718        statement
    712719        | statement_list statement
    713                 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
     720                { if ( $1 != 0 ) { $1->set_link( $2 ); $$ = $1; } }
    714721        ;
    715722
    716723expression_statement:
    717724        comma_expression_opt ';'
    718                 { $$ = new StatementNode( build_expr( $1 ) ); }
     725                { $$ = new StatementNode( StatementNode::Exp, $1, 0 ); }
    719726        ;
    720727
     
    722729        IF '(' comma_expression ')' statement                           %prec THEN
    723730                // explicitly deal with the shift/reduce conflict on if/else
    724                 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
     731                { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
    725732        | IF '(' comma_expression ')' statement ELSE statement
    726                 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
     733                { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
    727734        | SWITCH '(' comma_expression ')' case_clause           // CFA
    728                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     735                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    729736        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    730737                {
    731                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     738                        StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    732739                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    733740                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    735742                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    736743                        // statement.
    737                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     744                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    738745                }
    739746        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    740                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     747                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    741748        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    742749                {
    743                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    744                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     750                        StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     751                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    745752                }
    746753        ;
     
    752759        constant_expression                                                     { $$ = $1; }
    753760        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    754                 { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
     761                { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }
    755762        | subrange                                                                                      // CFA, subrange
    756763        ;
    757764
    758765case_value_list:                                                                                // CFA
    759         case_value                                                                      { $$ = new StatementNode( build_case( $1 ) ); }
     766        case_value                                                                      { $$ = new StatementNode( StatementNode::Case, $1, 0 ); }
    760767                // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5"
    761         | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); }
     768        | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); }
    762769        ;
    763770
    764771case_label:                                                                                             // CFA
    765772        CASE case_value_list ':'                                        { $$ = $2; }
    766         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
     773        | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
    767774                // A semantic check is required to ensure only one default clause per switch/choose statement.
    768775        ;
     
    770777case_label_list:                                                                                // CFA
    771778        case_label
    772         | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_last( $2 )); }
     779        | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_link( $2 )); }
    773780        ;
    774781
    775782case_clause:                                                                                    // CFA
    776         case_label_list statement                                       { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     783        case_label_list statement                                       { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    777784        ;
    778785
     
    785792switch_clause_list:                                                                             // CFA
    786793        case_label_list statement_list
    787                 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     794                { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    788795        | switch_clause_list case_label_list statement_list
    789                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     796                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); }
    790797        ;
    791798
     
    800807                { $$ = $1->append_last_case( $2 ); }
    801808        | case_label_list statement_list fall_through_opt
    802                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
     809                { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }
    803810        | choose_clause_list case_label_list fall_through
    804                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
     811                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    805812        | choose_clause_list case_label_list statement_list fall_through_opt
    806                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
     813                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }
    807814        ;
    808815
    809816fall_through_opt:                                                                               // CFA
    810817        // empty
    811                 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break
     818                { $$ = new StatementNode( StatementNode::Break ); }     // insert implicit break
    812819        | fall_through
    813820        ;
     
    822829iteration_statement:
    823830        WHILE '(' comma_expression ')' statement
    824                 { $$ = new StatementNode( build_while( $3, $5 ) ); }
     831                { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
    825832        | DO statement WHILE '(' comma_expression ')' ';'
    826                 { $$ = new StatementNode( build_while( $5, $2 ) ); }
     833                { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
    827834        | FOR '(' push for_control_expression ')' statement
    828                 { $$ = new StatementNode( build_for( $4, $6 ) ); }
     835                { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
    829836        ;
    830837
    831838for_control_expression:
    832839        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    833                 { $$ = new ForCtl( $1, $4, $6 ); }
     840                { $$ = new ForCtlExprNode( $1, $4, $6 ); }
    834841        | declaration comma_expression_opt ';' comma_expression_opt // C99
    835                 { $$ = new ForCtl( $1, $2, $4 ); }
    836         ;
     842                { $$ = new ForCtlExprNode( $1, $2, $4 ); }
     843        ;
    837844
    838845jump_statement:
    839846        GOTO IDENTIFIER ';'
    840                 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Goto ) ); }
     847                { $$ = new StatementNode( StatementNode::Goto, $2 ); }
    841848        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    842849                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
    843850                // whereas normal operator precedence yields goto (*i)+3;
    844                 { $$ = new StatementNode( build_computedgoto( $3 ) ); }
     851                { $$ = new StatementNode( StatementNode::Goto, $3 ); }
    845852        | CONTINUE ';'
    846853                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    847                 { $$ = new StatementNode( build_branch( "", BranchStmt::Continue ) ); }
     854                { $$ = new StatementNode( StatementNode::Continue ); }
    848855        | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
    849856                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    850857                // the target of the transfer appears only at the start of an iteration statement.
    851                 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Continue ) ); }
     858                { $$ = new StatementNode( StatementNode::Continue, $2 ); }
    852859        | BREAK ';'
    853860                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    854                 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); }
     861                { $$ = new StatementNode( StatementNode::Break ); }
    855862        | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
    856863                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    857864                // the target of the transfer appears only at the start of an iteration statement.
    858                 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Break ) ); }
     865                { $$ = new StatementNode( StatementNode::Break, $2 ); }
    859866        | RETURN comma_expression_opt ';'
    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 ) ); }
     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 ); }
    867878        ;
    868879
    869880exception_statement:
    870881        TRY compound_statement handler_list
    871                 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
     882                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    872883        | TRY compound_statement finally_clause
    873                 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
     884                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    874885        | TRY compound_statement handler_list finally_clause
    875                 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
     886                {
     887                        $3->set_link( $4 );
     888                        $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 ))));
     889                }
    876890        ;
    877891
    878892handler_list:
     893                // There must be at least one catch clause
    879894        handler_clause
    880895                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    881896        | CATCH '(' ELLIPSIS ')' compound_statement
    882                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     897                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
    883898        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    884                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     899                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
    885900        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    886                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     901                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
    887902        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    888                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     903                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
    889904        ;
    890905
    891906handler_clause:
    892907        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    893                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     908                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    894909        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    895         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     910                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    896911        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    897                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     912                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    898913        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    899                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     914                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    900915        ;
    901916
     
    903918        FINALLY compound_statement
    904919                {
    905                         $$ = new StatementNode( build_finally( $2 ) );
     920                        $$ = new StatementNode( StatementNode::Finally, 0, $2 );
     921                        std::cout << "Just created a finally node" << std::endl;
    906922                }
    907923        ;
     
    931947asm_statement:
    932948        ASM asm_volatile_opt '(' string_literal_list ')' ';'
    933                 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); }
     949                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
    934950        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
    935                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); }
     951                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
    936952        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    937                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); }
     953                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
    938954        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    939                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); }
     955                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
    940956        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    941                 { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); }
     957        { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
    942958        ;
    943959
     
    958974        asm_operand
    959975        | asm_operands_list ',' asm_operand
    960                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     976                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    961977        ;
    962978
    963979asm_operand:                                                                                    // GCC
    964980        string_literal_list '(' constant_expression ')'
    965                 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
     981                { $$ = new AsmExprNode( 0, $1, $3 ); }
    966982        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
    967         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     983                { $$ = new AsmExprNode( $2, $4, $6 ); }
    968984        ;
    969985
     
    972988                { $$ = 0; }                                                                             // use default argument
    973989        | string_literal_list
    974                 { $$ = new ExpressionNode( $1 ); }
     990                { $$ = $1; }
    975991        | asm_clobbers_list_opt ',' string_literal_list
    976                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     992                { $$ = (ConstantNode *)$1->set_link( $3 ); }
    977993        ;
    978994
    979995label_list:
    980996        no_attr_identifier
    981                 { $$ = new LabelNode(); $$->labels.push_back( assign_strptr($1) ); }
     997                { $$ = new LabelNode(); $$->append_label( $1 ); }
    982998        | label_list ',' no_attr_identifier
    983                 { $$ = $1; $1->labels.push_back( assign_strptr($3) ); }
     999                { $$ = $1; $1->append_label( $3 ); }
    9841000        ;
    9851001
     
    13241340
    13251341storage_class:
     1342        storage_class_name
     1343        ;
     1344
     1345storage_class_name:
    13261346        EXTERN
    13271347                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); }
     
    14931513        | EXTENSION field_declaring_list ';'                            // GCC
    14941514                {       // mark all fields in list
    1495                         for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     1515                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    14961516                                iter->set_extension( true );
    14971517                        $$ = $2;
     
    17391759        | initializer
    17401760        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    1741         | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
     1761        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
    17421762        | initializer_list ',' designation initializer
    1743                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     1763                { $$ = (InitializerNode *)( $1->set_link( $4->set_designators( $3 ) ) ); }
    17441764        ;
    17451765
     
    17571777        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    17581778        | no_attr_identifier_or_type_name ':'                           // GCC, field name
    1759                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     1779                { $$ = new VarRefNode( $1 ); }
    17601780        ;
    17611781
     
    17631783        designator
    17641784        | designator_list designator
    1765                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
    1766         //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
     1785                { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
     1786        //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
    17671787        ;
    17681788
    17691789designator:
    1770         '.' no_attr_identifier_or_type_name                                     // C99, field name
    1771                 { $$ = new ExpressionNode( build_varref( $2 ) ); }
     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 ) ); }
    17721796        | '[' push assignment_expression pop ']'                        // C99, single array element
    17731797                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1774                 { $$ = $3; }
     1798                { $$ = new DesignatorNode( $3, true ); }
    17751799        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1776                 { $$ = $3; }
     1800                { $$ = new DesignatorNode( $3, true ); }
    17771801        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1778                 { $$ = new ExpressionNode( build_range( $3, $5 ) ); }
     1802                { $$ = new DesignatorNode( new CompositeExprNode( build_range( $3, $5 ) ), true ); }
    17791803        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1780                 { $$ = $4; }
     1804                { $$ = new DesignatorNode( $4 ); }
    17811805        ;
    17821806
     
    18661890type_name_list:                                                                                 // CFA
    18671891        type_name
    1868                 { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
     1892                { $$ = new TypeValueNode( $1 ); }
    18691893        | assignment_expression
    18701894        | type_name_list ',' type_name
    1871                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
     1895                { $$ = (ExpressionNode *)( $1->set_link( new TypeValueNode( $3 ))); }
    18721896        | type_name_list ',' assignment_expression
    1873                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     1897                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    18741898        ;
    18751899
     
    19701994                {}                                                                                              // empty input file
    19711995        | external_definition_list
    1972                 { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1;  }
     1996                {
     1997                        if ( theTree ) {
     1998                                theTree->appendList( $1 );
     1999                        } else {
     2000                                theTree = $1;
     2001                        }
     2002                }
    19732003        ;
    19742004
     
    19762006        external_definition
    19772007        | external_definition_list push external_definition
    1978                 { $$ = $1 != nullptr ? $1->appendList( $3 ) : $3; }
     2008                { $$ = ( $1 != NULL ) ? $1->appendList( $3 ) : $3; }
    19792009        ;
    19802010
     
    19922022        | EXTERN STRINGliteral
    19932023                {
    1994                         linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    1995                         linkage = LinkageSpec::fromString( assign_strptr($2) );
     2024                        linkageStack.push( linkage );
     2025                        linkage = LinkageSpec::fromString( *$2 );
    19962026                }
    19972027          '{' external_definition_list_opt '}'                          // C++-style linkage specifier
     
    20032033        | EXTENSION external_definition
    20042034                {       // mark all fields in list
    2005                         for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() )
     2035                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    20062036                                iter->set_extension( true );
    20072037                        $$ = $2;
     
    20992129subrange:
    21002130        constant_expression '~' constant_expression                     // CFA, integer subrange
    2101                 { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
     2131                { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }
    21022132        ;
    21032133
     
    21382168any_word:                                                                                               // GCC
    21392169        identifier_or_type_name {}
    2140         | storage_class {}
     2170        | storage_class_name {}
    21412171        | basic_type_name {}
    21422172        | type_qualifier {}
     
    28382868// ----end of grammar----
    28392869
    2840 extern char *yytext;
    2841 
    28422870void yyerror( const char * ) {
    28432871        std::cout << "Error ";
Note: See TracChangeset for help on using the changeset viewer.