Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rbb7422a r70056ed  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 14:02:00 2023
    13 // Update Count     : 6329
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Mar 30 21:28:25 2023
     13// Update Count     : 6328
    1414//
    1515
     
    6464
    6565extern DeclarationNode * parseTree;
    66 extern ast::Linkage::Spec linkage;
     66extern LinkageSpec::Spec linkage;
    6767extern TypedefTable typedefTable;
    6868
    69 stack<ast::Linkage::Spec> linkageStack;
     69stack<LinkageSpec::Spec> linkageStack;
    7070
    7171bool appendStr( string & to, string & from ) {
     
    200200} // fieldDecl
    201201
    202 #define NEW_ZERO new ExpressionNode( build_constantInteger( yylloc, *new string( "0" ) ) )
    203 #define NEW_ONE  new ExpressionNode( build_constantInteger( yylloc, *new string( "1" ) ) )
     202#define NEW_ZERO new ExpressionNode( build_constantInteger( *new string( "0" ) ) )
     203#define NEW_ONE  new ExpressionNode( build_constantInteger( *new string( "1" ) ) )
    204204#define UPDOWN( compop, left, right ) (compop == OperKinds::LThan || compop == OperKinds::LEThan ? left : right)
    205205#define MISSING_ANON_FIELD "Missing loop fields with an anonymous loop index is meaningless as loop index is unavailable in loop body."
     
    208208
    209209static ForCtrl * makeForCtrl(
    210                 const CodeLocation & location,
    211210                DeclarationNode * init,
    212211                enum OperKinds compop,
     
    214213                ExpressionNode * inc ) {
    215214        // Wrap both comp/inc if they are non-null.
    216         if ( comp ) comp = new ExpressionNode( build_binary_val( location,
     215        if ( comp ) comp = new ExpressionNode( build_binary_val(
    217216                compop,
    218                 new ExpressionNode( build_varref( location, new string( *init->name ) ) ),
     217                new ExpressionNode( build_varref( new string( *init->name ) ) ),
    219218                comp ) );
    220         if ( inc ) inc = new ExpressionNode( build_binary_val( location,
     219        if ( inc ) inc = new ExpressionNode( build_binary_val(
    221220                // choose += or -= for upto/downto
    222221                compop == OperKinds::LThan || compop == OperKinds::LEThan ? OperKinds::PlusAssn : OperKinds::MinusAssn,
    223                 new ExpressionNode( build_varref( location, new string( *init->name ) ) ),
     222                new ExpressionNode( build_varref( new string( *init->name ) ) ),
    224223                inc ) );
    225224        // The StatementNode call frees init->name, it must happen later.
     
    227226}
    228227
    229 ForCtrl * forCtrl( const CodeLocation & location, DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     228ForCtrl * forCtrl( DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    230229        if ( index->initializer ) {
    231230                SemanticError( yylloc, "Direct initialization disallowed. Use instead: type var; initialization ~ comparison ~ increment." );
     
    235234        } // if
    236235        DeclarationNode * initDecl = index->addInitializer( new InitializerNode( start ) );
    237         return makeForCtrl( location, initDecl, compop, comp, inc );
     236        return makeForCtrl( initDecl, compop, comp, inc );
    238237} // forCtrl
    239238
    240 ForCtrl * forCtrl( const CodeLocation & location, ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    241         ast::ConstantExpr * constant = dynamic_cast<ast::ConstantExpr *>(type->expr.get());
    242         if ( constant && (constant->rep == "0" || constant->rep == "1") ) {
    243                 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicType::SignedInt ) ) );
     239ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     240        ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->expr.get());
     241        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
     242                type = new ExpressionNode( new CastExpr( maybeMoveBuild( type ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
    244243        } // if
    245244        DeclarationNode * initDecl = distAttr(
     
    247246                DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) )
    248247        );
    249         return makeForCtrl( location, initDecl, compop, comp, inc );
     248        return makeForCtrl( initDecl, compop, comp, inc );
    250249} // forCtrl
    251250
    252 ForCtrl * forCtrl( const CodeLocation & location, ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    253         if ( auto identifier = dynamic_cast<ast::NameExpr *>(index->expr.get()) ) {
    254                 return forCtrl( location, type, new string( identifier->name ), start, compop, comp, inc );
    255         } else if ( auto commaExpr = dynamic_cast<ast::CommaExpr *>( index->expr.get() ) ) {
    256                 if ( auto identifier = commaExpr->arg1.as<ast::NameExpr>() ) {
    257                         return forCtrl( location, type, new string( identifier->name ), start, compop, comp, inc );
     251ForCtrl * forCtrl( ExpressionNode * type, ExpressionNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     252        if ( NameExpr * identifier = dynamic_cast<NameExpr *>(index->expr.get()) ) {
     253                return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
     254        } else if ( CommaExpr * commaExpr = dynamic_cast<CommaExpr *>(index->expr.get()) ) {
     255                if ( NameExpr * identifier = dynamic_cast<NameExpr *>(commaExpr->arg1 ) ) {
     256                        return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
    258257                } else {
    259258                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
     
    300299        ExpressionNode * en;
    301300        DeclarationNode * decl;
    302         ast::AggregateDecl::Aggregate aggKey;
    303         ast::TypeDecl::Kind tclass;
     301        AggregateDecl::Aggregate aggKey;
     302        TypeDecl::Kind tclass;
    304303        StatementNode * sn;
    305         ast::WaitForStmt * wfs;
    306         ast::Expr * constant;
     304        WaitForStmt * wfs;
     305        Expression * constant;
    307306        CondCtl * ifctl;
    308307        ForCtrl * fctl;
     
    314313        bool flag;
    315314        EnumHiding hide;
    316         ast::ExceptionKind catch_kind;
    317         ast::GenericExpr * genexpr;
     315        CatchStmt::Kind catch_kind;
     316        GenericExpr * genexpr;
    318317}
    319318
    320 // ************************ TERMINAL TOKENS ********************************
     319//************************* TERMINAL TOKENS ********************************
    321320
    322321// keywords
     
    612611constant:
    613612                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    614         INTEGERconstant                                                         { $$ = new ExpressionNode( build_constantInteger( yylloc, *$1 ) ); }
    615         | FLOATING_DECIMALconstant                                      { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); }
    616         | FLOATING_FRACTIONconstant                                     { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); }
    617         | FLOATINGconstant                                                      { $$ = new ExpressionNode( build_constantFloat( yylloc, *$1 ) ); }
    618         | CHARACTERconstant                                                     { $$ = new ExpressionNode( build_constantChar( yylloc, *$1 ) ); }
     613        INTEGERconstant                                                         { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); }
     614        | FLOATING_DECIMALconstant                                      { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
     615        | FLOATING_FRACTIONconstant                                     { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
     616        | FLOATINGconstant                                                      { $$ = new ExpressionNode( build_constantFloat( *$1 ) ); }
     617        | CHARACTERconstant                                                     { $$ = new ExpressionNode( build_constantChar( *$1 ) ); }
    619618        ;
    620619
     
    642641
    643642string_literal:
    644         string_literal_list                                                     { $$ = build_constantStr( yylloc, *$1 ); }
     643        string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
    645644        ;
    646645
     
    659658primary_expression:
    660659        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    661                 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
     660                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    662661        | quasi_keyword
    663                 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
     662                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    664663        | TYPEDIMname                                                                           // CFA, generic length argument
    665664                // { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( DeclarationNode::newFromTypedef( $1 ) ) ) ); }
    666665                // { $$ = new ExpressionNode( build_varref( $1 ) ); }
    667                 { $$ = new ExpressionNode( build_dimensionref( yylloc, $1 ) ); }
     666                { $$ = new ExpressionNode( build_dimensionref( $1 ) ); }
    668667        | tuple
    669668        | '(' comma_expression ')'
    670669                { $$ = $2; }
    671670        | '(' compound_statement ')'                                            // GCC, lambda expression
    672                 { $$ = new ExpressionNode( new ast::StmtExpr( yylloc, dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( $2 ) ) ) ); }
     671                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild( $2 ) ) ) ); }
    673672        | type_name '.' identifier                                                      // CFA, nested type
    674                 { $$ = new ExpressionNode( build_qualified_expr( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
     673                { $$ = new ExpressionNode( build_qualified_expr( $1, build_varref( $3 ) ) ); }
    675674        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
    676675                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    704703                {
    705704                        // steal the association node from the singleton and delete the wrapper
    706                         assert( 1 == $3->associations.size() );
    707                         $1->associations.push_back( $3->associations.front() );
     705                        $1->associations.splice($1->associations.end(), $3->associations);
    708706                        delete $3;
    709707                        $$ = $1;
     
    715713                {
    716714                        // create a GenericExpr wrapper with one association pair
    717                         $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuildType( $1 ), maybeMoveBuild( $3 ) } } );
     715                        $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild( $3 ) } } );
    718716                }
    719717        | DEFAULT ':' assignment_expression
    720                 { $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuild( $3 ) } } ); }
     718                { $$ = new GenericExpr( nullptr, { { maybeMoveBuild( $3 ) } } ); }
    721719        ;
    722720
     
    727725                // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
    728726                // Current: Commas in subscripts make tuples.
    729                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
     727                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    730728        | postfix_expression '[' assignment_expression ']'
    731729                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
     
    733731                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
    734732                // equivalent to the old x[i,j].
    735                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); }
     733                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
    736734        | constant '[' assignment_expression ']'                        // 3[a], 'a'[a], 3.5[a]
    737                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); }
     735                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
    738736        | string_literal '[' assignment_expression ']'          // "abc"[3], 3["abc"]
    739                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }
     737                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }
    740738        | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call
    741739                {
    742740                        Token fn;
    743741                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    744                         $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
     742                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    745743                }
    746744        | postfix_expression '(' argument_expression_list_opt ')'
    747                 { $$ = new ExpressionNode( build_func( yylloc, $1, $3 ) ); }
     745                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    748746        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
    749747                // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
    750                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg") ) ),
     748                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__builtin_va_arg") ) ),
    751749                                                                                           (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }
    752750        | postfix_expression '`' identifier                                     // CFA, postfix call
    753                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
     751                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
    754752        | constant '`' identifier                                                       // CFA, postfix call
    755                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
     753                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
    756754        | string_literal '`' identifier                                         // CFA, postfix call
    757                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
     755                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
    758756        | postfix_expression '.' identifier
    759                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
     757                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    760758        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
    761                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); }
     759                { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
    762760        | postfix_expression FLOATING_FRACTIONconstant          // CFA, tuple index
    763                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 ) ) ); }
     761                { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }
    764762        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    765                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
     763                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    766764        | postfix_expression '.' aggregate_control
    767                 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $3, $1 ) ); }
     765                { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
    768766        | postfix_expression ARROW identifier
    769                 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
     767                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    770768        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
    771                 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); }
     769                { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); }
    772770        | postfix_expression ARROW '[' field_name_list ']'      // CFA, tuple field selector
    773                 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
     771                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); }
    774772        | postfix_expression ICR
    775                 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::IncrPost, $1 ) ); }
     773                { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); }
    776774        | postfix_expression DECR
    777                 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::DecrPost, $1 ) ); }
     775                { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); }
    778776        | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal
    779                 { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, new InitializerNode( $5, true ) ) ); }
     777                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
    780778        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    781                 { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
     779                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    782780        | '^' primary_expression '{' argument_expression_list_opt '}' // CFA, destructor call
    783781                {
    784782                        Token fn;
    785783                        fn.str = new string( "^?{}" );                          // location undefined
    786                         $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );
     784                        $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );
    787785                }
    788786        ;
     
    815813        field_name
    816814        | FLOATING_DECIMALconstant field
    817                 { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), maybeMoveBuild( $2 ) ) ); }
     815                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild( $2 ) ) ); }
    818816        | FLOATING_DECIMALconstant '[' field_name_list ']'
    819                 { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), build_tuple( yylloc, $3 ) ) ); }
     817                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); }
    820818        | field_name '.' field
    821                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); }
     819                { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild( $3 ) ) ); }
    822820        | field_name '.' '[' field_name_list ']'
    823                 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
     821                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    824822        | field_name ARROW field
    825                 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); }
     823                { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild( $3 ) ) ); }
    826824        | field_name ARROW '[' field_name_list ']'
    827                 { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
     825                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); }
    828826        ;
    829827
    830828field_name:
    831829        INTEGERconstant fraction_constants_opt
    832                 { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_constantInteger( yylloc, *$1 ), $2 ) ); }
     830                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
    833831        | FLOATINGconstant fraction_constants_opt
    834                 { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_field_name_FLOATINGconstant( yylloc, *$1 ), $2 ) ); }
     832                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    835833        | identifier_at fraction_constants_opt                          // CFA, allow anonymous fields
    836834                {
    837                         $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_varref( yylloc, $1 ), $2 ) );
     835                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    838836                }
    839837        ;
     
    844842        | fraction_constants_opt FLOATING_FRACTIONconstant
    845843                {
    846                         ast::Expr * constant = build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 );
    847                         $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( yylloc, $1, constant ) ) : new ExpressionNode( constant );
     844                        Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 );
     845                        $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1, constant ) ) : new ExpressionNode( constant );
    848846                }
    849847        ;
     
    864862                {
    865863                        switch ( $1 ) {
    866                         case OperKinds::AddressOf:
    867                                 $$ = new ExpressionNode( new ast::AddressExpr( maybeMoveBuild( $2 ) ) );
     864                          case OperKinds::AddressOf:
     865                                $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild( $2 ) ) );
    868866                                break;
    869                         case OperKinds::PointTo:
    870                                 $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) );
     867                          case OperKinds::PointTo:
     868                                $$ = new ExpressionNode( build_unary_val( $1, $2 ) );
    871869                                break;
    872                         case OperKinds::And:
    873                                 $$ = new ExpressionNode( new ast::AddressExpr( new ast::AddressExpr( maybeMoveBuild( $2 ) ) ) );
     870                          case OperKinds::And:
     871                                $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild( $2 ) ) ) );
    874872                                break;
    875                         default:
     873                          default:
    876874                                assert( false );
    877875                        }
    878876                }
    879877        | unary_operator cast_expression
    880                 { $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) ); }
     878                { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
    881879        | ICR unary_expression
    882                 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Incr, $2 ) ); }
     880                { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); }
    883881        | DECR unary_expression
    884                 { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Decr, $2 ) ); }
     882                { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); }
    885883        | SIZEOF unary_expression
    886                 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
     884                { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild( $2 ) ) ); }
    887885        | SIZEOF '(' type_no_function ')'
    888                 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     886                { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuildType( $3 ) ) ); }
    889887        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    890                 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
     888                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild( $2 ) ) ); }
    891889        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    892                 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
     890                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
    893891        | OFFSETOF '(' type_no_function ',' identifier ')'
    894                 { $$ = new ExpressionNode( build_offsetOf( yylloc, $3, build_varref( yylloc, $5 ) ) ); }
     892                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    895893        | TYPEID '(' type_no_function ')'
    896894                {
     
    917915        unary_expression
    918916        | '(' type_no_function ')' cast_expression
    919                 { $$ = new ExpressionNode( build_cast( yylloc, $2, $4 ) ); }
     917                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    920918        | '(' aggregate_control '&' ')' cast_expression         // CFA
    921                 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); }
     919                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    922920        | '(' aggregate_control '*' ')' cast_expression         // CFA
    923                 { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); }
     921                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    924922        | '(' VIRTUAL ')' cast_expression                                       // CFA
    925                 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     923                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    926924        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    927                 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
     925                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
    928926        | '(' RETURN type_no_function ')' cast_expression       // CFA
    929927                { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; }
     
    933931                { SemanticError( yylloc, "Qualifier cast is currently unimplemented." ); $$ = nullptr; }
    934932//      | '(' type_no_function ')' tuple
    935 //              { $$ = new ast::ExpressionNode( build_cast( yylloc, $2, $4 ) ); }
     933//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    936934        ;
    937935
     
    951949        cast_expression
    952950        | exponential_expression '\\' cast_expression
    953                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Exp, $1, $3 ) ); }
     951                { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
    954952        ;
    955953
     
    957955        exponential_expression
    958956        | multiplicative_expression '*' exponential_expression
    959                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mul, $1, $3 ) ); }
     957                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    960958        | multiplicative_expression '/' exponential_expression
    961                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Div, $1, $3 ) ); }
     959                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    962960        | multiplicative_expression '%' exponential_expression
    963                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mod, $1, $3 ) ); }
     961                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    964962        ;
    965963
     
    967965        multiplicative_expression
    968966        | additive_expression '+' multiplicative_expression
    969                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Plus, $1, $3 ) ); }
     967                { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
    970968        | additive_expression '-' multiplicative_expression
    971                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Minus, $1, $3 ) ); }
     969                { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
    972970        ;
    973971
     
    975973        additive_expression
    976974        | shift_expression LS additive_expression
    977                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LShift, $1, $3 ) ); }
     975                { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
    978976        | shift_expression RS additive_expression
    979                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::RShift, $1, $3 ) ); }
     977                { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
    980978        ;
    981979
     
    983981        shift_expression
    984982        | relational_expression '<' shift_expression
    985                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LThan, $1, $3 ) ); }
     983                { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
    986984        | relational_expression '>' shift_expression
    987                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GThan, $1, $3 ) ); }
     985                { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
    988986        | relational_expression LE shift_expression
    989                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LEThan, $1, $3 ) ); }
     987                { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
    990988        | relational_expression GE shift_expression
    991                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GEThan, $1, $3 ) ); }
     989                { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
    992990        ;
    993991
     
    995993        relational_expression
    996994        | equality_expression EQ relational_expression
    997                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Eq, $1, $3 ) ); }
     995                { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
    998996        | equality_expression NE relational_expression
    999                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Neq, $1, $3 ) ); }
     997                { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
    1000998        ;
    1001999
     
    10031001        equality_expression
    10041002        | AND_expression '&' equality_expression
    1005                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitAnd, $1, $3 ) ); }
     1003                { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
    10061004        ;
    10071005
     
    10091007        AND_expression
    10101008        | exclusive_OR_expression '^' AND_expression
    1011                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Xor, $1, $3 ) ); }
     1009                { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
    10121010        ;
    10131011
     
    10151013        exclusive_OR_expression
    10161014        | inclusive_OR_expression '|' exclusive_OR_expression
    1017                 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitOr, $1, $3 ) ); }
     1015                { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
    10181016        ;
    10191017
     
    10211019        inclusive_OR_expression
    10221020        | logical_AND_expression ANDAND inclusive_OR_expression
    1023                 { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::AndExpr ) ); }
     1021                { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); }
    10241022        ;
    10251023
     
    10271025        logical_AND_expression
    10281026        | logical_OR_expression OROR logical_AND_expression
    1029                 { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::OrExpr ) ); }
     1027                { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); }
    10301028        ;
    10311029
     
    10331031        logical_OR_expression
    10341032        | logical_OR_expression '?' comma_expression ':' conditional_expression
    1035                 { $$ = new ExpressionNode( build_cond( yylloc, $1, $3, $5 ) ); }
     1033                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    10361034                // FIX ME: computes $1 twice
    10371035        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    1038                 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1, $4 ) ); }
     1036                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
    10391037        ;
    10401038
     
    10511049//                              SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr;
    10521050//                      } else {
    1053                                 $$ = new ExpressionNode( build_binary_val( yylloc, $2, $1, $3 ) );
     1051                                $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) );
    10541052//                      } // if
    10551053                }
     
    10961094//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    10971095        '[' ',' tuple_expression_list ']'
    1098                 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
     1096                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    10991097        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    1100                 { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $6 ) ) )); }
     1098                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
    11011099        ;
    11021100
     
    11141112        assignment_expression
    11151113        | comma_expression ',' assignment_expression
    1116                 { $$ = new ExpressionNode( new ast::CommaExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     1114                { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    11171115        ;
    11181116
     
    11411139        | asm_statement
    11421140        | DIRECTIVE
    1143                 { $$ = new StatementNode( build_directive( yylloc, $1 ) ); }
     1141                { $$ = new StatementNode( build_directive( $1 ) ); }
    11441142        ;
    11451143
     
    11471145                // labels cannot be identifiers 0 or 1
    11481146        identifier_or_type_name ':' attribute_list_opt statement
    1149                 { $$ = $4->add_label( yylloc, $1, $3 ); }
     1147                { $$ = $4->add_label( $1, $3 ); }
    11501148        | identifier_or_type_name ':' attribute_list_opt error // syntax error
    11511149                {
     
    11591157compound_statement:
    11601158        '{' '}'
    1161                 { $$ = new StatementNode( build_compound( yylloc, (StatementNode *)0 ) ); }
     1159                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    11621160        | '{' push
    11631161          local_label_declaration_opt                                           // GCC, local labels appear at start of block
    11641162          statement_decl_list                                                           // C99, intermix declarations and statements
    11651163          pop '}'
    1166                 { $$ = new StatementNode( build_compound( yylloc, $4 ) ); }
     1164                { $$ = new StatementNode( build_compound( $4 ) ); }
    11671165        ;
    11681166
     
    11951193expression_statement:
    11961194        comma_expression_opt ';'
    1197                 { $$ = new StatementNode( build_expr( yylloc, $1 ) ); }
     1195                { $$ = new StatementNode( build_expr( $1 ) ); }
    11981196        ;
    11991197
     
    12041202                { $$ = $2; }
    12051203        | SWITCH '(' comma_expression ')' case_clause
    1206                 { $$ = new StatementNode( build_switch( yylloc, true, $3, $5 ) ); }
     1204                { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
    12071205        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
    12081206                {
    1209                         StatementNode *sw = new StatementNode( build_switch( yylloc, true, $3, $8 ) );
     1207                        StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
    12101208                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    12111209                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    12131211                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    12141212                        // statement.
    1215                         $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     1213                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    12161214                }
    12171215        | SWITCH '(' comma_expression ')' '{' error '}'         // CFA, syntax error
    12181216                { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    12191217        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    1220                 { $$ = new StatementNode( build_switch( yylloc, false, $3, $5 ) ); }
     1218                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
    12211219        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
    12221220                {
    1223                         StatementNode *sw = new StatementNode( build_switch( yylloc, false, $3, $8 ) );
    1224                         $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     1221                        StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
     1222                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    12251223                }
    12261224        | CHOOSE '(' comma_expression ')' '{' error '}'         // CFA, syntax error
     
    12311229        IF '(' conditional_declaration ')' statement            %prec THEN
    12321230                // explicitly deal with the shift/reduce conflict on if/else
    1233                 { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), nullptr ) ); }
     1231                { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), nullptr ) ); }
    12341232        | IF '(' conditional_declaration ')' statement ELSE statement
    1235                 { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), maybe_build_compound( yylloc, $7 ) ) ); }
     1233                { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), maybe_build_compound( $7 ) ) ); }
    12361234        ;
    12371235
     
    12531251        constant_expression                                                     { $$ = $1; }
    12541252        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    1255                 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     1253                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    12561254        | subrange                                                                                      // CFA, subrange
    12571255        ;
     
    12691267        | CASE case_value_list error                                            // syntax error
    12701268                { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; }
    1271         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default( yylloc ) ); }
     1269        | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
    12721270                // A semantic check is required to ensure only one default clause per switch/choose statement.
    12731271        | DEFAULT error                                                                         //  syntax error
     
    12811279
    12821280case_clause:                                                                                    // CFA
    1283         case_label_list statement                                       { $$ = $1->append_last_case( maybe_build_compound( yylloc, $2 ) ); }
     1281        case_label_list statement                                       { $$ = $1->append_last_case( maybe_build_compound( $2 ) ); }
    12841282        ;
    12851283
     
    12921290switch_clause_list:                                                                             // CFA
    12931291        case_label_list statement_list_nodecl
    1294                 { $$ = $1->append_last_case( new StatementNode( build_compound( yylloc, $2 ) ) ); }
     1292                { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
    12951293        | switch_clause_list case_label_list statement_list_nodecl
    1296                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ) ); }
     1294                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    12971295        ;
    12981296
    12991297iteration_statement:
    13001298        WHILE '(' ')' statement                                                         %prec THEN // CFA => while ( 1 )
    1301                 { $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) ); }
     1299                { $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( $4 ) ) ); }
    13021300        | WHILE '(' ')' statement ELSE statement                        // CFA
    13031301                {
    1304                         $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) );
     1302                        $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( $4 ) ) );
    13051303                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13061304                }
    13071305        | WHILE '(' conditional_declaration ')' statement       %prec THEN
    1308                 { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
     1306                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
    13091307        | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
    1310                 { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
     1308                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ), $7 ) ); }
    13111309        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    1312                 { $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) ); }
     1310                { $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound( $2 ) ) ); }
    13131311        | DO statement WHILE '(' ')' ELSE statement                     // CFA
    13141312                {
    1315                         $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) );
     1313                        $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound( $2 ) ) );
    13161314                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13171315                }
    13181316        | DO statement WHILE '(' comma_expression ')' ';'
    1319                 { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ) ) ); }
     1317                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    13201318        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    1321                 { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ), $8 ) ); }
     1319                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
    13221320        | FOR '(' ')' statement                                                         %prec THEN // CFA => for ( ;; )
    1323                 { $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) ); }
     1321                { $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) ); }
    13241322        | FOR '(' ')' statement ELSE statement                          // CFA
    13251323                {
    1326                         $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) );
     1324                        $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) );
    13271325                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13281326                }
    13291327        | FOR '(' for_control_expression_list ')' statement     %prec THEN
    1330                 { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
     1328                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
    13311329        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    1332                 { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
     1330                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
    13331331        ;
    13341332
     
    13441342                        if ( $1->condition ) {
    13451343                                if ( $3->condition ) {
    1346                                         $1->condition->expr.reset( new ast::LogicalExpr( yylloc, $1->condition->expr.release(), $3->condition->expr.release(), ast::AndExpr ) );
     1344                                        $1->condition->expr.reset( new LogicalExpr( $1->condition->expr.release(), $3->condition->expr.release(), true ) );
    13471345                                } // if
    13481346                        } else $1->condition = $3->condition;
    13491347                        if ( $1->change ) {
    13501348                                if ( $3->change ) {
    1351                                         $1->change->expr.reset( new ast::CommaExpr( yylloc, $1->change->expr.release(), $3->change->expr.release() ) );
     1349                                        $1->change->expr.reset( new CommaExpr( $1->change->expr.release(), $3->change->expr.release() ) );
    13521350                                } // if
    13531351                        } else $1->change = $3->change;
     
    13611359        | comma_expression ';' comma_expression_opt ';' comma_expression_opt
    13621360                {
    1363                         StatementNode * init = $1 ? new StatementNode( new ast::ExprStmt( yylloc, maybeMoveBuild( $1 ) ) ) : nullptr;
     1361                        StatementNode * init = $1 ? new StatementNode( new ExprStmt( maybeMoveBuild( $1 ) ) ) : nullptr;
    13641362                        $$ = new ForCtrl( init, $3, $5 );
    13651363                }
     
    13731371
    13741372        | comma_expression                                                                      // CFA, anonymous loop-index
    1375                 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); }
     1373                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); }
    13761374        | downupdowneq comma_expression                                         // CFA, anonymous loop-index
    1377                 { $$ = forCtrl( yylloc, $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); }
     1375                { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); }
    13781376
    13791377        | comma_expression updowneq comma_expression            // CFA, anonymous loop-index
    1380                 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }
     1378                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }
    13811379        | '@' updowneq comma_expression                                         // CFA, anonymous loop-index
    13821380                {
    13831381                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1384                         else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
     1382                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
    13851383                }
    13861384        | comma_expression updowneq '@'                                         // CFA, anonymous loop-index
     
    13901388                }
    13911389        | comma_expression updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index
    1392                 { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }
     1390                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }
    13931391        | '@' updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index
    13941392                {
    13951393                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1396                         else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
     1394                        else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
    13971395                }
    13981396        | comma_expression updowneq '@' '~' comma_expression // CFA, anonymous loop-index
     
    14131411
    14141412        | comma_expression ';' comma_expression                         // CFA
    1415                 { $$ = forCtrl( yylloc, $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); }
     1413                { $$ = forCtrl( $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); }
    14161414        | comma_expression ';' downupdowneq comma_expression // CFA
    1417                 { $$ = forCtrl( yylloc, $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); }
     1415                { $$ = forCtrl( $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); }
    14181416
    14191417        | comma_expression ';' comma_expression updowneq comma_expression // CFA
    1420                 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }
     1418                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }
    14211419        | comma_expression ';' '@' updowneq comma_expression // CFA
    14221420                {
    14231421                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1424                         else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
     1422                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
    14251423                }
    14261424        | comma_expression ';' comma_expression updowneq '@' // CFA
     
    14281426                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14291427                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1430                         else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
     1428                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
    14311429                }
    14321430        | comma_expression ';' '@' updowneq '@'                         // CFA, error
     
    14341432
    14351433        | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA
    1436                 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
     1434                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
    14371435        | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, error
    14381436                {
    14391437                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1440                         else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, $7 );
     1438                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, $7 );
    14411439                }
    14421440        | comma_expression ';' comma_expression updowneq '@' '~' comma_expression // CFA
     
    14441442                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14451443                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1446                         else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, $7 );
     1444                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, $7 );
    14471445                }
    14481446        | comma_expression ';' comma_expression updowneq comma_expression '~' '@' // CFA
    1449                 { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
     1447                { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
    14501448        | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, error
    14511449                {
    14521450                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1453                         else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, nullptr );
     1451                        else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, nullptr );
    14541452                }
    14551453        | comma_expression ';' comma_expression updowneq '@' '~' '@' // CFA
     
    14571455                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14581456                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1459                         else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, nullptr );
     1457                        else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, nullptr );
    14601458                }
    14611459        | comma_expression ';' '@' updowneq '@' '~' '@' // CFA
     
    14631461
    14641462        | declaration comma_expression                                          // CFA
    1465                 { $$ = forCtrl( yylloc, $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); }
     1463                { $$ = forCtrl( $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); }
    14661464        | declaration downupdowneq comma_expression                     // CFA
    1467                 { $$ = forCtrl( yylloc, $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); }
     1465                { $$ = forCtrl( $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); }
    14681466
    14691467        | declaration comma_expression updowneq comma_expression // CFA
    1470                 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }
     1468                { $$ = forCtrl( $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }
    14711469        | declaration '@' updowneq comma_expression                     // CFA
    14721470                {
    14731471                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1474                         else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, NEW_ONE );
     1472                        else $$ = forCtrl( $1, $4, $3, nullptr, NEW_ONE );
    14751473                }
    14761474        | declaration comma_expression updowneq '@'                     // CFA
     
    14781476                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14791477                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1480                         else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, NEW_ONE );
     1478                        else $$ = forCtrl( $1, $2, $3, nullptr, NEW_ONE );
    14811479                }
    14821480
    14831481        | declaration comma_expression updowneq comma_expression '~' comma_expression // CFA
    1484                 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }
     1482                { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }
    14851483        | declaration '@' updowneq comma_expression '~' comma_expression // CFA
    14861484                {
    14871485                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1488                         else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, $6 );
     1486                        else $$ = forCtrl( $1, $4, $3, nullptr, $6 );
    14891487                }
    14901488        | declaration comma_expression updowneq '@' '~' comma_expression // CFA
     
    14921490                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14931491                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1494                         else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, $6 );
     1492                        else $$ = forCtrl( $1, $2, $3, nullptr, $6 );
    14951493                }
    14961494        | declaration comma_expression updowneq comma_expression '~' '@' // CFA
    1497                 { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }
     1495                { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }
    14981496        | declaration '@' updowneq comma_expression '~' '@' // CFA
    14991497                {
    15001498                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1501                         else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, nullptr );
     1499                        else $$ = forCtrl( $1, $4, $3, nullptr, nullptr );
    15021500                }
    15031501        | declaration comma_expression updowneq '@' '~' '@'     // CFA
     
    15051503                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    15061504                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1507                         else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, nullptr );
     1505                        else $$ = forCtrl( $1, $2, $3, nullptr, nullptr );
    15081506                }
    15091507        | declaration '@' updowneq '@' '~' '@'                          // CFA, error
     
    15481546jump_statement:
    15491547        GOTO identifier_or_type_name ';'
    1550                 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Goto ) ); }
     1548                { $$ = new StatementNode( build_branch( $2, BranchStmt::Goto ) ); }
    15511549        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    15521550                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
     
    15551553                // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
    15561554        | fall_through_name ';'                                                         // CFA
    1557                 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThrough ) ); }
     1555                { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
    15581556        | fall_through_name identifier_or_type_name ';'         // CFA
    1559                 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::FallThrough ) ); }
     1557                { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
    15601558        | fall_through_name DEFAULT ';'                                         // CFA
    1561                 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThroughDefault ) ); }
     1559                { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }
    15621560        | CONTINUE ';'
    15631561                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    1564                 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Continue ) ); }
     1562                { $$ = new StatementNode( build_branch( BranchStmt::Continue ) ); }
    15651563        | CONTINUE identifier_or_type_name ';'                          // CFA, multi-level continue
    15661564                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    15671565                // the target of the transfer appears only at the start of an iteration statement.
    1568                 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Continue ) ); }
     1566                { $$ = new StatementNode( build_branch( $2, BranchStmt::Continue ) ); }
    15691567        | BREAK ';'
    15701568                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    1571                 { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Break ) ); }
     1569                { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); }
    15721570        | BREAK identifier_or_type_name ';'                                     // CFA, multi-level exit
    15731571                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    15741572                // the target of the transfer appears only at the start of an iteration statement.
    1575                 { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Break ) ); }
     1573                { $$ = new StatementNode( build_branch( $2, BranchStmt::Break ) ); }
    15761574        | RETURN comma_expression_opt ';'
    1577                 { $$ = new StatementNode( build_return( yylloc, $2 ) ); }
     1575                { $$ = new StatementNode( build_return( $2 ) ); }
    15781576        | RETURN '{' initializer_list_opt comma_opt '}' ';'
    15791577                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    15801578        | SUSPEND ';'
    1581                 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::None ) ); }
     1579                { $$ = new StatementNode( build_suspend( nullptr ) ); }
    15821580        | SUSPEND compound_statement
    1583                 { $$ = new StatementNode( build_suspend( yylloc, $2, ast::SuspendStmt::None ) ); }
     1581                { $$ = new StatementNode( build_suspend( $2 ) ); }
    15841582        | SUSPEND COROUTINE ';'
    1585                 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Coroutine ) ); }
     1583                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Coroutine ) ); }
    15861584        | SUSPEND COROUTINE compound_statement
    1587                 { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Coroutine ) ); }
     1585                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Coroutine ) ); }
    15881586        | SUSPEND GENERATOR ';'
    1589                 { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Generator ) ); }
     1587                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Generator ) ); }
    15901588        | SUSPEND GENERATOR compound_statement
    1591                 { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Generator ) ); }
     1589                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Generator ) ); }
    15921590        | THROW assignment_expression_opt ';'                           // handles rethrow
    1593                 { $$ = new StatementNode( build_throw( yylloc, $2 ) ); }
     1591                { $$ = new StatementNode( build_throw( $2 ) ); }
    15941592        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
    1595                 { $$ = new StatementNode( build_resume( yylloc, $2 ) ); }
     1593                { $$ = new StatementNode( build_resume( $2 ) ); }
    15961594        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    15971595                { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
     
    16051603with_statement:
    16061604        WITH '(' tuple_expression_list ')' statement
    1607                 { $$ = new StatementNode( build_with( yylloc, $3, $5 ) ); }
     1605                { $$ = new StatementNode( build_with( $3, $5 ) ); }
    16081606        ;
    16091607
     
    16131611                {
    16141612                        if ( ! $3 ) { SemanticError( yylloc, "mutex argument list cannot be empty." ); $$ = nullptr; }
    1615                         $$ = new StatementNode( build_mutex( yylloc, $3, $5 ) );
     1613                        $$ = new StatementNode( build_mutex( $3, $5 ) );
    16161614                }
    16171615        ;
     
    16521650        when_clause_opt waitfor statement                                       %prec THEN
    16531651                // Called first: create header for WaitForStmt.
    1654                 { $$ = build_waitfor( yylloc, new ast::WaitForStmt( yylloc ), $1, $2, maybe_build_compound( yylloc, $3 ) ); }
     1652                { $$ = build_waitfor( new WaitForStmt(), $1, $2, maybe_build_compound( $3 ) ); }
    16551653        | wor_waitfor_clause wor when_clause_opt waitfor statement
    1656                 { $$ = build_waitfor( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); }
     1654                { $$ = build_waitfor( $1, $3, $4, maybe_build_compound( $5 ) ); }
    16571655        | wor_waitfor_clause wor when_clause_opt ELSE statement
    1658                 { $$ = build_waitfor_else( yylloc, $1, $3, maybe_build_compound( yylloc, $5 ) ); }
     1656                { $$ = build_waitfor_else( $1, $3, maybe_build_compound( $5 ) ); }
    16591657        | wor_waitfor_clause wor when_clause_opt timeout statement      %prec THEN
    1660                 { $$ = build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); }
     1658                { $$ = build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ); }
    16611659        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    16621660        | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error
    16631661                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    16641662        | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
    1665                 { $$ = build_waitfor_else( yylloc, build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ), $7, maybe_build_compound( yylloc, $9 ) ); }
    1666         ;
     1663                { $$ = build_waitfor_else( build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ), $7, maybe_build_compound( $9 ) ); }
    16671664
    16681665waitfor_statement:
     
    17141711        wor_waituntil_clause                                                            %prec THEN
    17151712                // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement.
    1716                 { $$ = new StatementNode( build_compound( yylloc, nullptr ) ); }
     1713                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    17171714        ;
    17181715
    17191716exception_statement:
    1720         TRY compound_statement handler_clause                                   %prec THEN
    1721                 { $$ = new StatementNode( build_try( yylloc, $2, $3, nullptr ) ); }
     1717        TRY compound_statement handler_clause                           %prec THEN
     1718                { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); }
    17221719        | TRY compound_statement finally_clause
    1723                 { $$ = new StatementNode( build_try( yylloc, $2, nullptr, $3 ) ); }
     1720                { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); }
    17241721        | TRY compound_statement handler_clause finally_clause
    1725                 { $$ = new StatementNode( build_try( yylloc, $2, $3, $4 ) ); }
     1722                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
    17261723        ;
    17271724
    17281725handler_clause:
    17291726        handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1730                 { $$ = new StatementNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
     1727                { $$ = new StatementNode( build_catch( $1, $4, $6, $8 ) ); }
    17311728        | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1732                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
     1729                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $5, $7, $9 ) ) ); }
    17331730        ;
    17341731
     
    17401737
    17411738handler_key:
    1742         CATCH                                                                           { $$ = ast::Terminate; }
    1743         | RECOVER                                                                       { $$ = ast::Terminate; }
    1744         | CATCHRESUME                                                           { $$ = ast::Resume; }
    1745         | FIXUP                                                                         { $$ = ast::Resume; }
     1739        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1740        | RECOVER                                                                       { $$ = CatchStmt::Terminate; }
     1741        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
     1742        | FIXUP                                                                         { $$ = CatchStmt::Resume; }
    17461743        ;
    17471744
    17481745finally_clause:
    1749         FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( yylloc, $2 ) ); }
     1746        FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
    17501747        ;
    17511748
     
    17731770asm_statement:
    17741771        ASM asm_volatile_opt '(' string_literal ')' ';'
    1775                 { $$ = new StatementNode( build_asm( yylloc, $2, $4, nullptr ) ); }
     1772                { $$ = new StatementNode( build_asm( $2, $4, nullptr ) ); }
    17761773        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC
    1777                 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6 ) ); }
     1774                { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); }
    17781775        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    1779                 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8 ) ); }
     1776                { $$ = new StatementNode( build_asm( $2, $4, $6, $8 ) ); }
    17801777        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    1781                 { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8, $10 ) ); }
     1778                { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); }
    17821779        | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    1783                 { $$ = new StatementNode( build_asm( yylloc, $2, $5, nullptr, $8, $10, $12 ) ); }
     1780                { $$ = new StatementNode( build_asm( $2, $5, nullptr, $8, $10, $12 ) ); }
    17841781        ;
    17851782
     
    18051802asm_operand:                                                                                    // GCC
    18061803        string_literal '(' constant_expression ')'
    1807                 { $$ = new ExpressionNode( new ast::AsmExpr( yylloc, "", $1, maybeMoveBuild( $3 ) ) ); }
     1804                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild( $3 ) ) ); }
    18081805        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
    1809                 {
    1810                         $$ = new ExpressionNode( new ast::AsmExpr( yylloc, *$2.str, $4, maybeMoveBuild( $6 ) ) );
    1811                         delete $2.str;
    1812                 }
     1806                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild( $6 ) ) ); }
    18131807        ;
    18141808
     
    18251819        identifier
    18261820                {
    1827                         $$ = new LabelNode(); $$->labels.emplace_back( yylloc, *$1 );
     1821                        $$ = new LabelNode(); $$->labels.push_back( *$1 );
    18281822                        delete $1;                                                                      // allocated by lexer
    18291823                }
    18301824        | label_list ',' identifier
    18311825                {
    1832                         $$ = $1; $1->labels.emplace_back( yylloc, *$3 );
     1826                        $$ = $1; $1->labels.push_back( *$3 );
    18331827                        delete $3;                                                                      // allocated by lexer
    18341828                }
     
    18931887                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    18941888        | STATICASSERT '(' constant_expression ')' ';'          // CFA
    1895                 { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( yylloc, *new string( "\"\"" ) ) ); }
     1889                { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( *new string( "\"\"" ) ) ); }
    18961890
    18971891// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    20932087                {
    20942088                        SemanticError( yylloc, ::toString( "Missing ';' after end of ",
    2095                                 $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ),
     2089                                $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
    20962090                                " declaration" ) );
    20972091                        $$ = nullptr;
     
    23272321                { $$ = DeclarationNode::newTypeof( $3 ); }
    23282322        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof( x ) y;
    2329                 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ), true ); }
     2323                { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ), true ); }
    23302324        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    23312325                { $$ = DeclarationNode::newTypeof( $3, true ); }
     
    25212515aggregate_data:
    25222516        STRUCT vtable_opt
    2523                 { $$ = ast::AggregateDecl::Struct; }
     2517                { $$ = AggregateDecl::Struct; }
    25242518        | UNION
    2525                 { $$ = ast::AggregateDecl::Union; }
     2519                { $$ = AggregateDecl::Union; }
    25262520        | EXCEPTION                                                                                     // CFA
    2527                 { $$ = ast::AggregateDecl::Exception; }
    2528           //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = ast::AggregateDecl::NoAggregate; }
     2521                { $$ = AggregateDecl::Exception; }
     2522          //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    25292523        ;
    25302524
    25312525aggregate_control:                                                                              // CFA
    25322526        MONITOR
    2533                 { $$ = ast::AggregateDecl::Monitor; }
     2527                { $$ = AggregateDecl::Monitor; }
    25342528        | MUTEX STRUCT
    2535                 { $$ = ast::AggregateDecl::Monitor; }
     2529                { $$ = AggregateDecl::Monitor; }
    25362530        | GENERATOR
    2537                 { $$ = ast::AggregateDecl::Generator; }
     2531                { $$ = AggregateDecl::Generator; }
    25382532        | MUTEX GENERATOR
    2539                 {
    2540                         SemanticError( yylloc, "monitor generator is currently unimplemented." );
    2541                         $$ = ast::AggregateDecl::NoAggregate;
    2542                 }
     2533                { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    25432534        | COROUTINE
    2544                 { $$ = ast::AggregateDecl::Coroutine; }
     2535                { $$ = AggregateDecl::Coroutine; }
    25452536        | MUTEX COROUTINE
    2546                 {
    2547                         SemanticError( yylloc, "monitor coroutine is currently unimplemented." );
    2548                         $$ = ast::AggregateDecl::NoAggregate;
    2549                 }
     2537                { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    25502538        | THREAD
    2551                 { $$ = ast::AggregateDecl::Thread; }
     2539                { $$ = AggregateDecl::Thread; }
    25522540        | MUTEX THREAD
    2553                 {
    2554                         SemanticError( yylloc, "monitor thread is currently unimplemented." );
    2555                         $$ = ast::AggregateDecl::NoAggregate;
    2556                 }
     2541                { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    25572542        ;
    25582543
     
    29042889        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    29052890        | identifier_at ':'                                                                     // GCC, field name
    2906                 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
     2891                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    29072892        ;
    29082893
     
    29162901designator:
    29172902        '.' identifier_at                                                                       // C99, field name
    2918                 { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); }
     2903                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    29192904        | '[' push assignment_expression pop ']'                        // C99, single array element
    29202905                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     
    29232908                { $$ = $3; }
    29242909        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    2925                 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }
     2910                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }
    29262911        | '.' '[' push field_name_list pop ']'                          // CFA, tuple field selector
    29272912                { $$ = $4; }
     
    29632948                {
    29642949                        typedefTable.addToScope( *$2, TYPEDEFname, "9" );
    2965                         if ( $1 == ast::TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }
    2966                         if ( $1 == ast::TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }
    2967                         if ( $1 == ast::TypeDecl::Ttype ) { SemanticError( yylloc, "ttype keyword is deprecated, use T ..." ); }
     2950                        if ( $1 == TypeDecl::Otype ) { SemanticError( yylloc, "otype keyword is deprecated, use T " ); }
     2951                        if ( $1 == TypeDecl::Dtype ) { SemanticError( yylloc, "dtype keyword is deprecated, use T &" ); }
     2952                        if ( $1 == TypeDecl::Ttype ) { SemanticError( yylloc, "ttype keyword is deprecated, use T ..." ); }
    29682953                }
    29692954          type_initializer_opt assertion_list_opt
     
    29762961                {
    29772962                        typedefTable.addToScope( *$2, TYPEDIMname, "9" );
    2978                         $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 );
     2963                        $$ = DeclarationNode::newTypeParam( TypeDecl::Dimension, $2 );
    29792964                }
    29802965        // | type_specifier identifier_parameter_declarator
    29812966        | assertion_list
    2982                 { $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2967                { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    29832968        ;
    29842969
    29852970new_type_class:                                                                                 // CFA
    29862971        // empty
    2987                 { $$ = ast::TypeDecl::Otype; }
     2972                { $$ = TypeDecl::Otype; }
    29882973        | '&'
    2989                 { $$ = ast::TypeDecl::Dtype; }
     2974                { $$ = TypeDecl::Dtype; }
    29902975        | '*'
    2991                 { $$ = ast::TypeDecl::DStype; }                                         // dtype + sized
     2976                { $$ = TypeDecl::DStype; }                                              // dtype + sized
    29922977        // | '(' '*' ')'
    2993         //      { $$ = ast::TypeDecl::Ftype; }
     2978        //      { $$ = TypeDecl::Ftype; }
    29942979        | ELLIPSIS
    2995                 { $$ = ast::TypeDecl::Ttype; }
     2980                { $$ = TypeDecl::Ttype; }
    29962981        ;
    29972982
    29982983type_class:                                                                                             // CFA
    29992984        OTYPE
    3000                 { $$ = ast::TypeDecl::Otype; }
     2985                { $$ = TypeDecl::Otype; }
    30012986        | DTYPE
    3002                 { $$ = ast::TypeDecl::Dtype; }
     2987                { $$ = TypeDecl::Dtype; }
    30032988        | FTYPE
    3004                 { $$ = ast::TypeDecl::Ftype; }
     2989                { $$ = TypeDecl::Ftype; }
    30052990        | TTYPE
    3006                 { $$ = ast::TypeDecl::Ttype; }
     2991                { $$ = TypeDecl::Ttype; }
    30072992        ;
    30082993
     
    30303015type_list:                                                                                              // CFA
    30313016        type
    3032                 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
     3017                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
    30333018        | assignment_expression
    30343019        | type_list ',' type
    3035                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
     3020                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    30363021        | type_list ',' assignment_expression
    30373022                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     
    31403125external_definition:
    31413126        DIRECTIVE
    3142                 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( yylloc, $1 ) ) ); }
     3127                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
    31433128        | declaration
    31443129                {
     
    31463131                        // unit, which is a dubious task, especially because C uses name rather than structural typing; hence it is
    31473132                        // disallowed at the moment.
    3148                         if ( $1->linkage == ast::Linkage::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
     3133                        if ( $1->linkage == LinkageSpec::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
    31493134                                if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) {
    31503135                                        SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr;
     
    31733158                }
    31743159        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    3175                 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( yylloc, false, $3, nullptr ) ) ); }
     3160                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); }
    31763161        | EXTERN STRINGliteral
    31773162                {
    31783163                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    3179                         linkage = ast::Linkage::update( yylloc, linkage, $2 );
     3164                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
    31803165                }
    31813166          up external_definition down
     
    31883173                {
    31893174                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    3190                         linkage = ast::Linkage::update( yylloc, linkage, $2 );
     3175                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
    31913176                }
    31923177          '{' up external_definition_list_opt down '}'
     
    33123297subrange:
    33133298        constant_expression '~' constant_expression                     // CFA, integer subrange
    3314                 { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     3299                { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    33153300        ;
    33163301
     
    38413826array_type_list:
    38423827        basic_type_name
    3843                 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
     3828                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
    38443829        | type_name
    3845                 { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
     3830                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
    38463831        | assignment_expression upupeq assignment_expression
    38473832        | array_type_list ',' basic_type_name
    3848                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
    3849         | array_type_list ',' type_name
    3850                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
     3833                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     3834        | array_type_list ',' type_name 
     3835                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    38513836        | array_type_list ',' assignment_expression upupeq assignment_expression
    38523837        ;
Note: See TracChangeset for help on using the changeset viewer.