Ignore:
Timestamp:
Apr 4, 2023, 10:12:57 PM (2 years ago)
Author:
Mike Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, master
Children:
9bb8ee42
Parents:
ff71057 (diff), bb7422a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rff71057 re02e13f  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 21:28:25 2023
    13 // Update Count     : 6328
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Apr  4 14:02:00 2023
     13// Update Count     : 6329
    1414//
    1515
     
    6464
    6565extern DeclarationNode * parseTree;
    66 extern LinkageSpec::Spec linkage;
     66extern ast::Linkage::Spec linkage;
    6767extern TypedefTable typedefTable;
    6868
    69 stack<LinkageSpec::Spec> linkageStack;
     69stack<ast::Linkage::Spec> linkageStack;
    7070
    7171bool appendStr( string & to, string & from ) {
     
    200200} // fieldDecl
    201201
    202 #define NEW_ZERO new ExpressionNode( build_constantInteger( *new string( "0" ) ) )
    203 #define NEW_ONE  new ExpressionNode( build_constantInteger( *new string( "1" ) ) )
     202#define NEW_ZERO new ExpressionNode( build_constantInteger( yylloc, *new string( "0" ) ) )
     203#define NEW_ONE  new ExpressionNode( build_constantInteger( yylloc, *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,
    210211                DeclarationNode * init,
    211212                enum OperKinds compop,
     
    213214                ExpressionNode * inc ) {
    214215        // Wrap both comp/inc if they are non-null.
    215         if ( comp ) comp = new ExpressionNode( build_binary_val(
     216        if ( comp ) comp = new ExpressionNode( build_binary_val( location,
    216217                compop,
    217                 new ExpressionNode( build_varref( new string( *init->name ) ) ),
     218                new ExpressionNode( build_varref( location, new string( *init->name ) ) ),
    218219                comp ) );
    219         if ( inc ) inc = new ExpressionNode( build_binary_val(
     220        if ( inc ) inc = new ExpressionNode( build_binary_val( location,
    220221                // choose += or -= for upto/downto
    221222                compop == OperKinds::LThan || compop == OperKinds::LEThan ? OperKinds::PlusAssn : OperKinds::MinusAssn,
    222                 new ExpressionNode( build_varref( new string( *init->name ) ) ),
     223                new ExpressionNode( build_varref( location, new string( *init->name ) ) ),
    223224                inc ) );
    224225        // The StatementNode call frees init->name, it must happen later.
     
    226227}
    227228
    228 ForCtrl * forCtrl( DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     229ForCtrl * forCtrl( const CodeLocation & location, DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
    229230        if ( index->initializer ) {
    230231                SemanticError( yylloc, "Direct initialization disallowed. Use instead: type var; initialization ~ comparison ~ increment." );
     
    234235        } // if
    235236        DeclarationNode * initDecl = index->addInitializer( new InitializerNode( start ) );
    236         return makeForCtrl( initDecl, compop, comp, inc );
     237        return makeForCtrl( location, initDecl, compop, comp, inc );
    237238} // forCtrl
    238239
    239 ForCtrl * 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 ) ) );
     240ForCtrl * 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 ) ) );
    243244        } // if
    244245        DeclarationNode * initDecl = distAttr(
     
    246247                DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) )
    247248        );
    248         return makeForCtrl( initDecl, compop, comp, inc );
     249        return makeForCtrl( location, initDecl, compop, comp, inc );
    249250} // forCtrl
    250251
    251 ForCtrl * 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 );
     252ForCtrl * 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 );
    257258                } else {
    258259                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
     
    299300        ExpressionNode * en;
    300301        DeclarationNode * decl;
    301         AggregateDecl::Aggregate aggKey;
    302         TypeDecl::Kind tclass;
     302        ast::AggregateDecl::Aggregate aggKey;
     303        ast::TypeDecl::Kind tclass;
    303304        StatementNode * sn;
    304         WaitForStmt * wfs;
    305         Expression * constant;
     305        ast::WaitForStmt * wfs;
     306        ast::Expr * constant;
    306307        CondCtl * ifctl;
    307308        ForCtrl * fctl;
     
    313314        bool flag;
    314315        EnumHiding hide;
    315         CatchStmt::Kind catch_kind;
    316         GenericExpr * genexpr;
     316        ast::ExceptionKind catch_kind;
     317        ast::GenericExpr * genexpr;
    317318}
    318319
    319 //************************* TERMINAL TOKENS ********************************
     320// ************************ TERMINAL TOKENS ********************************
    320321
    321322// keywords
     
    611612constant:
    612613                // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant".
    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 ) ); }
     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 ) ); }
    618619        ;
    619620
     
    641642
    642643string_literal:
    643         string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
     644        string_literal_list                                                     { $$ = build_constantStr( yylloc, *$1 ); }
    644645        ;
    645646
     
    658659primary_expression:
    659660        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    660                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     661                { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
    661662        | quasi_keyword
    662                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     663                { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
    663664        | TYPEDIMname                                                                           // CFA, generic length argument
    664665                // { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( DeclarationNode::newFromTypedef( $1 ) ) ) ); }
    665666                // { $$ = new ExpressionNode( build_varref( $1 ) ); }
    666                 { $$ = new ExpressionNode( build_dimensionref( $1 ) ); }
     667                { $$ = new ExpressionNode( build_dimensionref( yylloc, $1 ) ); }
    667668        | tuple
    668669        | '(' comma_expression ')'
    669670                { $$ = $2; }
    670671        | '(' compound_statement ')'                                            // GCC, lambda expression
    671                 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild( $2 ) ) ) ); }
     672                { $$ = new ExpressionNode( new ast::StmtExpr( yylloc, dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( $2 ) ) ) ); }
    672673        | type_name '.' identifier                                                      // CFA, nested type
    673                 { $$ = new ExpressionNode( build_qualified_expr( $1, build_varref( $3 ) ) ); }
     674                { $$ = new ExpressionNode( build_qualified_expr( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    674675        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
    675676                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    703704                {
    704705                        // steal the association node from the singleton and delete the wrapper
    705                         $1->associations.splice($1->associations.end(), $3->associations);
     706                        assert( 1 == $3->associations.size() );
     707                        $1->associations.push_back( $3->associations.front() );
    706708                        delete $3;
    707709                        $$ = $1;
     
    713715                {
    714716                        // create a GenericExpr wrapper with one association pair
    715                         $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild( $3 ) } } );
     717                        $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuildType( $1 ), maybeMoveBuild( $3 ) } } );
    716718                }
    717719        | DEFAULT ':' assignment_expression
    718                 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild( $3 ) } } ); }
     720                { $$ = new ast::GenericExpr( yylloc, nullptr, { { maybeMoveBuild( $3 ) } } ); }
    719721        ;
    720722
     
    725727                // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
    726728                // Current: Commas in subscripts make tuples.
    727                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
     729                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    728730        | postfix_expression '[' assignment_expression ']'
    729731                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
     
    731733                // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is
    732734                // equivalent to the old x[i,j].
    733                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
     735                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); }
    734736        | constant '[' assignment_expression ']'                        // 3[a], 'a'[a], 3.5[a]
    735                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
     737                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); }
    736738        | string_literal '[' assignment_expression ']'          // "abc"[3], 3["abc"]
    737                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }
     739                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }
    738740        | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call
    739741                {
    740742                        Token fn;
    741743                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    742                         $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
     744                        $$ = new ExpressionNode( new ast::ConstructorExpr( yylloc, build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    743745                }
    744746        | postfix_expression '(' argument_expression_list_opt ')'
    745                 { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     747                { $$ = new ExpressionNode( build_func( yylloc, $1, $3 ) ); }
    746748        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
    747749                // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
    748                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__builtin_va_arg") ) ),
     750                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg") ) ),
    749751                                                                                           (ExpressionNode *)($3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) )) ) ); }
    750752        | postfix_expression '`' identifier                                     // CFA, postfix call
    751                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     753                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
    752754        | constant '`' identifier                                                       // CFA, postfix call
    753                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     755                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
    754756        | string_literal '`' identifier                                         // CFA, postfix call
    755                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
     757                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
    756758        | postfix_expression '.' identifier
    757                 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     759                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    758760        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
    759                 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); }
     761                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); }
    760762        | postfix_expression FLOATING_FRACTIONconstant          // CFA, tuple index
    761                 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_FLOATING_FRACTIONconstant( *$2 ) ) ); }
     763                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 ) ) ); }
    762764        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    763                 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     765                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
    764766        | postfix_expression '.' aggregate_control
    765                 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
     767                { $$ = new ExpressionNode( build_keyword_cast( yylloc, $3, $1 ) ); }
    766768        | postfix_expression ARROW identifier
    767                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     769                { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
    768770        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
    769                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_constantInteger( *$3 ) ) ); }
     771                { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_constantInteger( yylloc, *$3 ) ) ); }
    770772        | postfix_expression ARROW '[' field_name_list ']'      // CFA, tuple field selector
    771                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); }
     773                { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
    772774        | postfix_expression ICR
    773                 { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); }
     775                { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::IncrPost, $1 ) ); }
    774776        | postfix_expression DECR
    775                 { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); }
     777                { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::DecrPost, $1 ) ); }
    776778        | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal
    777                 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     779                { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, new InitializerNode( $5, true ) ) ); }
    778780        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    779                 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
     781                { $$ = new ExpressionNode( build_compoundLiteral( yylloc, $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    780782        | '^' primary_expression '{' argument_expression_list_opt '}' // CFA, destructor call
    781783                {
    782784                        Token fn;
    783785                        fn.str = new string( "^?{}" );                          // location undefined
    784                         $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );
     786                        $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) );
    785787                }
    786788        ;
     
    813815        field_name
    814816        | FLOATING_DECIMALconstant field
    815                 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild( $2 ) ) ); }
     817                { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), maybeMoveBuild( $2 ) ) ); }
    816818        | FLOATING_DECIMALconstant '[' field_name_list ']'
    817                 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); }
     819                { $$ = new ExpressionNode( build_fieldSel( yylloc, new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( yylloc, *$1 ) ), build_tuple( yylloc, $3 ) ) ); }
    818820        | field_name '.' field
    819                 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild( $3 ) ) ); }
     821                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); }
    820822        | field_name '.' '[' field_name_list ']'
    821                 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     823                { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
    822824        | field_name ARROW field
    823                 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild( $3 ) ) ); }
     825                { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, maybeMoveBuild( $3 ) ) ); }
    824826        | field_name ARROW '[' field_name_list ']'
    825                 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); }
     827                { $$ = new ExpressionNode( build_pfieldSel( yylloc, $1, build_tuple( yylloc, $4 ) ) ); }
    826828        ;
    827829
    828830field_name:
    829831        INTEGERconstant fraction_constants_opt
    830                 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
     832                { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_constantInteger( yylloc, *$1 ), $2 ) ); }
    831833        | FLOATINGconstant fraction_constants_opt
    832                 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
     834                { $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_field_name_FLOATINGconstant( yylloc, *$1 ), $2 ) ); }
    833835        | identifier_at fraction_constants_opt                          // CFA, allow anonymous fields
    834836                {
    835                         $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     837                        $$ = new ExpressionNode( build_field_name_fraction_constants( yylloc, build_varref( yylloc, $1 ), $2 ) );
    836838                }
    837839        ;
     
    842844        | fraction_constants_opt FLOATING_FRACTIONconstant
    843845                {
    844                         Expression * constant = build_field_name_FLOATING_FRACTIONconstant( *$2 );
    845                         $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1, constant ) ) : new ExpressionNode( constant );
     846                        ast::Expr * constant = build_field_name_FLOATING_FRACTIONconstant( yylloc, *$2 );
     847                        $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( yylloc, $1, constant ) ) : new ExpressionNode( constant );
    846848                }
    847849        ;
     
    862864                {
    863865                        switch ( $1 ) {
    864                           case OperKinds::AddressOf:
    865                                 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild( $2 ) ) );
     866                        case OperKinds::AddressOf:
     867                                $$ = new ExpressionNode( new ast::AddressExpr( maybeMoveBuild( $2 ) ) );
    866868                                break;
    867                           case OperKinds::PointTo:
    868                                 $$ = new ExpressionNode( build_unary_val( $1, $2 ) );
     869                        case OperKinds::PointTo:
     870                                $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) );
    869871                                break;
    870                           case OperKinds::And:
    871                                 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild( $2 ) ) ) );
     872                        case OperKinds::And:
     873                                $$ = new ExpressionNode( new ast::AddressExpr( new ast::AddressExpr( maybeMoveBuild( $2 ) ) ) );
    872874                                break;
    873                           default:
     875                        default:
    874876                                assert( false );
    875877                        }
    876878                }
    877879        | unary_operator cast_expression
    878                 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
     880                { $$ = new ExpressionNode( build_unary_val( yylloc, $1, $2 ) ); }
    879881        | ICR unary_expression
    880                 { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); }
     882                { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Incr, $2 ) ); }
    881883        | DECR unary_expression
    882                 { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); }
     884                { $$ = new ExpressionNode( build_unary_val( yylloc, OperKinds::Decr, $2 ) ); }
    883885        | SIZEOF unary_expression
    884                 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild( $2 ) ) ); }
     886                { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
    885887        | SIZEOF '(' type_no_function ')'
    886                 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuildType( $3 ) ) ); }
     888                { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
    887889        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    888                 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild( $2 ) ) ); }
     890                { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuild( $2 ) ) ); }
    889891        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    890                 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
     892                { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); }
    891893        | OFFSETOF '(' type_no_function ',' identifier ')'
    892                 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
     894                { $$ = new ExpressionNode( build_offsetOf( yylloc, $3, build_varref( yylloc, $5 ) ) ); }
    893895        | TYPEID '(' type_no_function ')'
    894896                {
     
    915917        unary_expression
    916918        | '(' type_no_function ')' cast_expression
    917                 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     919                { $$ = new ExpressionNode( build_cast( yylloc, $2, $4 ) ); }
    918920        | '(' aggregate_control '&' ')' cast_expression         // CFA
    919                 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
     921                { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); }
    920922        | '(' aggregate_control '*' ')' cast_expression         // CFA
    921                 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
     923                { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); }
    922924        | '(' VIRTUAL ')' cast_expression                                       // CFA
    923                 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     925                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    924926        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    925                 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
     927                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
    926928        | '(' RETURN type_no_function ')' cast_expression       // CFA
    927929                { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; }
     
    931933                { SemanticError( yylloc, "Qualifier cast is currently unimplemented." ); $$ = nullptr; }
    932934//      | '(' type_no_function ')' tuple
    933 //              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
     935//              { $$ = new ast::ExpressionNode( build_cast( yylloc, $2, $4 ) ); }
    934936        ;
    935937
     
    949951        cast_expression
    950952        | exponential_expression '\\' cast_expression
    951                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
     953                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Exp, $1, $3 ) ); }
    952954        ;
    953955
     
    955957        exponential_expression
    956958        | multiplicative_expression '*' exponential_expression
    957                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
     959                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mul, $1, $3 ) ); }
    958960        | multiplicative_expression '/' exponential_expression
    959                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
     961                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Div, $1, $3 ) ); }
    960962        | multiplicative_expression '%' exponential_expression
    961                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
     963                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Mod, $1, $3 ) ); }
    962964        ;
    963965
     
    965967        multiplicative_expression
    966968        | additive_expression '+' multiplicative_expression
    967                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }
     969                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Plus, $1, $3 ) ); }
    968970        | additive_expression '-' multiplicative_expression
    969                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }
     971                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Minus, $1, $3 ) ); }
    970972        ;
    971973
     
    973975        additive_expression
    974976        | shift_expression LS additive_expression
    975                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }
     977                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LShift, $1, $3 ) ); }
    976978        | shift_expression RS additive_expression
    977                 { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }
     979                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::RShift, $1, $3 ) ); }
    978980        ;
    979981
     
    981983        shift_expression
    982984        | relational_expression '<' shift_expression
    983                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }
     985                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LThan, $1, $3 ) ); }
    984986        | relational_expression '>' shift_expression
    985                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }
     987                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GThan, $1, $3 ) ); }
    986988        | relational_expression LE shift_expression
    987                 { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }
     989                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::LEThan, $1, $3 ) ); }
    988990        | relational_expression GE shift_expression
    989                 { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }
     991                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::GEThan, $1, $3 ) ); }
    990992        ;
    991993
     
    993995        relational_expression
    994996        | equality_expression EQ relational_expression
    995                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }
     997                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Eq, $1, $3 ) ); }
    996998        | equality_expression NE relational_expression
    997                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }
     999                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Neq, $1, $3 ) ); }
    9981000        ;
    9991001
     
    10011003        equality_expression
    10021004        | AND_expression '&' equality_expression
    1003                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }
     1005                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitAnd, $1, $3 ) ); }
    10041006        ;
    10051007
     
    10071009        AND_expression
    10081010        | exclusive_OR_expression '^' AND_expression
    1009                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }
     1011                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Xor, $1, $3 ) ); }
    10101012        ;
    10111013
     
    10131015        exclusive_OR_expression
    10141016        | inclusive_OR_expression '|' exclusive_OR_expression
    1015                 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }
     1017                { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::BitOr, $1, $3 ) ); }
    10161018        ;
    10171019
     
    10191021        inclusive_OR_expression
    10201022        | logical_AND_expression ANDAND inclusive_OR_expression
    1021                 { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); }
     1023                { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::AndExpr ) ); }
    10221024        ;
    10231025
     
    10251027        logical_AND_expression
    10261028        | logical_OR_expression OROR logical_AND_expression
    1027                 { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); }
     1029                { $$ = new ExpressionNode( build_and_or( yylloc, $1, $3, ast::OrExpr ) ); }
    10281030        ;
    10291031
     
    10311033        logical_OR_expression
    10321034        | logical_OR_expression '?' comma_expression ':' conditional_expression
    1033                 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
     1035                { $$ = new ExpressionNode( build_cond( yylloc, $1, $3, $5 ) ); }
    10341036                // FIX ME: computes $1 twice
    10351037        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    1036                 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     1038                { $$ = new ExpressionNode( build_cond( yylloc, $1, $1, $4 ) ); }
    10371039        ;
    10381040
     
    10491051//                              SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr;
    10501052//                      } else {
    1051                                 $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) );
     1053                                $$ = new ExpressionNode( build_binary_val( yylloc, $2, $1, $3 ) );
    10521054//                      } // if
    10531055                }
     
    10941096//              { $$ = new ExpressionNode( build_tuple( $3 ) ); }
    10951097        '[' ',' tuple_expression_list ']'
    1096                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
     1098                { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    10971099        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    1098                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
     1100                { $$ = new ExpressionNode( build_tuple( yylloc, (ExpressionNode *)($3->set_last( $6 ) ) )); }
    10991101        ;
    11001102
     
    11121114        assignment_expression
    11131115        | comma_expression ',' assignment_expression
    1114                 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     1116                { $$ = new ExpressionNode( new ast::CommaExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    11151117        ;
    11161118
     
    11391141        | asm_statement
    11401142        | DIRECTIVE
    1141                 { $$ = new StatementNode( build_directive( $1 ) ); }
     1143                { $$ = new StatementNode( build_directive( yylloc, $1 ) ); }
    11421144        ;
    11431145
     
    11451147                // labels cannot be identifiers 0 or 1
    11461148        identifier_or_type_name ':' attribute_list_opt statement
    1147                 { $$ = $4->add_label( $1, $3 ); }
     1149                { $$ = $4->add_label( yylloc, $1, $3 ); }
    11481150        | identifier_or_type_name ':' attribute_list_opt error // syntax error
    11491151                {
     
    11571159compound_statement:
    11581160        '{' '}'
    1159                 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     1161                { $$ = new StatementNode( build_compound( yylloc, (StatementNode *)0 ) ); }
    11601162        | '{' push
    11611163          local_label_declaration_opt                                           // GCC, local labels appear at start of block
    11621164          statement_decl_list                                                           // C99, intermix declarations and statements
    11631165          pop '}'
    1164                 { $$ = new StatementNode( build_compound( $4 ) ); }
     1166                { $$ = new StatementNode( build_compound( yylloc, $4 ) ); }
    11651167        ;
    11661168
     
    11931195expression_statement:
    11941196        comma_expression_opt ';'
    1195                 { $$ = new StatementNode( build_expr( $1 ) ); }
     1197                { $$ = new StatementNode( build_expr( yylloc, $1 ) ); }
    11961198        ;
    11971199
     
    12021204                { $$ = $2; }
    12031205        | SWITCH '(' comma_expression ')' case_clause
    1204                 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
     1206                { $$ = new StatementNode( build_switch( yylloc, true, $3, $5 ) ); }
    12051207        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
    12061208                {
    1207                         StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
     1209                        StatementNode *sw = new StatementNode( build_switch( yylloc, true, $3, $8 ) );
    12081210                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    12091211                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    12111213                        // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    12121214                        // statement.
    1213                         $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     1215                        $$ = $7 ? new StatementNode( build_compound( yylloc, (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    12141216                }
    12151217        | SWITCH '(' comma_expression ')' '{' error '}'         // CFA, syntax error
    12161218                { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    12171219        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    1218                 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
     1220                { $$ = new StatementNode( build_switch( yylloc, false, $3, $5 ) ); }
    12191221        | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt pop '}' // CFA
    12201222                {
    1221                         StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) );
    1222                         $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
     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;
    12231225                }
    12241226        | CHOOSE '(' comma_expression ')' '{' error '}'         // CFA, syntax error
     
    12291231        IF '(' conditional_declaration ')' statement            %prec THEN
    12301232                // explicitly deal with the shift/reduce conflict on if/else
    1231                 { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), nullptr ) ); }
     1233                { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), nullptr ) ); }
    12321234        | IF '(' conditional_declaration ')' statement ELSE statement
    1233                 { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), maybe_build_compound( $7 ) ) ); }
     1235                { $$ = new StatementNode( build_if( yylloc, $3, maybe_build_compound( yylloc, $5 ), maybe_build_compound( yylloc, $7 ) ) ); }
    12341236        ;
    12351237
     
    12511253        constant_expression                                                     { $$ = $1; }
    12521254        | constant_expression ELLIPSIS constant_expression      // GCC, subrange
    1253                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     1255                { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    12541256        | subrange                                                                                      // CFA, subrange
    12551257        ;
     
    12671269        | CASE case_value_list error                                            // syntax error
    12681270                { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; }
    1269         | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
     1271        | DEFAULT ':'                                                           { $$ = new StatementNode( build_default( yylloc ) ); }
    12701272                // A semantic check is required to ensure only one default clause per switch/choose statement.
    12711273        | DEFAULT error                                                                         //  syntax error
     
    12791281
    12801282case_clause:                                                                                    // CFA
    1281         case_label_list statement                                       { $$ = $1->append_last_case( maybe_build_compound( $2 ) ); }
     1283        case_label_list statement                                       { $$ = $1->append_last_case( maybe_build_compound( yylloc, $2 ) ); }
    12821284        ;
    12831285
     
    12901292switch_clause_list:                                                                             // CFA
    12911293        case_label_list statement_list_nodecl
    1292                 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     1294                { $$ = $1->append_last_case( new StatementNode( build_compound( yylloc, $2 ) ) ); }
    12931295        | switch_clause_list case_label_list statement_list_nodecl
    1294                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
     1296                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ) ); }
    12951297        ;
    12961298
    12971299iteration_statement:
    12981300        WHILE '(' ')' statement                                                         %prec THEN // CFA => while ( 1 )
    1299                 { $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( $4 ) ) ); }
     1301                { $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) ); }
    13001302        | WHILE '(' ')' statement ELSE statement                        // CFA
    13011303                {
    1302                         $$ = new StatementNode( build_while( new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( $4 ) ) );
     1304                        $$ = new StatementNode( build_while( yylloc, new CondCtl( nullptr, NEW_ONE ), maybe_build_compound( yylloc, $4 ) ) );
    13031305                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13041306                }
    13051307        | WHILE '(' conditional_declaration ')' statement       %prec THEN
    1306                 { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
     1308                { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
    13071309        | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
    1308                 { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ), $7 ) ); }
     1310                { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
    13091311        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    1310                 { $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound( $2 ) ) ); }
     1312                { $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) ); }
    13111313        | DO statement WHILE '(' ')' ELSE statement                     // CFA
    13121314                {
    1313                         $$ = new StatementNode( build_do_while( NEW_ONE, maybe_build_compound( $2 ) ) );
     1315                        $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) );
    13141316                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13151317                }
    13161318        | DO statement WHILE '(' comma_expression ')' ';'
    1317                 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
     1319                { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ) ) ); }
    13181320        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    1319                 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
     1321                { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ), $8 ) ); }
    13201322        | FOR '(' ')' statement                                                         %prec THEN // CFA => for ( ;; )
    1321                 { $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) ); }
     1323                { $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) ); }
    13221324        | FOR '(' ')' statement ELSE statement                          // CFA
    13231325                {
    1324                         $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) );
     1326                        $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) );
    13251327                        SemanticWarning( yylloc, Warning::SuperfluousElse );
    13261328                }
    13271329        | FOR '(' for_control_expression_list ')' statement     %prec THEN
    1328                 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
     1330                { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
    13291331        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    1330                 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
     1332                { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
    13311333        ;
    13321334
     
    13421344                        if ( $1->condition ) {
    13431345                                if ( $3->condition ) {
    1344                                         $1->condition->expr.reset( new LogicalExpr( $1->condition->expr.release(), $3->condition->expr.release(), true ) );
     1346                                        $1->condition->expr.reset( new ast::LogicalExpr( yylloc, $1->condition->expr.release(), $3->condition->expr.release(), ast::AndExpr ) );
    13451347                                } // if
    13461348                        } else $1->condition = $3->condition;
    13471349                        if ( $1->change ) {
    13481350                                if ( $3->change ) {
    1349                                         $1->change->expr.reset( new CommaExpr( $1->change->expr.release(), $3->change->expr.release() ) );
     1351                                        $1->change->expr.reset( new ast::CommaExpr( yylloc, $1->change->expr.release(), $3->change->expr.release() ) );
    13501352                                } // if
    13511353                        } else $1->change = $3->change;
     
    13591361        | comma_expression ';' comma_expression_opt ';' comma_expression_opt
    13601362                {
    1361                         StatementNode * init = $1 ? new StatementNode( new ExprStmt( maybeMoveBuild( $1 ) ) ) : nullptr;
     1363                        StatementNode * init = $1 ? new StatementNode( new ast::ExprStmt( yylloc, maybeMoveBuild( $1 ) ) ) : nullptr;
    13621364                        $$ = new ForCtrl( init, $3, $5 );
    13631365                }
     
    13711373
    13721374        | comma_expression                                                                      // CFA, anonymous loop-index
    1373                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); }
     1375                { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), NEW_ZERO, OperKinds::LThan, $1->clone(), NEW_ONE ); }
    13741376        | downupdowneq comma_expression                                         // CFA, anonymous loop-index
    1375                 { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); }
     1377                { $$ = forCtrl( yylloc, $2, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $1, NEW_ZERO, $2->clone() ), $1, UPDOWN( $1, $2->clone(), NEW_ZERO ), NEW_ONE ); }
    13761378
    13771379        | comma_expression updowneq comma_expression            // CFA, anonymous loop-index
    1378                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }
     1380                { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), NEW_ONE ); }
    13791381        | '@' updowneq comma_expression                                         // CFA, anonymous loop-index
    13801382                {
    13811383                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1382                         else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
     1384                        else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, NEW_ONE );
    13831385                }
    13841386        | comma_expression updowneq '@'                                         // CFA, anonymous loop-index
     
    13881390                }
    13891391        | comma_expression updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index
    1390                 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }
     1392                { $$ = forCtrl( yylloc, $1, new string( DeclarationNode::anonymous.newName() ), UPDOWN( $2, $1->clone(), $3 ), $2, UPDOWN( $2, $3->clone(), $1->clone() ), $5 ); }
    13911393        | '@' updowneq comma_expression '~' comma_expression // CFA, anonymous loop-index
    13921394                {
    13931395                        if ( $2 == OperKinds::LThan || $2 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1394                         else $$ = forCtrl( $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
     1396                        else $$ = forCtrl( yylloc, $3, new string( DeclarationNode::anonymous.newName() ), $3->clone(), $2, nullptr, $5 );
    13951397                }
    13961398        | comma_expression updowneq '@' '~' comma_expression // CFA, anonymous loop-index
     
    14111413
    14121414        | comma_expression ';' comma_expression                         // CFA
    1413                 { $$ = forCtrl( $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); }
     1415                { $$ = forCtrl( yylloc, $3, $1, NEW_ZERO, OperKinds::LThan, $3->clone(), NEW_ONE ); }
    14141416        | comma_expression ';' downupdowneq comma_expression // CFA
    1415                 { $$ = forCtrl( $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); }
     1417                { $$ = forCtrl( yylloc, $4, $1, UPDOWN( $3, NEW_ZERO, $4->clone() ), $3, UPDOWN( $3, $4->clone(), NEW_ZERO ), NEW_ONE ); }
    14161418
    14171419        | comma_expression ';' comma_expression updowneq comma_expression // CFA
    1418                 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }
     1420                { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), NEW_ONE ); }
    14191421        | comma_expression ';' '@' updowneq comma_expression // CFA
    14201422                {
    14211423                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1422                         else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
     1424                        else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, NEW_ONE );
    14231425                }
    14241426        | comma_expression ';' comma_expression updowneq '@' // CFA
     
    14261428                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14271429                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1428                         else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
     1430                        else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, NEW_ONE );
    14291431                }
    14301432        | comma_expression ';' '@' updowneq '@'                         // CFA, error
     
    14321434
    14331435        | comma_expression ';' comma_expression updowneq comma_expression '~' comma_expression // CFA
    1434                 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
     1436                { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), $7 ); }
    14351437        | comma_expression ';' '@' updowneq comma_expression '~' comma_expression // CFA, error
    14361438                {
    14371439                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1438                         else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, $7 );
     1440                        else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, $7 );
    14391441                }
    14401442        | comma_expression ';' comma_expression updowneq '@' '~' comma_expression // CFA
     
    14421444                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14431445                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1444                         else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, $7 );
     1446                        else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, $7 );
    14451447                }
    14461448        | comma_expression ';' comma_expression updowneq comma_expression '~' '@' // CFA
    1447                 { $$ = forCtrl( $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
     1449                { $$ = forCtrl( yylloc, $3, $1, UPDOWN( $4, $3->clone(), $5 ), $4, UPDOWN( $4, $5->clone(), $3->clone() ), nullptr ); }
    14481450        | comma_expression ';' '@' updowneq comma_expression '~' '@' // CFA, error
    14491451                {
    14501452                        if ( $4 == OperKinds::LThan || $4 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1451                         else $$ = forCtrl( $5, $1, $5->clone(), $4, nullptr, nullptr );
     1453                        else $$ = forCtrl( yylloc, $5, $1, $5->clone(), $4, nullptr, nullptr );
    14521454                }
    14531455        | comma_expression ';' comma_expression updowneq '@' '~' '@' // CFA
     
    14551457                        if ( $4 == OperKinds::GThan || $4 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14561458                        else if ( $4 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1457                         else $$ = forCtrl( $3, $1, $3->clone(), $4, nullptr, nullptr );
     1459                        else $$ = forCtrl( yylloc, $3, $1, $3->clone(), $4, nullptr, nullptr );
    14581460                }
    14591461        | comma_expression ';' '@' updowneq '@' '~' '@' // CFA
     
    14611463
    14621464        | declaration comma_expression                                          // CFA
    1463                 { $$ = forCtrl( $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); }
     1465                { $$ = forCtrl( yylloc, $1, NEW_ZERO, OperKinds::LThan, $2, NEW_ONE ); }
    14641466        | declaration downupdowneq comma_expression                     // CFA
    1465                 { $$ = forCtrl( $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); }
     1467                { $$ = forCtrl( yylloc, $1, UPDOWN( $2, NEW_ZERO, $3 ), $2, UPDOWN( $2, $3->clone(), NEW_ZERO ), NEW_ONE ); }
    14661468
    14671469        | declaration comma_expression updowneq comma_expression // CFA
    1468                 { $$ = forCtrl( $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }
     1470                { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2->clone(), $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), NEW_ONE ); }
    14691471        | declaration '@' updowneq comma_expression                     // CFA
    14701472                {
    14711473                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1472                         else $$ = forCtrl( $1, $4, $3, nullptr, NEW_ONE );
     1474                        else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, NEW_ONE );
    14731475                }
    14741476        | declaration comma_expression updowneq '@'                     // CFA
     
    14761478                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14771479                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1478                         else $$ = forCtrl( $1, $2, $3, nullptr, NEW_ONE );
     1480                        else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, NEW_ONE );
    14791481                }
    14801482
    14811483        | declaration comma_expression updowneq comma_expression '~' comma_expression // CFA
    1482                 { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }
     1484                { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), $6 ); }
    14831485        | declaration '@' updowneq comma_expression '~' comma_expression // CFA
    14841486                {
    14851487                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1486                         else $$ = forCtrl( $1, $4, $3, nullptr, $6 );
     1488                        else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, $6 );
    14871489                }
    14881490        | declaration comma_expression updowneq '@' '~' comma_expression // CFA
     
    14901492                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    14911493                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1492                         else $$ = forCtrl( $1, $2, $3, nullptr, $6 );
     1494                        else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, $6 );
    14931495                }
    14941496        | declaration comma_expression updowneq comma_expression '~' '@' // CFA
    1495                 { $$ = forCtrl( $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }
     1497                { $$ = forCtrl( yylloc, $1, UPDOWN( $3, $2, $4 ), $3, UPDOWN( $3, $4->clone(), $2->clone() ), nullptr ); }
    14961498        | declaration '@' updowneq comma_expression '~' '@' // CFA
    14971499                {
    14981500                        if ( $3 == OperKinds::LThan || $3 == OperKinds::LEThan ) { SemanticError( yylloc, MISSING_LOW ); $$ = nullptr; }
    1499                         else $$ = forCtrl( $1, $4, $3, nullptr, nullptr );
     1501                        else $$ = forCtrl( yylloc, $1, $4, $3, nullptr, nullptr );
    15001502                }
    15011503        | declaration comma_expression updowneq '@' '~' '@'     // CFA
     
    15031505                        if ( $3 == OperKinds::GThan || $3 == OperKinds::GEThan ) { SemanticError( yylloc, MISSING_HIGH ); $$ = nullptr; }
    15041506                        else if ( $3 == OperKinds::LEThan ) { SemanticError( yylloc, "Equality with missing high value is meaningless. Use \"~\"." ); $$ = nullptr; }
    1505                         else $$ = forCtrl( $1, $2, $3, nullptr, nullptr );
     1507                        else $$ = forCtrl( yylloc, $1, $2, $3, nullptr, nullptr );
    15061508                }
    15071509        | declaration '@' updowneq '@' '~' '@'                          // CFA, error
     
    15461548jump_statement:
    15471549        GOTO identifier_or_type_name ';'
    1548                 { $$ = new StatementNode( build_branch( $2, BranchStmt::Goto ) ); }
     1550                { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Goto ) ); }
    15491551        | GOTO '*' comma_expression ';'                                         // GCC, computed goto
    15501552                // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3);
     
    15531555                // A semantic check is required to ensure fallthru appears only in the body of a choose statement.
    15541556        | fall_through_name ';'                                                         // CFA
    1555                 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); }
     1557                { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThrough ) ); }
    15561558        | fall_through_name identifier_or_type_name ';'         // CFA
    1557                 { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); }
     1559                { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::FallThrough ) ); }
    15581560        | fall_through_name DEFAULT ';'                                         // CFA
    1559                 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); }
     1561                { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::FallThroughDefault ) ); }
    15601562        | CONTINUE ';'
    15611563                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    1562                 { $$ = new StatementNode( build_branch( BranchStmt::Continue ) ); }
     1564                { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Continue ) ); }
    15631565        | CONTINUE identifier_or_type_name ';'                          // CFA, multi-level continue
    15641566                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    15651567                // the target of the transfer appears only at the start of an iteration statement.
    1566                 { $$ = new StatementNode( build_branch( $2, BranchStmt::Continue ) ); }
     1568                { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Continue ) ); }
    15671569        | BREAK ';'
    15681570                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    1569                 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); }
     1571                { $$ = new StatementNode( build_branch( yylloc, ast::BranchStmt::Break ) ); }
    15701572        | BREAK identifier_or_type_name ';'                                     // CFA, multi-level exit
    15711573                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
    15721574                // the target of the transfer appears only at the start of an iteration statement.
    1573                 { $$ = new StatementNode( build_branch( $2, BranchStmt::Break ) ); }
     1575                { $$ = new StatementNode( build_branch( yylloc, $2, ast::BranchStmt::Break ) ); }
    15741576        | RETURN comma_expression_opt ';'
    1575                 { $$ = new StatementNode( build_return( $2 ) ); }
     1577                { $$ = new StatementNode( build_return( yylloc, $2 ) ); }
    15761578        | RETURN '{' initializer_list_opt comma_opt '}' ';'
    15771579                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    15781580        | SUSPEND ';'
    1579                 { $$ = new StatementNode( build_suspend( nullptr ) ); }
     1581                { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::None ) ); }
    15801582        | SUSPEND compound_statement
    1581                 { $$ = new StatementNode( build_suspend( $2 ) ); }
     1583                { $$ = new StatementNode( build_suspend( yylloc, $2, ast::SuspendStmt::None ) ); }
    15821584        | SUSPEND COROUTINE ';'
    1583                 { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Coroutine ) ); }
     1585                { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Coroutine ) ); }
    15841586        | SUSPEND COROUTINE compound_statement
    1585                 { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Coroutine ) ); }
     1587                { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Coroutine ) ); }
    15861588        | SUSPEND GENERATOR ';'
    1587                 { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Generator ) ); }
     1589                { $$ = new StatementNode( build_suspend( yylloc, nullptr, ast::SuspendStmt::Generator ) ); }
    15881590        | SUSPEND GENERATOR compound_statement
    1589                 { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Generator ) ); }
     1591                { $$ = new StatementNode( build_suspend( yylloc, $3, ast::SuspendStmt::Generator ) ); }
    15901592        | THROW assignment_expression_opt ';'                           // handles rethrow
    1591                 { $$ = new StatementNode( build_throw( $2 ) ); }
     1593                { $$ = new StatementNode( build_throw( yylloc, $2 ) ); }
    15921594        | THROWRESUME assignment_expression_opt ';'                     // handles reresume
    1593                 { $$ = new StatementNode( build_resume( $2 ) ); }
     1595                { $$ = new StatementNode( build_resume( yylloc, $2 ) ); }
    15941596        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    15951597                { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
     
    16031605with_statement:
    16041606        WITH '(' tuple_expression_list ')' statement
    1605                 { $$ = new StatementNode( build_with( $3, $5 ) ); }
     1607                { $$ = new StatementNode( build_with( yylloc, $3, $5 ) ); }
    16061608        ;
    16071609
     
    16111613                {
    16121614                        if ( ! $3 ) { SemanticError( yylloc, "mutex argument list cannot be empty." ); $$ = nullptr; }
    1613                         $$ = new StatementNode( build_mutex( $3, $5 ) );
     1615                        $$ = new StatementNode( build_mutex( yylloc, $3, $5 ) );
    16141616                }
    16151617        ;
     
    16501652        when_clause_opt waitfor statement                                       %prec THEN
    16511653                // Called first: create header for WaitForStmt.
    1652                 { $$ = build_waitfor( new WaitForStmt(), $1, $2, maybe_build_compound( $3 ) ); }
     1654                { $$ = build_waitfor( yylloc, new ast::WaitForStmt( yylloc ), $1, $2, maybe_build_compound( yylloc, $3 ) ); }
    16531655        | wor_waitfor_clause wor when_clause_opt waitfor statement
    1654                 { $$ = build_waitfor( $1, $3, $4, maybe_build_compound( $5 ) ); }
     1656                { $$ = build_waitfor( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); }
    16551657        | wor_waitfor_clause wor when_clause_opt ELSE statement
    1656                 { $$ = build_waitfor_else( $1, $3, maybe_build_compound( $5 ) ); }
     1658                { $$ = build_waitfor_else( yylloc, $1, $3, maybe_build_compound( yylloc, $5 ) ); }
    16571659        | wor_waitfor_clause wor when_clause_opt timeout statement      %prec THEN
    1658                 { $$ = build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ); }
     1660                { $$ = build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ); }
    16591661        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    16601662        | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error
    16611663                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    16621664        | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
    1663                 { $$ = build_waitfor_else( build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ), $7, maybe_build_compound( $9 ) ); }
     1665                { $$ = build_waitfor_else( yylloc, build_waitfor_timeout( yylloc, $1, $3, $4, maybe_build_compound( yylloc, $5 ) ), $7, maybe_build_compound( yylloc, $9 ) ); }
     1666        ;
    16641667
    16651668waitfor_statement:
     
    17111714        wor_waituntil_clause                                                            %prec THEN
    17121715                // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement.
    1713                 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
     1716                { $$ = new StatementNode( build_compound( yylloc, nullptr ) ); }
    17141717        ;
    17151718
    17161719exception_statement:
    1717         TRY compound_statement handler_clause                           %prec THEN
    1718                 { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); }
     1720        TRY compound_statement handler_clause                                   %prec THEN
     1721                { $$ = new StatementNode( build_try( yylloc, $2, $3, nullptr ) ); }
    17191722        | TRY compound_statement finally_clause
    1720                 { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); }
     1723                { $$ = new StatementNode( build_try( yylloc, $2, nullptr, $3 ) ); }
    17211724        | TRY compound_statement handler_clause finally_clause
    1722                 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
     1725                { $$ = new StatementNode( build_try( yylloc, $2, $3, $4 ) ); }
    17231726        ;
    17241727
    17251728handler_clause:
    17261729        handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1727                 { $$ = new StatementNode( build_catch( $1, $4, $6, $8 ) ); }
     1730                { $$ = new StatementNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }
    17281731        | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
    1729                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $5, $7, $9 ) ) ); }
     1732                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }
    17301733        ;
    17311734
     
    17371740
    17381741handler_key:
    1739         CATCH                                                                           { $$ = CatchStmt::Terminate; }
    1740         | RECOVER                                                                       { $$ = CatchStmt::Terminate; }
    1741         | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
    1742         | FIXUP                                                                         { $$ = CatchStmt::Resume; }
     1742        CATCH                                                                           { $$ = ast::Terminate; }
     1743        | RECOVER                                                                       { $$ = ast::Terminate; }
     1744        | CATCHRESUME                                                           { $$ = ast::Resume; }
     1745        | FIXUP                                                                         { $$ = ast::Resume; }
    17431746        ;
    17441747
    17451748finally_clause:
    1746         FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
     1749        FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( yylloc, $2 ) ); }
    17471750        ;
    17481751
     
    17701773asm_statement:
    17711774        ASM asm_volatile_opt '(' string_literal ')' ';'
    1772                 { $$ = new StatementNode( build_asm( $2, $4, nullptr ) ); }
     1775                { $$ = new StatementNode( build_asm( yylloc, $2, $4, nullptr ) ); }
    17731776        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC
    1774                 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); }
     1777                { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6 ) ); }
    17751778        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    1776                 { $$ = new StatementNode( build_asm( $2, $4, $6, $8 ) ); }
     1779                { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8 ) ); }
    17771780        | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
    1778                 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); }
     1781                { $$ = new StatementNode( build_asm( yylloc, $2, $4, $6, $8, $10 ) ); }
    17791782        | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
    1780                 { $$ = new StatementNode( build_asm( $2, $5, nullptr, $8, $10, $12 ) ); }
     1783                { $$ = new StatementNode( build_asm( yylloc, $2, $5, nullptr, $8, $10, $12 ) ); }
    17811784        ;
    17821785
     
    18021805asm_operand:                                                                                    // GCC
    18031806        string_literal '(' constant_expression ')'
    1804                 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild( $3 ) ) ); }
     1807                { $$ = new ExpressionNode( new ast::AsmExpr( yylloc, "", $1, maybeMoveBuild( $3 ) ) ); }
    18051808        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
    1806                 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild( $6 ) ) ); }
     1809                {
     1810                        $$ = new ExpressionNode( new ast::AsmExpr( yylloc, *$2.str, $4, maybeMoveBuild( $6 ) ) );
     1811                        delete $2.str;
     1812                }
    18071813        ;
    18081814
     
    18191825        identifier
    18201826                {
    1821                         $$ = new LabelNode(); $$->labels.push_back( *$1 );
     1827                        $$ = new LabelNode(); $$->labels.emplace_back( yylloc, *$1 );
    18221828                        delete $1;                                                                      // allocated by lexer
    18231829                }
    18241830        | label_list ',' identifier
    18251831                {
    1826                         $$ = $1; $1->labels.push_back( *$3 );
     1832                        $$ = $1; $1->labels.emplace_back( yylloc, *$3 );
    18271833                        delete $3;                                                                      // allocated by lexer
    18281834                }
     
    18871893                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    18881894        | STATICASSERT '(' constant_expression ')' ';'          // CFA
    1889                 { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( *new string( "\"\"" ) ) ); }
     1895                { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( yylloc, *new string( "\"\"" ) ) ); }
    18901896
    18911897// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    20872093                {
    20882094                        SemanticError( yylloc, ::toString( "Missing ';' after end of ",
    2089                                 $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),
     2095                                $1->type->enumeration.name ? "enum" : ast::AggregateDecl::aggrString( $1->type->aggregate.kind ),
    20902096                                " declaration" ) );
    20912097                        $$ = nullptr;
     
    23212327                { $$ = DeclarationNode::newTypeof( $3 ); }
    23222328        | BASETYPEOF '(' type ')'                                                       // CFA: basetypeof( x ) y;
    2323                 { $$ = DeclarationNode::newTypeof( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ), true ); }
     2329                { $$ = DeclarationNode::newTypeof( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ), true ); }
    23242330        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    23252331                { $$ = DeclarationNode::newTypeof( $3, true ); }
     
    25152521aggregate_data:
    25162522        STRUCT vtable_opt
    2517                 { $$ = AggregateDecl::Struct; }
     2523                { $$ = ast::AggregateDecl::Struct; }
    25182524        | UNION
    2519                 { $$ = AggregateDecl::Union; }
     2525                { $$ = ast::AggregateDecl::Union; }
    25202526        | EXCEPTION                                                                                     // CFA
    2521                 { $$ = AggregateDecl::Exception; }
    2522           //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2527                { $$ = ast::AggregateDecl::Exception; }
     2528          //            { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = ast::AggregateDecl::NoAggregate; }
    25232529        ;
    25242530
    25252531aggregate_control:                                                                              // CFA
    25262532        MONITOR
    2527                 { $$ = AggregateDecl::Monitor; }
     2533                { $$ = ast::AggregateDecl::Monitor; }
    25282534        | MUTEX STRUCT
    2529                 { $$ = AggregateDecl::Monitor; }
     2535                { $$ = ast::AggregateDecl::Monitor; }
    25302536        | GENERATOR
    2531                 { $$ = AggregateDecl::Generator; }
     2537                { $$ = ast::AggregateDecl::Generator; }
    25322538        | MUTEX GENERATOR
    2533                 { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2539                {
     2540                        SemanticError( yylloc, "monitor generator is currently unimplemented." );
     2541                        $$ = ast::AggregateDecl::NoAggregate;
     2542                }
    25342543        | COROUTINE
    2535                 { $$ = AggregateDecl::Coroutine; }
     2544                { $$ = ast::AggregateDecl::Coroutine; }
    25362545        | MUTEX COROUTINE
    2537                 { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2546                {
     2547                        SemanticError( yylloc, "monitor coroutine is currently unimplemented." );
     2548                        $$ = ast::AggregateDecl::NoAggregate;
     2549                }
    25382550        | THREAD
    2539                 { $$ = AggregateDecl::Thread; }
     2551                { $$ = ast::AggregateDecl::Thread; }
    25402552        | MUTEX THREAD
    2541                 { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
     2553                {
     2554                        SemanticError( yylloc, "monitor thread is currently unimplemented." );
     2555                        $$ = ast::AggregateDecl::NoAggregate;
     2556                }
    25422557        ;
    25432558
     
    28892904        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    28902905        | identifier_at ':'                                                                     // GCC, field name
    2891                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
     2906                { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
    28922907        ;
    28932908
     
    29012916designator:
    29022917        '.' identifier_at                                                                       // C99, field name
    2903                 { $$ = new ExpressionNode( build_varref( $2 ) ); }
     2918                { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); }
    29042919        | '[' push assignment_expression pop ']'                        // C99, single array element
    29052920                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
     
    29082923                { $$ = $3; }
    29092924        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    2910                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }
     2925                { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); }
    29112926        | '.' '[' push field_name_list pop ']'                          // CFA, tuple field selector
    29122927                { $$ = $4; }
     
    29482963                {
    29492964                        typedefTable.addToScope( *$2, TYPEDEFname, "9" );
    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 ..." ); }
     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 ..." ); }
    29532968                }
    29542969          type_initializer_opt assertion_list_opt
     
    29612976                {
    29622977                        typedefTable.addToScope( *$2, TYPEDIMname, "9" );
    2963                         $$ = DeclarationNode::newTypeParam( TypeDecl::Dimension, $2 );
     2978                        $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dimension, $2 );
    29642979                }
    29652980        // | type_specifier identifier_parameter_declarator
    29662981        | assertion_list
    2967                 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2982                { $$ = DeclarationNode::newTypeParam( ast::TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    29682983        ;
    29692984
    29702985new_type_class:                                                                                 // CFA
    29712986        // empty
    2972                 { $$ = TypeDecl::Otype; }
     2987                { $$ = ast::TypeDecl::Otype; }
    29732988        | '&'
    2974                 { $$ = TypeDecl::Dtype; }
     2989                { $$ = ast::TypeDecl::Dtype; }
    29752990        | '*'
    2976                 { $$ = TypeDecl::DStype; }                                              // dtype + sized
     2991                { $$ = ast::TypeDecl::DStype; }                                         // dtype + sized
    29772992        // | '(' '*' ')'
    2978         //      { $$ = TypeDecl::Ftype; }
     2993        //      { $$ = ast::TypeDecl::Ftype; }
    29792994        | ELLIPSIS
    2980                 { $$ = TypeDecl::Ttype; }
     2995                { $$ = ast::TypeDecl::Ttype; }
    29812996        ;
    29822997
    29832998type_class:                                                                                             // CFA
    29842999        OTYPE
    2985                 { $$ = TypeDecl::Otype; }
     3000                { $$ = ast::TypeDecl::Otype; }
    29863001        | DTYPE
    2987                 { $$ = TypeDecl::Dtype; }
     3002                { $$ = ast::TypeDecl::Dtype; }
    29883003        | FTYPE
    2989                 { $$ = TypeDecl::Ftype; }
     3004                { $$ = ast::TypeDecl::Ftype; }
    29903005        | TTYPE
    2991                 { $$ = TypeDecl::Ttype; }
     3006                { $$ = ast::TypeDecl::Ttype; }
    29923007        ;
    29933008
     
    30153030type_list:                                                                                              // CFA
    30163031        type
    3017                 { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
     3032                { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
    30183033        | assignment_expression
    30193034        | type_list ',' type
    3020                 { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     3035                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $3 ) ) ) )); }
    30213036        | type_list ',' assignment_expression
    30223037                { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     
    31253140external_definition:
    31263141        DIRECTIVE
    3127                 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); }
     3142                { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( yylloc, $1 ) ) ); }
    31283143        | declaration
    31293144                {
     
    31313146                        // unit, which is a dubious task, especially because C uses name rather than structural typing; hence it is
    31323147                        // disallowed at the moment.
    3133                         if ( $1->linkage == LinkageSpec::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
     3148                        if ( $1->linkage == ast::Linkage::Cforall && ! $1->storageClasses.is_static && $1->type && $1->type->kind == TypeData::AggregateInst ) {
    31343149                                if ( $1->type->aggInst.aggregate->kind == TypeData::Enum && $1->type->aggInst.aggregate->enumeration.anon ) {
    31353150                                        SemanticError( yylloc, "extern anonymous enumeration is currently unimplemented." ); $$ = nullptr;
     
    31583173                }
    31593174        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    3160                 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr ) ) ); }
     3175                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( yylloc, false, $3, nullptr ) ) ); }
    31613176        | EXTERN STRINGliteral
    31623177                {
    31633178                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    3164                         linkage = LinkageSpec::update( yylloc, linkage, $2 );
     3179                        linkage = ast::Linkage::update( yylloc, linkage, $2 );
    31653180                }
    31663181          up external_definition down
     
    31733188                {
    31743189                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    3175                         linkage = LinkageSpec::update( yylloc, linkage, $2 );
     3190                        linkage = ast::Linkage::update( yylloc, linkage, $2 );
    31763191                }
    31773192          '{' up external_definition_list_opt down '}'
     
    32973312subrange:
    32983313        constant_expression '~' constant_expression                     // CFA, integer subrange
    3299                 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
     3314                { $$ = new ExpressionNode( new ast::RangeExpr( yylloc, maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); }
    33003315        ;
    33013316
     
    38263841array_type_list:
    38273842        basic_type_name
    3828                 { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
     3843                { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
    38293844        | type_name
    3830                 { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
     3845                { $$ = new ExpressionNode( new ast::TypeExpr( yylloc, maybeMoveBuildType( $1 ) ) ); }
    38313846        | assignment_expression upupeq assignment_expression
    38323847        | array_type_list ',' basic_type_name
    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 ) ) ) )); }
     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 ) ) ) )); }
    38363851        | array_type_list ',' assignment_expression upupeq assignment_expression
    38373852        ;
Note: See TracChangeset for help on using the changeset viewer.