Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    re82aa9df r5d125e4  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 15:18:19 2016
    13 // Update Count     : 1891
     12// Last Modified On : Tue Jul 12 20:52:53 2016
     13// Update Count     : 1661
    1414//
    1515
     
    6060std::stack< LinkageSpec::Type > linkageStack;
    6161TypedefTable typedefTable;
    62 
    63 void appendStr( std::string &to, std::string *from ) {
    64         // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    65         to.insert( to.length() - 1, from->substr( 1, from->length() - 2 ) );
    66 } // appendStr
    6762%}
    6863
     
    121116        DeclarationNode::TypeClass tclass;
    122117        StatementNode *sn;
    123         ConstantExpr *constant;
    124         ForCtl *fctl;
     118        ConstantNode *constant;
    125119        LabelNode *label;
    126120        InitializerNode *in;
    127         OperKinds op;
    128121        bool flag;
    129122}
     
    134127
    135128// expressions
    136 %type<en> constant
     129%type<constant> constant
    137130%type<en> tuple                                                 tuple_expression_list
    138 %type<op> ptrref_operator                               unary_operator                          assignment_operator
     131%type<en> ptrref_operator                               unary_operator                          assignment_operator
    139132%type<en> primary_expression                    postfix_expression                      unary_expression
    140133%type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
     
    143136%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    144137%type<en> comma_expression                              comma_expression_opt
    145 %type<en> argument_expression_list              argument_expression                     assignment_opt
    146 %type<fctl> for_control_expression
     138%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    147139%type<en> subrange
    148140%type<en> asm_operands_opt asm_operands_list asm_operand
    149141%type<label> label_list
    150 %type<en> asm_clobbers_list_opt
     142%type<constant> asm_clobbers_list_opt
    151143%type<flag> asm_volatile_opt
    152144
     
    158150%type<sn> block_item_list                               block_item
    159151%type<sn> case_clause
    160 %type<en> case_value
    161 %type<sn> case_value_list                               case_label                                      case_label_list
     152%type<en> case_value                                    case_value_list
     153%type<sn> case_label                                    case_label_list
    162154%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
     155%type<pn> handler_list                                  handler_clause                          finally_clause
    164156
    165157// declarations
     
    311303constant:
    312304                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    313 INTEGERconstant                                                                 { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }
    314         | FLOATINGconstant                                                      { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
    315         | CHARACTERconstant                                                     { $$ = new ExpressionNode( build_constantChar( *$1 ) ); }
     305INTEGERconstant                                                                 { $$ = makeConstant( ConstantNode::Integer, $1 ); }
     306        | FLOATINGconstant                                                      { $$ = makeConstant( ConstantNode::Float, $1 ); }
     307        | CHARACTERconstant                                                     { $$ = makeConstant( ConstantNode::Character, $1 ); }
    316308        ;
    317309
     
    338330
    339331string_literal_list:                                                                    // juxtaposed strings are concatenated
    340         STRINGliteral                                                           { $$ = build_constantStr( *$1 ); }
    341         | string_literal_list STRINGliteral
    342                 {
    343                         appendStr( $1->get_constant()->get_value(), $2 );
    344                         delete $2;                                                                      // allocated by lexer
    345                         $$ = $1;
    346                 }
     332        STRINGliteral                                                           { $$ = makeConstantStr( ConstantNode::String, $1 ); }
     333        | string_literal_list STRINGliteral                     { $$ = $1->appendstr( $2 ); }
    347334        ;
    348335
     
    351338primary_expression:
    352339        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    353                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     340                { $$ = new VarRefNode( $1 ); }
    354341        | zero_one
    355                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     342                { $$ = new VarRefNode( $1 ); }
    356343        | '(' comma_expression ')'
    357344                { $$ = $2; }
    358345        | '(' compound_statement ')'                                            // GCC, lambda expression
    359         { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     346                { $$ = new ValofExprNode( $2 ); }
    360347        ;
    361348
     
    367354                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
    368355                // equivalent to the old x[i,j].
    369                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
     356                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Index ), $1, $4 ); }
    370357        | postfix_expression '(' argument_expression_list ')'
    371                 { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     358                { $$ = new CompositeExprNode( $1, $3 ); }
    372359        // ambiguity with .0 so space required after field-selection, e.g.
    373360                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    374361        | postfix_expression '.' no_attr_identifier
    375                 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     362                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), $1, new VarRefNode( $3 )); }
    376363        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
    377364        | postfix_expression ARROW no_attr_identifier
    378                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     365                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), $1, new VarRefNode( $3 )); }
    379366        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
    380367        | postfix_expression ICR
    381                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     368                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::IncrPost ), $1 ); }
    382369        | postfix_expression DECR
    383                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }
     370                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); }
    384371        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
    385                 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     372                { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); }
    386373        | postfix_expression '{' argument_expression_list '}' // CFA
    387374                {
    388                         Token fn;
    389                         fn.str = new std::string( "?{}" ); // location undefined
    390                         $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) );
     375                        Token fn; fn.str = new std::string( "?{}" ); // location undefined
     376                        $$ = new CompositeExprNode( new VarRefNode( fn ), (ExpressionNode *)( $1 )->set_link( $3 ) );
    391377                }
    392378        ;
     
    395381        argument_expression
    396382        | argument_expression_list ',' argument_expression
    397                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     383                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    398384        ;
    399385
     
    402388                { $$ = 0; }                                                                             // use default argument
    403389        | assignment_expression
     390        | no_attr_identifier ':' assignment_expression
     391                { $$ = $3->set_argName( $1 ); }
     392                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
     393                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
     394                // with an appropriate semantic check.
     395        | '[' push assignment_expression pop ']' ':' assignment_expression
     396                { $$ = $7->set_argName( $3 ); }
     397        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
     398                { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    404399        ;
    405400
    406401field_list:                                                                                             // CFA, tuple field selector
    407402        field
    408         | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     403        | field_list ',' field                                          { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    409404        ;
    410405
    411406field:                                                                                                  // CFA, tuple field selector
    412407        no_attr_identifier
    413                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     408                { $$ = new VarRefNode( $1 ); }
    414409        // ambiguity with .0 so space required after field-selection, e.g.
    415410                //   struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1;
    416411        | no_attr_identifier '.' field
    417                 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     412                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $3 ); }
    418413        | no_attr_identifier '.' '[' push field_list pop ']'
    419                 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
     414                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $5 ); }
    420415        | no_attr_identifier ARROW field
    421                 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
     416                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $3 ); }
    422417        | no_attr_identifier ARROW '[' push field_list pop ']'
    423                 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     418                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $5 ); }
    424419        ;
    425420
     
    431426                { $$ = $1; }
    432427        | string_literal_list
    433                 { $$ = new ExpressionNode( $1 ); }
     428                { $$ = $1; }
    434429        | EXTENSION cast_expression                                                     // GCC
    435430                { $$ = $2->set_extension( true ); }
     431        | ptrref_operator cast_expression                                       // CFA
     432                { $$ = new CompositeExprNode( $1, $2 ); }
    436433                // '*' ('&') is separated from unary_operator because of shift/reduce conflict in:
    437434                //              { * X; }         // dereference X
    438435                //              { * int X; } // CFA declaration of pointer to int
    439         | ptrref_operator cast_expression                                       // CFA
    440                 {
    441                         switch ( $1 ) {
    442                           case OperKinds::AddressOf:
    443                                 $$ = new ExpressionNode( build_addressOf( $2 ) );
    444                                 break;
    445                           case OperKinds::PointTo:
    446                                 $$ = new ExpressionNode( build_unary_val( $1, $2 ) );
    447                                 break;
    448                           default:
    449                                 assert( false );
    450                         }
    451                 }
    452436        | unary_operator cast_expression
    453                 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
     437                { $$ = new CompositeExprNode( $1, $2 ); }
    454438        | ICR unary_expression
    455                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }
     439                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
    456440        | DECR unary_expression
    457                 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }
     441                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Decr ), $2 ); }
    458442        | SIZEOF unary_expression
    459                 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); }
     443                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), $2 ); }
    460444        | SIZEOF '(' type_name_no_function ')'
    461                 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); }
     445                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }
     446        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
     447                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }
     448        | ATTR_IDENTIFIER
     449                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); }
     450        | ATTR_IDENTIFIER '(' type_name ')'
     451                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), new TypeValueNode( $3 )); }
     452        | ATTR_IDENTIFIER '(' argument_expression ')'
     453                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), $3 ); }
    462454        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    463                 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
     455                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), $2 ); }
    464456        | 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 ) ); }
     457                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3 ) ); }
    474458//      | ANDAND IDENTIFIER                                                                     // GCC, address of label
    475 //              { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); }
     459//              { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true ) ); }
    476460        ;
    477461
    478462ptrref_operator:
    479         '*'                                                                                     { $$ = OperKinds::PointTo; }
    480         | '&'                                                                           { $$ = OperKinds::AddressOf; }
     463        '*'                                                                                     { $$ = new OperatorNode( OperatorNode::PointTo ); }
     464        | '&'                                                                           { $$ = new OperatorNode( OperatorNode::AddressOf ); }
    481465                // GCC, address of label must be handled by semantic check for ref,ref,label
    482 //      | ANDAND                                                                        { $$ = OperKinds::And; }
     466        | ANDAND                                                                        { $$ = new OperatorNode( OperatorNode::And ); }
    483467        ;
    484468
    485469unary_operator:
    486         '+'                                                                                     { $$ = OperKinds::UnPlus; }
    487         | '-'                                                                           { $$ = OperKinds::UnMinus; }
    488         | '!'                                                                           { $$ = OperKinds::Neg; }
    489         | '~'                                                                           { $$ = OperKinds::BitNeg; }
     470        '+'                                                                                     { $$ = new OperatorNode( OperatorNode::UnPlus ); }
     471        | '-'                                                                           { $$ = new OperatorNode( OperatorNode::UnMinus ); }
     472        | '!'                                                                           { $$ = new OperatorNode( OperatorNode::Neg ); }
     473        | '~'                                                                           { $$ = new OperatorNode( OperatorNode::BitNeg ); }
    490474        ;
    491475
     
    493477        unary_expression
    494478        | '(' type_name_no_function ')' cast_expression
    495                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     479                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
    496480        | '(' type_name_no_function ')' tuple
    497                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     481                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4 ); }
    498482        ;
    499483
     
    501485        cast_expression
    502486        | multiplicative_expression '*' cast_expression
    503                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
     487                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mul ), $1, $3 ); }
    504488        | multiplicative_expression '/' cast_expression
    505                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
     489                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Div ), $1, $3 ); }
    506490        | multiplicative_expression '%' cast_expression
    507                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
     491                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Mod ), $1, $3 ); }
    508492        ;
    509493
     
    511495        multiplicative_expression
    512496        | additive_expression '+' multiplicative_expression
    513                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
     497                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Plus ), $1, $3 ); }
    514498        | additive_expression '-' multiplicative_expression
    515                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
     499                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Minus ), $1, $3 ); }
    516500        ;
    517501
     
    519503        additive_expression
    520504        | shift_expression LS additive_expression
    521                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
     505                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LShift ), $1, $3 ); }
    522506        | shift_expression RS additive_expression
    523                 { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
     507                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::RShift ), $1, $3 ); }
    524508        ;
    525509
     
    527511        shift_expression
    528512        | relational_expression '<' shift_expression
    529                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
     513                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LThan ), $1, $3 ); }
    530514        | relational_expression '>' shift_expression
    531                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
     515                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GThan ), $1, $3 ); }
    532516        | relational_expression LE shift_expression
    533                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
     517                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LEThan ), $1, $3 ); }
    534518        | relational_expression GE shift_expression
    535                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
     519                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::GEThan ), $1, $3 ); }
    536520        ;
    537521
     
    539523        relational_expression
    540524        | equality_expression EQ relational_expression
    541                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
     525                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Eq ), $1, $3 ); }
    542526        | equality_expression NE relational_expression
    543                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
     527                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Neq ), $1, $3 ); }
    544528        ;
    545529
     
    547531        equality_expression
    548532        | AND_expression '&' equality_expression
    549                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
     533                { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::BitAnd ), $1, $3 ); }
    550534        ;
    551535
     
    553537        AND_expression
    554538        | exclusive_OR_expression '^' AND_expression
    555                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
     539                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Xor ), $1, $3 ); }
    556540        ;
    557541
     
    559543        exclusive_OR_expression
    560544        | inclusive_OR_expression '|' exclusive_OR_expression
    561                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
     545                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::BitOr ), $1, $3 ); }
    562546        ;
    563547
     
    565549        inclusive_OR_expression
    566550        | logical_AND_expression ANDAND inclusive_OR_expression
    567                 { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); }
     551                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::And ), $1, $3 ); }
    568552        ;
    569553
     
    571555        logical_AND_expression
    572556        | logical_OR_expression OROR logical_AND_expression
    573                 { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); }
     557                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Or ), $1, $3 ); }
    574558        ;
    575559
     
    577561        logical_OR_expression
    578562        | logical_OR_expression '?' comma_expression ':' conditional_expression
    579                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    580                 // FIX ME: this hack computes $1 twice
     563                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
    581564        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    582                 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     565                { $$=new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), $1, $4 ); }
    583566        | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression
    584                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
     567                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 ) ) ); }
    585568        ;
    586569
     
    592575                // CFA, assignment is separated from assignment_operator to ensure no assignment operations for tuples
    593576        conditional_expression
     577        | unary_expression '=' assignment_expression
     578                { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $3 ); }
    594579        | unary_expression assignment_operator assignment_expression
    595                 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
     580                { $$ =new CompositeExprNode( $2, $1, $3 ); }
    596581        | tuple assignment_opt                                                          // CFA, tuple expression
    597                 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }
     582                { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); }
    598583        ;
    599584
    600585assignment_expression_opt:
    601586        // empty
    602                 { $$ = nullptr; }
     587                { $$ = new NullExprNode; }
    603588        | assignment_expression
    604         ;
    605 
    606 assignment_operator:
    607         '='                                                                                     { $$ = OperKinds::Assign; }
    608         | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    609         | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
    610         | MODassign                                                                     { $$ = OperKinds::ModAssn; }
    611         | PLUSassign                                                            { $$ = OperKinds::PlusAssn; }
    612         | MINUSassign                                                           { $$ = OperKinds::MinusAssn; }
    613         | LSassign                                                                      { $$ = OperKinds::LSAssn; }
    614         | RSassign                                                                      { $$ = OperKinds::RSAssn; }
    615         | ANDassign                                                                     { $$ = OperKinds::AndAssn; }
    616         | ERassign                                                                      { $$ = OperKinds::ERAssn; }
    617         | ORassign                                                                      { $$ = OperKinds::OrAssn; }
    618589        ;
    619590
     
    622593                // comma_expression in new_identifier_parameter_array and new_abstract_array
    623594        '[' ']'
    624                 { $$ = new ExpressionNode( build_tuple() ); }
     595                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); }
    625596        | '[' push assignment_expression pop ']'
    626                 { $$ = new ExpressionNode( build_tuple( $3 ) ); }
     597                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), $3 ); }
    627598        | '[' push ',' tuple_expression_list pop ']'
    628                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); }
     599                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(new NullExprNode)->set_link( $4 ) ); }
    629600        | '[' push assignment_expression ',' tuple_expression_list pop ']'
    630                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); }
     601                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 ) ) ); }
    631602        ;
    632603
     
    634605        assignment_expression_opt
    635606        | tuple_expression_list ',' assignment_expression_opt
    636                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     607                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
     608        ;
     609
     610assignment_operator:
     611        MULTassign                                                                      { $$ = new OperatorNode( OperatorNode::MulAssn ); }
     612        | DIVassign                                                                     { $$ = new OperatorNode( OperatorNode::DivAssn ); }
     613        | MODassign                                                                     { $$ = new OperatorNode( OperatorNode::ModAssn ); }
     614        | PLUSassign                                                            { $$ = new OperatorNode( OperatorNode::PlusAssn ); }
     615        | MINUSassign                                                           { $$ = new OperatorNode( OperatorNode::MinusAssn ); }
     616        | LSassign                                                                      { $$ = new OperatorNode( OperatorNode::LSAssn ); }
     617        | RSassign                                                                      { $$ = new OperatorNode( OperatorNode::RSAssn ); }
     618        | ANDassign                                                                     { $$ = new OperatorNode( OperatorNode::AndAssn ); }
     619        | ERassign                                                                      { $$ = new OperatorNode( OperatorNode::ERAssn ); }
     620        | ORassign                                                                      { $$ = new OperatorNode( OperatorNode::OrAssn ); }
    637621        ;
    638622
    639623comma_expression:
    640624        assignment_expression
    641         | comma_expression ',' assignment_expression
    642                 { $$ = new ExpressionNode( build_comma( $1, $3 ) ); }
     625        | comma_expression ',' assignment_expression    // { $$ = (ExpressionNode *)$1->add_to_list( $3 ); }
     626                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Comma ), $1, $3 ); }
    643627        ;
    644628
     
    662646        | '^' postfix_expression '{' argument_expression_list '}' ';' // CFA
    663647                {
    664                         Token fn;
    665                         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 ) ) ) ) );
     648                        Token fn; fn.str = new std::string( "^?{}" ); // location undefined
     649                        $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( new VarRefNode( fn ),
     650                                (ExpressionNode *)( $2 )->set_link( $4 ) ), 0 );
    667651                }
    668652        ;
     
    678662compound_statement:
    679663        '{' '}'
    680                 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     664                { $$ = new CompoundStmtNode( (StatementNode *)0 ); }
    681665        | '{'
    682666                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
     
    685669          local_label_declaration_opt                                           // GCC, local labels
    686670          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    687                 { $$ = new StatementNode( build_compound( $5 ) ); }
     671                { $$ = new CompoundStmtNode( $5 ); }
    688672        ;
    689673
     
    691675        block_item
    692676        | block_item_list push block_item
    693                 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
     677                { if ( $1 != 0 ) { $1->set_link( $3 ); $$ = $1; } }
    694678        ;
    695679
     
    699683        | EXTENSION declaration                                                         // GCC
    700684                {       // mark all fields in list
    701                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )
     685                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    702686                                iter->set_extension( true );
    703687                        $$ = new StatementNode( $2 );
     
    711695        statement
    712696        | statement_list statement
    713                 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
     697                { if ( $1 != 0 ) { $1->set_link( $2 ); $$ = $1; } }
    714698        ;
    715699
    716700expression_statement:
    717701        comma_expression_opt ';'
    718                 { $$ = new StatementNode( build_expr( $1 ) ); }
     702                { $$ = new StatementNode( StatementNode::Exp, $1, 0 ); }
    719703        ;
    720704
     
    722706        IF '(' comma_expression ')' statement                           %prec THEN
    723707                // explicitly deal with the shift/reduce conflict on if/else
    724                 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
     708                { $$ = new StatementNode( StatementNode::If, $3, $5 ); }
    725709        | IF '(' comma_expression ')' statement ELSE statement
    726                 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
     710                { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }
    727711        | SWITCH '(' comma_expression ')' case_clause           // CFA
    728                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     712                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    729713        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    730714                {
    731                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     715                        StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
    732716                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    733717                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    734718                        // statement around the switch.  Statements after the initial declaration list can never be executed, and
    735                         // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    736                         // statement.
    737                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     719                        // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
     720                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    738721                }
    739722        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    740                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     723                { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); }
    741724        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA
    742725                {
    743                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
    744                         $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     726                        StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 );
     727                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    745728                }
    746729        ;
     
    752735        constant_expression                                                     { $$ = $1; }
    753736        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    754                 { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
     737                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
    755738        | subrange                                                                                      // CFA, subrange
    756739        ;
    757740
    758741case_value_list:                                                                                // CFA
    759         case_value                                                                      { $$ = new StatementNode( build_case( $1 ) ); }
    760                 // 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 ) ) ) ); }
     742        case_value
     743        | case_value_list ',' case_value
     744                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); }
    762745        ;
    763746
    764747case_label:                                                                                             // CFA
    765         CASE case_value_list ':'                                        { $$ = $2; }
    766         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
     748        CASE case_value_list ':'                                        { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }
     749        | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
    767750                // A semantic check is required to ensure only one default clause per switch/choose statement.
    768751        ;
     
    770753case_label_list:                                                                                // CFA
    771754        case_label
    772         | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_last( $2 )); }
     755        | case_label_list case_label                            { $$ = (StatementNode *)( $1->set_link( $2 )); }
    773756        ;
    774757
    775758case_clause:                                                                                    // CFA
    776         case_label_list statement                                       { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     759        case_label_list statement                                       { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    777760        ;
    778761
     
    785768switch_clause_list:                                                                             // CFA
    786769        case_label_list statement_list
    787                 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     770                { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); }
    788771        | switch_clause_list case_label_list statement_list
    789                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     772                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); }
    790773        ;
    791774
     
    800783                { $$ = $1->append_last_case( $2 ); }
    801784        | case_label_list statement_list fall_through_opt
    802                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
     785                { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }
    803786        | choose_clause_list case_label_list fall_through
    804                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
     787                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }
    805788        | 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 ) ) ) ) ) ); }
     789                { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }
    807790        ;
    808791
    809792fall_through_opt:                                                                               // CFA
    810793        // empty
    811                 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break
     794                { $$ = new StatementNode( StatementNode::Break ); }     // insert implicit break
    812795        | fall_through
    813796        ;
     
    822805iteration_statement:
    823806        WHILE '(' comma_expression ')' statement
    824                 { $$ = new StatementNode( build_while( $3, $5 ) ); }
     807                { $$ = new StatementNode( StatementNode::While, $3, $5 ); }
    825808        | DO statement WHILE '(' comma_expression ')' ';'
    826                 { $$ = new StatementNode( build_while( $5, $2 ) ); }
     809                { $$ = new StatementNode( StatementNode::Do, $5, $2 ); }
    827810        | FOR '(' push for_control_expression ')' statement
    828                 { $$ = new StatementNode( build_for( $4, $6 ) ); }
     811                { $$ = new StatementNode( StatementNode::For, $4, $6 ); }
    829812        ;
    830813
    831814for_control_expression:
    832815        comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt
    833                 { $$ = new ForCtl( $1, $4, $6 ); }
     816                { $$ = new ForCtlExprNode( $1, $4, $6 ); }
    834817        | declaration comma_expression_opt ';' comma_expression_opt // C99
    835                 { $$ = new ForCtl( $1, $2, $4 ); }
    836         ;
     818                { $$ = new ForCtlExprNode( $1, $2, $4 ); }
     819        ;
    837820
    838821jump_statement:
    839822        GOTO IDENTIFIER ';'
    840                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Goto ) ); }
     823                { $$ = new StatementNode( StatementNode::Goto, $2 ); }
    841824        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    842825                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
    843826                // whereas normal operator precedence yields goto (*i)+3;
    844                 { $$ = new StatementNode( build_computedgoto( $3 ) ); }
     827                { $$ = new StatementNode( StatementNode::Goto, $3 ); }
    845828        | CONTINUE ';'
    846829                // 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 ) ); }
     830                { $$ = new StatementNode( StatementNode::Continue ); }
    848831        | CONTINUE IDENTIFIER ';'                                                       // CFA, multi-level continue
    849832                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    850833                // the target of the transfer appears only at the start of an iteration statement.
    851                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Continue ) ); delete $2; }
     834                { $$ = new StatementNode( StatementNode::Continue, $2 ); }
    852835        | BREAK ';'
    853836                // 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 ) ); }
     837                { $$ = new StatementNode( StatementNode::Break ); }
    855838        | BREAK IDENTIFIER ';'                                                          // CFA, multi-level exit
    856839                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    857840                // the target of the transfer appears only at the start of an iteration statement.
    858                 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Break ) ); delete $2; }
     841                { $$ = new StatementNode( StatementNode::Break, $2 ); }
    859842        | 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 ) ); }
     843                { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
     844        | THROW assignment_expression_opt ';'
     845                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     846//      | THROW ';'
     847//              { $$ = new StatementNode( StatementNode::Throw ); }
     848        | THROWRESUME assignment_expression_opt ';'
     849                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     850        | THROWRESUME assignment_expression_opt AT assignment_expression ';'
     851                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     852//      | THROWRESUME ';'
     853//              { $$ = new StatementNode( StatementNode::Throw ); }
    867854        ;
    868855
    869856exception_statement:
    870857        TRY compound_statement handler_list
    871                 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); }
     858                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    872859        | TRY compound_statement finally_clause
    873                 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); }
     860                { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }
    874861        | TRY compound_statement handler_list finally_clause
    875                 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
     862                {
     863                        $3->set_link( $4 );
     864                        $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 ))));
     865                }
    876866        ;
    877867
    878868handler_list:
     869                // There must be at least one catch clause
    879870        handler_clause
    880871                // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    881872        | CATCH '(' ELLIPSIS ')' compound_statement
    882                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     873                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
    883874        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    884                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     875                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
    885876        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    886                 { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
     877                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
    887878        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    888                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
     879                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
    889880        ;
    890881
    891882handler_clause:
    892883        CATCH '(' push push exception_declaration pop ')' compound_statement pop
    893                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     884                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    894885        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    895         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     886                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    896887        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    897                 { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     888                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    898889        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    899                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     890                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    900891        ;
    901892
     
    903894        FINALLY compound_statement
    904895                {
    905                         $$ = new StatementNode( build_finally( $2 ) );
     896                        $$ = new StatementNode( StatementNode::Finally, 0, $2 );
     897                        std::cout << "Just created a finally node" << std::endl;
    906898                }
    907899        ;
     
    931923asm_statement:
    932924        ASM asm_volatile_opt '(' string_literal_list ')' ';'
    933                 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); }
     925                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
    934926        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
    935                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); }
     927                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
    936928        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    937                 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); }
     929                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
    938930        | 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 ) ); }
     931                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
    940932        | 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 ) ); }
     933        { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
    942934        ;
    943935
     
    958950        asm_operand
    959951        | asm_operands_list ',' asm_operand
    960                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     952                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    961953        ;
    962954
    963955asm_operand:                                                                                    // GCC
    964956        string_literal_list '(' constant_expression ')'
    965                 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
     957                { $$ = new AsmExprNode( 0, $1, $3 ); }
    966958        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
    967         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     959                { $$ = new AsmExprNode( $2, $4, $6 ); }
    968960        ;
    969961
     
    972964                { $$ = 0; }                                                                             // use default argument
    973965        | string_literal_list
    974                 { $$ = new ExpressionNode( $1 ); }
     966                { $$ = $1; }
    975967        | asm_clobbers_list_opt ',' string_literal_list
    976                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     968                { $$ = (ConstantNode *)$1->set_link( $3 ); }
    977969        ;
    978970
    979971label_list:
    980972        no_attr_identifier
    981                 { $$ = new LabelNode(); $$->labels.push_back( *$1 ); }
     973                { $$ = new LabelNode(); $$->append_label( $1 ); }
    982974        | label_list ',' no_attr_identifier
    983                 { $$ = $1; $1->labels.push_back( *$3 ); }
     975                { $$ = $1; $1->append_label( $3 ); }
    984976        ;
    985977
     
    14971489        | EXTENSION field_declaring_list ';'                            // GCC
    14981490                {       // mark all fields in list
    1499                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )
     1491                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    15001492                                iter->set_extension( true );
    15011493                        $$ = $2;
     
    17431735        | initializer
    17441736        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    1745         | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
     1737        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
    17461738        | initializer_list ',' designation initializer
    1747                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     1739                { $$ = (InitializerNode *)( $1->set_link( $4->set_designators( $3 ) ) ); }
    17481740        ;
    17491741
     
    17611753        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    17621754        | no_attr_identifier_or_type_name ':'                           // GCC, field name
    1763                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     1755                { $$ = new VarRefNode( $1 ); }
    17641756        ;
    17651757
     
    17671759        designator
    17681760        | designator_list designator
    1769                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
    1770         //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
     1761                { $$ = (ExpressionNode *)( $1->set_link( $2 )); }
     1762        //| designator_list designator                                          { $$ = new CompositeExprNode( $1, $2 ); }
    17711763        ;
    17721764
    17731765designator:
    1774         '.' no_attr_identifier_or_type_name                                     // C99, field name
    1775                 { $$ = new ExpressionNode( build_varref( $2 ) ); }
     1766                // lexer ambiguity: designator ".0" is floating-point constant or designator for name 0 only ".0" and ".1"
     1767                // allowed => semantic check
     1768        FLOATINGconstant
     1769                { $$ = new DesignatorNode( new VarRefNode( $1 ) ); }
     1770        | '.' no_attr_identifier_or_type_name                           // C99, field name
     1771                { $$ = new DesignatorNode( new VarRefNode( $2 ) ); }
    17761772        | '[' push assignment_expression pop ']'                        // C99, single array element
    17771773                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1778                 { $$ = $3; }
     1774                { $$ = new DesignatorNode( $3, true ); }
    17791775        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1780                 { $$ = $3; }
     1776                { $$ = new DesignatorNode( $3, true ); }
    17811777        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1782                 { $$ = new ExpressionNode( build_range( $3, $5 ) ); }
     1778                { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); }
    17831779        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1784                 { $$ = $4; }
     1780                { $$ = new DesignatorNode( $4 ); }
    17851781        ;
    17861782
     
    18701866type_name_list:                                                                                 // CFA
    18711867        type_name
    1872                 { $$ = new ExpressionNode( build_typevalue( $1 ) ); }
     1868                { $$ = new TypeValueNode( $1 ); }
    18731869        | assignment_expression
    18741870        | type_name_list ',' type_name
    1875                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); }
     1871                { $$ = (ExpressionNode *)( $1->set_link( new TypeValueNode( $3 ))); }
    18761872        | type_name_list ',' assignment_expression
    1877                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     1873                { $$ = (ExpressionNode *)( $1->set_link( $3 )); }
    18781874        ;
    18791875
     
    20132009        | EXTENSION external_definition
    20142010                {       // mark all fields in list
    2015                         for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() )
     2011                        for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )
    20162012                                iter->set_extension( true );
    20172013                        $$ = $2;
     
    21092105subrange:
    21102106        constant_expression '~' constant_expression                     // CFA, integer subrange
    2111                 { $$ = new ExpressionNode( build_range( $1, $3 ) ); }
     2107                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $1, $3 ); }
    21122108        ;
    21132109
Note: See TracChangeset for help on using the changeset viewer.