Changes in / [9c23f31:7ae930a]


Ignore:
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r9c23f31 r7ae930a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep 23 11:46:47 2016
    13 // Update Count     : 28
     12// Last Modified On : Wed Jun  8 17:33:59 2016
     13// Update Count     : 22
    1414//
    1515
     
    2525#include <sstream>
    2626#include <string>
    27 #include <cassert>
    2827
    2928template< typename T >
     
    102101                } // if
    103102        } // for
     103}
     104
     105static inline std::string assign_strptr( const std::string *str ) {
     106        if ( str == 0 ) {
     107                return "";
     108        } else {
     109                std::string tmp;
     110                tmp = *str;
     111                delete str;
     112                return tmp;
     113        } // if
    104114}
    105115
     
    131141
    132142template < typename T >
    133 void toString_single( std::ostream & os, const T & value ) {
     143void toString_single ( std::ostream & os, const T & value ) {
    134144        os << value;
    135145}
    136146
    137147template < typename T, typename... Params >
    138 void toString_single( std::ostream & os, const T & value, const Params & ... params ) {
     148void toString_single ( std::ostream & os, const T & value, const Params & ... params ) {
    139149        os << value;
    140150        toString_single( os, params ... );
     
    142152
    143153template < typename ... Params >
    144 std::string toString( const Params & ... params ) {
     154std::string toString ( const Params & ... params ) {
    145155        std::ostringstream os;
    146156        toString_single( os, params... );
  • src/Parser/DeclarationNode.cc

    r9c23f31 r7ae930a  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:12:52 2016
    13 // Update Count     : 627
     12// Last Modified On : Wed Sep 14 23:13:28 2016
     13// Update Count     : 502
    1414//
    1515
     
    3131
    3232// These must remain in the same order as the corresponding DeclarationNode enumerations.
    33 const char * DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" };
    34 const char * DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" };
    35 const char * DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" };
    36 const char * DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" };
    37 const char * DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" };
    38 const char * DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" };
    39 const char * DeclarationNode::aggregateName[] = { "struct", "union", "context" };
    40 const char * DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" };
    41 const char * DeclarationNode::builtinTypeName[] = { "__builtin_va_list" };
     33const char *DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" };
     34const char *DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" };
     35const char *DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" };
     36const char *DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" };
     37const char *DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" };
     38const char *DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" };
     39const char *DeclarationNode::aggregateName[] = { "struct", "union", "context" };
     40const char *DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" };
     41const char *DeclarationNode::builtinTypeName[] = { "__builtin_va_list" };
    4242
    4343UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    4646
    4747DeclarationNode::DeclarationNode() :
    48                 type( nullptr ),
     48                type( 0 ),
    4949                storageClass( NoStorageClass ),
    5050                isInline( false ),
    5151                isNoreturn( false ),
    52                 bitfieldWidth( nullptr ),
    53                 initializer( nullptr ),
     52                bitfieldWidth( 0 ),
     53                initializer( 0 ),
    5454                hasEllipsis( false ),
    5555                linkage( ::linkage ),
    5656                extension( false ) {
    57 
    58         variable.name = nullptr;
    5957        variable.tyClass = DeclarationNode::Otype;
    6058        variable.assertions = nullptr;
    6159
    62         attr.name = nullptr;
    6360        attr.expr = nullptr;
    6461        attr.type = nullptr;
     
    6663
    6764DeclarationNode::~DeclarationNode() {
    68         delete attr.name;
    6965        delete attr.expr;
    7066        delete attr.type;
    71 
    72         delete variable.name;
    73         delete variable.assertions;
    74 
    7567        delete type;
    7668        delete bitfieldWidth;
     
    7870}
    7971
    80 DeclarationNode * DeclarationNode::clone() const {
    81         DeclarationNode * newnode = new DeclarationNode;
     72DeclarationNode *DeclarationNode::clone() const {
     73        DeclarationNode *newnode = new DeclarationNode;
    8274        newnode->type = maybeClone( type );
    83         newnode->name = name ? new string( *name ) : nullptr;
     75        newnode->name = name;
    8476        newnode->storageClass = storageClass;
    8577        newnode->isInline = isInline;
     
    9183        newnode->linkage = linkage;
    9284
    93         newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr;
    9485        newnode->variable.assertions = maybeClone( variable.assertions );
     86        newnode->variable.name = variable.name;
    9587        newnode->variable.tyClass = variable.tyClass;
    9688
    97         newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
    9889        newnode->attr.expr = maybeClone( attr.expr );
    9990        newnode->attr.type = maybeClone( attr.type );
     
    10798void DeclarationNode::print( std::ostream &os, int indent ) const {
    10899        os << string( indent, ' ' );
    109         if ( name ) {
    110                 os << *name << ": ";
     100        if ( name == "" ) {
     101                os << "unnamed: ";
    111102        } else {
    112                 os << "unnamed: ";
     103                os << name << ": ";
    113104        } // if
    114105
     
    131122        } // if
    132123
    133         if ( initializer ) {
     124        if ( initializer != 0 ) {
    134125                os << endl << string( indent + 2, ' ' ) << "with initializer ";
    135126                initializer->printOneLine( os );
     
    148139}
    149140
    150 DeclarationNode * DeclarationNode::newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
    151         DeclarationNode * newnode = new DeclarationNode;
    152         newnode->name = name;
     141DeclarationNode *DeclarationNode::newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param, StatementNode *body, bool newStyle ) {
     142        DeclarationNode *newnode = new DeclarationNode;
     143        newnode->name = assign_strptr( name );
    153144
    154145        newnode->type = new TypeData( TypeData::Function );
     
    156147        newnode->type->function.newStyle = newStyle;
    157148        newnode->type->function.body = body;
    158         // ignore unnamed routine declarations: void p( int (*)(int) );
    159         if ( newnode->name ) {
    160                 typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID );
    161         } // if
     149        typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
    162150
    163151        if ( body ) {
     
    167155        if ( ret ) {
    168156                newnode->type->base = ret->type;
    169                 ret->type = nullptr;
     157                ret->type = 0;
    170158                delete ret;
    171159        } // if
     
    175163
    176164DeclarationNode * DeclarationNode::newQualifier( Qualifier q ) {
    177         DeclarationNode * newnode = new DeclarationNode;
     165        DeclarationNode *newnode = new DeclarationNode;
    178166        newnode->type = new TypeData();
    179167        newnode->type->qualifiers[ q ] = 1;
     
    181169} // DeclarationNode::newQualifier
    182170
    183 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) {
    184         DeclarationNode * newnode = new DeclarationNode;
     171DeclarationNode * DeclarationNode::newForall( DeclarationNode *forall ) {
     172        DeclarationNode *newnode = new DeclarationNode;
    185173        newnode->type = new TypeData( TypeData::Unknown );
    186174        newnode->type->forall = forall;
     
    189177
    190178DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {
    191         DeclarationNode * newnode = new DeclarationNode;
     179        DeclarationNode *newnode = new DeclarationNode;
     180        //switch (sc) {
     181        //      case Inline: newnode->isInline = true; break;
     182        //      case Noreturn: newnode->isNoreturn = true; break;
     183        //      default: newnode->storageClass = sc; break;
     184        //}
    192185        newnode->storageClass = sc;
    193186        return newnode;
     
    195188
    196189DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) {
    197         DeclarationNode * newnode = new DeclarationNode;
     190        DeclarationNode *newnode = new DeclarationNode;
    198191        newnode->type = new TypeData( TypeData::Basic );
    199192        newnode->type->basictype = bt;
     
    202195
    203196DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) {
    204         DeclarationNode * newnode = new DeclarationNode;
     197        DeclarationNode *newnode = new DeclarationNode;
    205198        newnode->type = new TypeData( TypeData::Basic );
    206199        newnode->type->complextype = ct;
     
    209202
    210203DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) {
    211         DeclarationNode * newnode = new DeclarationNode;
     204        DeclarationNode *newnode = new DeclarationNode;
    212205        newnode->type = new TypeData( TypeData::Basic );
    213206        newnode->type->signedness = sn;
     
    216209
    217210DeclarationNode * DeclarationNode::newLength( Length lnth ) {
    218         DeclarationNode * newnode = new DeclarationNode;
     211        DeclarationNode *newnode = new DeclarationNode;
    219212        newnode->type = new TypeData( TypeData::Basic );
    220213        newnode->type->length = lnth;
     
    222215} // DeclarationNode::newLength
    223216
    224 DeclarationNode * DeclarationNode::newFromTypedef( std::string * name ) {
    225         DeclarationNode * newnode = new DeclarationNode;
     217DeclarationNode * DeclarationNode::newFromTypedef( std::string *name ) {
     218        DeclarationNode *newnode = new DeclarationNode;
    226219        newnode->type = new TypeData( TypeData::SymbolicInst );
    227         newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
     220        newnode->type->symbolic.name = assign_strptr( name );
    228221        newnode->type->symbolic.isTypedef = true;
    229         newnode->type->symbolic.params = nullptr;
     222        newnode->type->symbolic.params = 0;
    230223        return newnode;
    231224} // DeclarationNode::newFromTypedef
    232225
    233 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
    234         DeclarationNode * newnode = new DeclarationNode;
     226DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields, bool body ) {
     227        DeclarationNode *newnode = new DeclarationNode;
    235228        newnode->type = new TypeData( TypeData::Aggregate );
    236229        newnode->type->aggregate.kind = kind;
    237         if ( name ) {
    238                 newnode->type->aggregate.name = new string( *name );
    239         } else {                                                                                        // anonymous aggregate ?
    240                 newnode->type->aggregate.name = new string( anonymous.newName() );
     230        newnode->type->aggregate.name = assign_strptr( name );
     231        if ( newnode->type->aggregate.name == "" ) {            // anonymous aggregate ?
     232                newnode->type->aggregate.name = anonymous.newName();
    241233        } // if
    242234        newnode->type->aggregate.actuals = actuals;
     
    246238} // DeclarationNode::newAggregate
    247239
    248 DeclarationNode * DeclarationNode::newEnum( std::string * name, DeclarationNode * constants ) {
    249         DeclarationNode * newnode = new DeclarationNode;
    250         newnode->name = name;
     240DeclarationNode *DeclarationNode::newEnum( std::string *name, DeclarationNode *constants ) {
     241        DeclarationNode *newnode = new DeclarationNode;
     242        newnode->name = assign_strptr( name );
    251243        newnode->type = new TypeData( TypeData::Enum );
    252         if ( name ) {
    253                 newnode->type->enumeration.name = new string( *name );
    254         } else {                                                                                        // anonymous aggregate ?
    255                 newnode->type->enumeration.name = new string( anonymous.newName() );
     244        newnode->type->enumeration.name = newnode->name;
     245        if ( newnode->type->enumeration.name == "" ) {          // anonymous enumeration ?
     246                newnode->type->enumeration.name = DeclarationNode::anonymous.newName();
    256247        } // if
    257248        newnode->type->enumeration.constants = constants;
     
    259250} // DeclarationNode::newEnum
    260251
    261 DeclarationNode * DeclarationNode::newEnumConstant( std::string * name, ExpressionNode * constant ) {
    262         DeclarationNode * newnode = new DeclarationNode;
    263         newnode->name = name;
     252DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) {
     253        DeclarationNode *newnode = new DeclarationNode;
     254        newnode->name = assign_strptr( name );
    264255        newnode->enumeratorValue.reset( constant );
    265         typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID );
     256        typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
    266257        return newnode;
    267258} // DeclarationNode::newEnumConstant
    268259
    269 DeclarationNode * DeclarationNode::newName( std::string * name ) {
    270         DeclarationNode * newnode = new DeclarationNode;
    271         newnode->name = name;
     260DeclarationNode *DeclarationNode::newName( std::string *name ) {
     261        DeclarationNode *newnode = new DeclarationNode;
     262        newnode->name = assign_strptr( name );
    272263        return newnode;
    273264} // DeclarationNode::newName
    274265
    275 DeclarationNode * DeclarationNode::newFromTypeGen( std::string * name, ExpressionNode * params ) {
    276         DeclarationNode * newnode = new DeclarationNode;
     266DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) {
     267        DeclarationNode *newnode = new DeclarationNode;
    277268        newnode->type = new TypeData( TypeData::SymbolicInst );
    278         newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
     269        newnode->type->symbolic.name = assign_strptr( name );
    279270        newnode->type->symbolic.isTypedef = false;
    280271        newnode->type->symbolic.actuals = params;
     
    282273} // DeclarationNode::newFromTypeGen
    283274
    284 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, std::string * name ) {
    285         DeclarationNode * newnode = new DeclarationNode;
    286         newnode->name = name;
    287 //      newnode->type = new TypeData( TypeData::Variable );
    288         newnode->type = nullptr;
     275DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) {
     276        DeclarationNode *newnode = new DeclarationNode;
     277        newnode->name = assign_strptr( name );
     278        newnode->type = new TypeData( TypeData::Variable );
    289279        newnode->variable.tyClass = tc;
    290         newnode->variable.name = newnode->name ? new string( *newnode->name ) : nullptr;
     280        newnode->variable.name = newnode->name;
    291281        return newnode;
    292282} // DeclarationNode::newTypeParam
    293283
    294 DeclarationNode * DeclarationNode::newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ) {
    295         DeclarationNode * newnode = new DeclarationNode;
     284DeclarationNode *DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) {
     285        DeclarationNode *newnode = new DeclarationNode;
    296286        newnode->type = new TypeData( TypeData::Aggregate );
    297         newnode->type->aggregate.name = name;
    298287        newnode->type->aggregate.kind = Trait;
    299288        newnode->type->aggregate.params = params;
    300289        newnode->type->aggregate.fields = asserts;
     290        newnode->type->aggregate.name = assign_strptr( name );
    301291        return newnode;
    302292} // DeclarationNode::newTrait
    303293
    304 DeclarationNode * DeclarationNode::newTraitUse( const std::string * name, ExpressionNode * params ) {
    305         DeclarationNode * newnode = new DeclarationNode;
     294DeclarationNode *DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) {
     295        DeclarationNode *newnode = new DeclarationNode;
    306296        newnode->type = new TypeData( TypeData::AggregateInst );
    307297        newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate );
    308298        newnode->type->aggInst.aggregate->aggregate.kind = Trait;
    309         newnode->type->aggInst.aggregate->aggregate.name = name;
     299        newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name );
    310300        newnode->type->aggInst.params = params;
    311301        return newnode;
    312302} // DeclarationNode::newTraitUse
    313303
    314 DeclarationNode * DeclarationNode::newTypeDecl( std::string * name, DeclarationNode * typeParams ) {
    315         DeclarationNode * newnode = new DeclarationNode;
    316         newnode->name = name;
     304DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) {
     305        DeclarationNode *newnode = new DeclarationNode;
     306        newnode->name = assign_strptr( name );
    317307        newnode->type = new TypeData( TypeData::Symbolic );
    318308        newnode->type->symbolic.isTypedef = false;
     
    322312} // DeclarationNode::newTypeDecl
    323313
    324 DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers ) {
    325         DeclarationNode * newnode = new DeclarationNode;
     314DeclarationNode *DeclarationNode::newPointer( DeclarationNode *qualifiers ) {
     315        DeclarationNode *newnode = new DeclarationNode;
    326316        newnode->type = new TypeData( TypeData::Pointer );
    327317        return newnode->addQualifiers( qualifiers );
    328318} // DeclarationNode::newPointer
    329319
    330 DeclarationNode * DeclarationNode::newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic ) {
    331         DeclarationNode * newnode = new DeclarationNode;
     320DeclarationNode *DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) {
     321        DeclarationNode *newnode = new DeclarationNode;
    332322        newnode->type = new TypeData( TypeData::Array );
    333323        newnode->type->array.dimension = size;
    334324        newnode->type->array.isStatic = isStatic;
    335         if ( newnode->type->array.dimension == nullptr || newnode->type->array.dimension->isExpressionType<ConstantExpr * >() ) {
     325        if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) {
    336326                newnode->type->array.isVarLen = false;
    337327        } else {
     
    341331} // DeclarationNode::newArray
    342332
    343 DeclarationNode * DeclarationNode::newVarArray( DeclarationNode * qualifiers ) {
    344         DeclarationNode * newnode = new DeclarationNode;
     333DeclarationNode *DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {
     334        DeclarationNode *newnode = new DeclarationNode;
    345335        newnode->type = new TypeData( TypeData::Array );
    346         newnode->type->array.dimension = nullptr;
     336        newnode->type->array.dimension = 0;
    347337        newnode->type->array.isStatic = false;
    348338        newnode->type->array.isVarLen = true;
     
    350340}
    351341
    352 DeclarationNode * DeclarationNode::newBitfield( ExpressionNode * size ) {
    353         DeclarationNode * newnode = new DeclarationNode;
     342DeclarationNode *DeclarationNode::newBitfield( ExpressionNode *size ) {
     343        DeclarationNode *newnode = new DeclarationNode;
    354344        newnode->bitfieldWidth = size;
    355345        return newnode;
    356346}
    357347
    358 DeclarationNode * DeclarationNode::newTuple( DeclarationNode * members ) {
    359         DeclarationNode * newnode = new DeclarationNode;
     348DeclarationNode *DeclarationNode::newTuple( DeclarationNode *members ) {
     349        DeclarationNode *newnode = new DeclarationNode;
    360350        newnode->type = new TypeData( TypeData::Tuple );
    361351        newnode->type->tuple = members;
     
    363353}
    364354
    365 DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) {
    366         DeclarationNode * newnode = new DeclarationNode;
     355DeclarationNode *DeclarationNode::newTypeof( ExpressionNode *expr ) {
     356        DeclarationNode *newnode = new DeclarationNode;
    367357        newnode->type = new TypeData( TypeData::Typeof );
    368358        newnode->type->typeexpr = expr;
     
    371361
    372362DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {
    373         DeclarationNode * newnode = new DeclarationNode;
     363        DeclarationNode *newnode = new DeclarationNode;
    374364        newnode->type = new TypeData( TypeData::Builtin );
    375365        newnode->builtin = bt;
     
    377367} // DeclarationNode::newBuiltinType
    378368
    379 DeclarationNode * DeclarationNode::newAttr( std::string * name, ExpressionNode * expr ) {
    380         DeclarationNode * newnode = new DeclarationNode;
    381 //      newnode->type = new TypeData( TypeData::Attr );
    382         newnode->type = nullptr;
    383         newnode->attr.name = name;
     369DeclarationNode *DeclarationNode::newAttr( std::string *name, ExpressionNode *expr ) {
     370        DeclarationNode *newnode = new DeclarationNode;
     371        newnode->type = new TypeData( TypeData::Attr );
     372        newnode->attr.name = assign_strptr( name );
    384373        newnode->attr.expr = expr;
    385374        return newnode;
    386375}
    387376
    388 DeclarationNode * DeclarationNode::newAttr( std::string * name, DeclarationNode * type ) {
    389         DeclarationNode * newnode = new DeclarationNode;
    390 //      newnode->type = new TypeData( TypeData::Attr );
    391         newnode->type = nullptr;
    392         newnode->attr.name = name;
     377DeclarationNode *DeclarationNode::newAttr( std::string *name, DeclarationNode *type ) {
     378        DeclarationNode *newnode = new DeclarationNode;
     379        newnode->type = new TypeData( TypeData::Attr );
     380        newnode->attr.name = assign_strptr( name );
    393381        newnode->attr.type = type;
    394382        return newnode;
     
    401389} // appendError
    402390
    403 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) {
     391void DeclarationNode::checkQualifiers( const TypeData *src, const TypeData *dst ) {
    404392        TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization
    405393
     
    413401} // DeclarationNode::checkQualifiers
    414402
    415 void DeclarationNode::checkStorageClasses( DeclarationNode * q ) {
     403void DeclarationNode::checkStorageClasses( DeclarationNode *q ) {
    416404        if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) {
    417405                if ( storageClass == q->storageClass ) {                // duplicate qualifier
     
    425413} // DeclarationNode::copyStorageClasses
    426414
    427 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) {
     415DeclarationNode *DeclarationNode::copyStorageClasses( DeclarationNode *q ) {
    428416        isInline = isInline || q->isInline;
    429417        isNoreturn = isNoreturn || q->isNoreturn;
     
    436424} // DeclarationNode::copyStorageClasses
    437425
    438 static void addQualifiersToType( TypeData *&src, TypeData * dst ) {
     426static void addQualifiersToType( TypeData *&src, TypeData *dst ) {
    439427        if ( src->forall && dst->kind == TypeData::Function ) {
    440428                if ( dst->forall ) {
     
    443431                        dst->forall = src->forall;
    444432                } // if
    445                 src->forall = nullptr;
     433                src->forall = 0;
    446434        } // if
    447435        if ( dst->base ) {
     
    449437        } else if ( dst->kind == TypeData::Function ) {
    450438                dst->base = src;
    451                 src = nullptr;
     439                src = 0;
    452440        } else {
    453441                dst->qualifiers |= src->qualifiers;
     
    455443} // addQualifiersToType
    456444
    457 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) {
    458         if ( ! q ) { delete q; return this; }
     445DeclarationNode *DeclarationNode::addQualifiers( DeclarationNode *q ) {
     446        if ( ! q ) return this;
    459447
    460448        checkStorageClasses( q );
    461449        copyStorageClasses( q );
    462450
    463         if ( ! q->type ) {
    464                 delete q;
    465                 return this;
    466         } // if
     451        if ( ! q->type ) { delete q; return this; }
    467452
    468453        if ( ! type ) {
    469                 type = q->type;                                                                 // reuse this structure
    470                 q->type = nullptr;
    471                 delete q;
     454//              type = new TypeData;
     455                type = q->type;
    472456                return this;
    473457        } // if
     
    483467                                type->aggregate.params = q->type->forall;
    484468                                // change implicit typedef from TYPEDEFname to TYPEGENname
    485                                 typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
     469                                typedefTable.changeKind( type->aggregate.name, TypedefTable::TG );
    486470                        } else {
    487471                                type->forall = q->type->forall;
    488472                        } // if
    489473                } // if
    490                 q->type->forall = nullptr;
     474                q->type->forall = 0;
    491475        } // if
    492476        delete q;
     
    501485                        dst->forall = src->forall;
    502486                } // if
    503                 src->forall = nullptr;
     487                src->forall = 0;
    504488        } // if
    505489        if ( dst->base ) {
     
    510494                        src->qualifiers |= dst->qualifiers;
    511495                        dst = src;
    512                         src = nullptr;
     496                        src = 0;
    513497                        break;
    514498                  case TypeData::Basic:
     
    550534                                } // if
    551535                                dst->base->qualifiers |= src->qualifiers;
    552                                 src = nullptr;
     536                                src = 0;
    553537                                break;
    554538                          default:
     
    558542                                        dst->forall = src->forall;
    559543                                } // if
    560                                 src->forall = nullptr;
     544                                src->forall = 0;
    561545                                dst->base = src;
    562                                 src = nullptr;
     546                                src = 0;
    563547                        } // switch
    564548                } // switch
     
    566550}
    567551
    568 DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) {
     552DeclarationNode *DeclarationNode::addType( DeclarationNode *o ) {
    569553        if ( o ) {
    570554                checkStorageClasses( o );
     
    582566                                        type = o->type;
    583567                                } // if
    584                                 o->type = nullptr;
     568                                o->type = 0;
    585569                        } else {
    586570                                addTypeToType( o->type, type );
     
    600584}
    601585
    602 DeclarationNode * DeclarationNode::addTypedef() {
    603         TypeData * newtype = new TypeData( TypeData::Symbolic );
    604         newtype->symbolic.params = nullptr;
     586DeclarationNode *DeclarationNode::addTypedef() {
     587        TypeData *newtype = new TypeData( TypeData::Symbolic );
     588        newtype->symbolic.params = 0;
    605589        newtype->symbolic.isTypedef = true;
    606         newtype->symbolic.name = name ? new string( *name ) : nullptr;
     590        newtype->symbolic.name = name;
    607591        newtype->base = type;
    608592        type = newtype;
     
    610594}
    611595
    612 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) {
    613         if ( variable.name ) {
    614                 if ( variable.assertions ) {
    615                         variable.assertions->appendList( assertions );
    616                 } else {
    617                         variable.assertions = assertions;
    618                 } // if
    619                 return this;
    620         } // if
    621 
     596DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) {
    622597        assert( type );
    623598        switch ( type->kind ) {
     
    629604                } // if
    630605                break;
    631           // case TypeData::Variable:
    632           //    if ( variable.assertions ) {
    633           //            variable.assertions->appendList( assertions );
    634           //    } else {
    635           //            variable.assertions = assertions;
    636           //    } // if
    637           //    break;
     606          case TypeData::Variable:
     607                if ( variable.assertions ) {
     608                        variable.assertions->appendList( assertions );
     609                } else {
     610                        variable.assertions = assertions;
     611                } // if
     612                break;
    638613          default:
    639614                assert( false );
     
    643618}
    644619
    645 DeclarationNode * DeclarationNode::addName( std::string * newname ) {
    646         assert( ! name );
    647         name = newname;
    648         return this;
    649 }
    650 
    651 DeclarationNode * DeclarationNode::addBitfield( ExpressionNode * size ) {
     620DeclarationNode *DeclarationNode::addName( std::string *newname ) {
     621        name = assign_strptr( newname );
     622        return this;
     623}
     624
     625DeclarationNode *DeclarationNode::addBitfield( ExpressionNode *size ) {
    652626        bitfieldWidth = size;
    653627        return this;
    654628}
    655629
    656 DeclarationNode * DeclarationNode::addVarArgs() {
     630DeclarationNode *DeclarationNode::addVarArgs() {
    657631        assert( type );
    658632        hasEllipsis = true;
     
    660634}
    661635
    662 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) {
     636DeclarationNode *DeclarationNode::addFunctionBody( StatementNode *body ) {
    663637        assert( type );
    664638        assert( type->kind == TypeData::Function );
    665         assert( ! type->function.body );
     639        assert( type->function.body == 0 );
    666640        type->function.body = body;
    667641        type->function.hasBody = true;
     
    669643}
    670644
    671 DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode * list ) {
     645DeclarationNode *DeclarationNode::addOldDeclList( DeclarationNode *list ) {
    672646        assert( type );
    673647        assert( type->kind == TypeData::Function );
    674         assert( ! type->function.oldDeclList );
     648        assert( type->function.oldDeclList == 0 );
    675649        type->function.oldDeclList = list;
    676650        return this;
    677651}
    678652
    679 static void setBase( TypeData *&type, TypeData * newType ) {
     653static void setBase( TypeData *&type, TypeData *newType ) {
    680654        if ( type ) {
    681                 TypeData * prevBase = type;
    682                 TypeData * curBase = type->base;
    683                 while ( curBase != nullptr ) {
     655                TypeData *prevBase = type;
     656                TypeData *curBase = type->base;
     657                while ( curBase != 0 ) {
    684658                        prevBase = curBase;
    685659                        curBase = curBase->base;
     
    691665}
    692666
    693 DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) {
     667DeclarationNode *DeclarationNode::addPointer( DeclarationNode *p ) {
    694668        if ( p ) {
    695669                assert( p->type->kind == TypeData::Pointer );
    696670                setBase( type, p->type );
    697                 p->type = nullptr;
     671                p->type = 0;
    698672                delete p;
    699673        } // if
     
    701675}
    702676
    703 DeclarationNode * DeclarationNode::addArray( DeclarationNode * a ) {
     677DeclarationNode *DeclarationNode::addArray( DeclarationNode *a ) {
    704678        if ( a ) {
    705679                assert( a->type->kind == TypeData::Array );
    706680                setBase( type, a->type );
    707                 a->type = nullptr;
     681                a->type = 0;
    708682                delete a;
    709683        } // if
     
    711685}
    712686
    713 DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode * p ) {
     687DeclarationNode *DeclarationNode::addNewPointer( DeclarationNode *p ) {
    714688        if ( p ) {
    715689                assert( p->type->kind == TypeData::Pointer );
     
    729703                                p->type->base = type;
    730704                        } // switch
    731                         type = nullptr;
     705                        type = 0;
    732706                } // if
    733707                delete this;
     
    738712}
    739713
    740 static TypeData * findLast( TypeData * a ) {
     714static TypeData *findLast( TypeData *a ) {
    741715        assert( a );
    742         TypeData * cur = a;
     716        TypeData *cur = a;
    743717        while ( cur->base ) {
    744718                cur = cur->base;
     
    747721}
    748722
    749 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) {
     723DeclarationNode *DeclarationNode::addNewArray( DeclarationNode *a ) {
    750724        if ( a ) {
    751725                assert( a->type->kind == TypeData::Array );
    752                 TypeData * lastArray = findLast( a->type );
     726                TypeData *lastArray = findLast( a->type );
    753727                if ( type ) {
    754728                        switch ( type->kind ) {
     
    765739                                lastArray->base = type;
    766740                        } // switch
    767                         type = nullptr;
     741                        type = 0;
    768742                } // if
    769743                delete this;
     
    774748}
    775749
    776 DeclarationNode * DeclarationNode::addParamList( DeclarationNode * params ) {
    777         TypeData * ftype = new TypeData( TypeData::Function );
     750DeclarationNode *DeclarationNode::addParamList( DeclarationNode *params ) {
     751        TypeData *ftype = new TypeData( TypeData::Function );
    778752        ftype->function.params = params;
    779753        setBase( type, ftype );
     
    781755}
    782756
    783 static TypeData * addIdListToType( TypeData * type, DeclarationNode * ids ) {
     757static TypeData *addIdListToType( TypeData *type, DeclarationNode *ids ) {
    784758        if ( type ) {
    785759                if ( type->kind != TypeData::Function ) {
     
    790764                return type;
    791765        } else {
    792                 TypeData * newtype = new TypeData( TypeData::Function );
     766                TypeData *newtype = new TypeData( TypeData::Function );
    793767                newtype->function.idList = ids;
    794768                return newtype;
    795769        } // if
    796 } // addIdListToType
    797 
    798 DeclarationNode * DeclarationNode::addIdList( DeclarationNode * ids ) {
     770}
     771
     772DeclarationNode *DeclarationNode::addIdList( DeclarationNode *ids ) {
    799773        type = addIdListToType( type, ids );
    800774        return this;
    801775}
    802776
    803 DeclarationNode * DeclarationNode::addInitializer( InitializerNode * init ) {
     777DeclarationNode *DeclarationNode::addInitializer( InitializerNode *init ) {
     778        //assert
    804779        initializer = init;
    805780        return this;
    806781}
    807782
    808 DeclarationNode * DeclarationNode::cloneType( string * newName ) {
    809         DeclarationNode * newnode = new DeclarationNode;
     783DeclarationNode *DeclarationNode::cloneBaseType( string *newName ) {
     784        DeclarationNode *newnode = new DeclarationNode;
     785        TypeData *srcType = type;
     786        while ( srcType->base ) {
     787                srcType = srcType->base;
     788        } // while
     789        newnode->type = maybeClone( srcType );
     790        if ( newnode->type->kind == TypeData::AggregateInst ) {
     791                // don't duplicate members
     792                if ( newnode->type->aggInst.aggregate->kind == TypeData::Enum ) {
     793                        delete newnode->type->aggInst.aggregate->enumeration.constants;
     794                        newnode->type->aggInst.aggregate->enumeration.constants = 0;
     795                } else {
     796                        assert( newnode->type->aggInst.aggregate->kind == TypeData::Aggregate );
     797                        delete newnode->type->aggInst.aggregate->aggregate.fields;
     798                        newnode->type->aggInst.aggregate->aggregate.fields = 0;
     799                } // if
     800        } // if
     801        newnode->type->forall = maybeClone( type->forall );
     802        assert( storageClass == NoStorageClass );
     803        newnode->copyStorageClasses( this );
     804        newnode->name = assign_strptr( newName );
     805        return newnode;
     806}
     807
     808DeclarationNode *DeclarationNode::cloneBaseType( DeclarationNode *o ) {
     809        if ( o ) {
     810                o->copyStorageClasses( this );
     811                if ( type ) {
     812                        TypeData *srcType = type;
     813                        while ( srcType->base ) {
     814                                srcType = srcType->base;
     815                        } // while
     816                        TypeData *newType = srcType->clone();
     817                        if ( newType->kind == TypeData::AggregateInst ) {
     818                                // don't duplicate members
     819                                if ( newType->aggInst.aggregate->kind == TypeData::Enum ) {
     820                                        delete newType->aggInst.aggregate->enumeration.constants;
     821                                        newType->aggInst.aggregate->enumeration.constants = 0;
     822                                } else {
     823                                        assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
     824                                        delete newType->aggInst.aggregate->aggregate.fields;
     825                                        newType->aggInst.aggregate->aggregate.fields = 0;
     826                                } // if
     827                        } // if
     828                        newType->forall = maybeClone( type->forall );
     829                        if ( ! o->type ) {
     830                                o->type = newType;
     831                        } else {
     832                                addTypeToType( newType, o->type );
     833                                delete newType;
     834                        } // if
     835                } // if
     836        } // if
     837        return o;
     838}
     839
     840DeclarationNode *DeclarationNode::cloneType( string *newName ) {
     841        DeclarationNode *newnode = new DeclarationNode;
    810842        newnode->type = maybeClone( type );
    811843        assert( storageClass == NoStorageClass );
    812844        newnode->copyStorageClasses( this );
    813         assert( newName );
    814         newnode->name = newName;
    815         return newnode;
    816 }
    817 
    818 DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) {
    819         if ( ! o ) return nullptr;
    820 
    821         o->copyStorageClasses( this );
     845        newnode->name = assign_strptr( newName );
     846        return newnode;
     847}
     848
     849DeclarationNode *DeclarationNode::cloneType( DeclarationNode *o ) {
     850        if ( o ) {
     851                assert( storageClass == NoStorageClass );
     852                o->copyStorageClasses( this );
     853                if ( type ) {
     854                        TypeData *newType = type->clone();
     855                        if ( ! o->type ) {
     856                                o->type = newType;
     857                        } else {
     858                                addTypeToType( newType, o->type );
     859                                delete newType;
     860                        } // if
     861                } // if
     862        } // if
     863        delete o;
     864        return o;
     865}
     866
     867DeclarationNode *DeclarationNode::extractAggregate() const {
    822868        if ( type ) {
    823                 TypeData * srcType = type;
    824 
    825                 while ( srcType->base ) {
    826                         srcType = srcType->base;
    827                 } // while
    828 
    829                 TypeData * newType = srcType->clone();
    830                 if ( newType->kind == TypeData::AggregateInst ) {
    831                         // don't duplicate members
    832                         if ( newType->aggInst.aggregate->kind == TypeData::Enum ) {
    833                                 delete newType->aggInst.aggregate->enumeration.constants;
    834                                 newType->aggInst.aggregate->enumeration.constants = nullptr;
    835                         } else {
    836                                 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
    837                                 delete newType->aggInst.aggregate->aggregate.fields;
    838                                 newType->aggInst.aggregate->aggregate.fields = nullptr;
    839                         } // if
    840                 } // if
    841 
    842                 newType->forall = maybeClone( type->forall );
    843                 if ( ! o->type ) {
    844                         o->type = newType;
    845                 } else {
    846                         addTypeToType( newType, o->type );
    847                         delete newType;
    848                 } // if
    849         } // if
    850         return o;
    851 }
    852 
    853 DeclarationNode * DeclarationNode::extractAggregate() const {
    854         if ( type ) {
    855                 TypeData * ret = typeextractAggregate( type );
     869                TypeData *ret = typeextractAggregate( type );
    856870                if ( ret ) {
    857                         DeclarationNode * newnode = new DeclarationNode;
     871                        DeclarationNode *newnode = new DeclarationNode;
    858872                        newnode->type = ret;
    859873                        return newnode;
    860874                } // if
    861875        } // if
    862         return nullptr;
    863 }
    864 
    865 void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) {
     876        return 0;
     877}
     878
     879void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList ) {
    866880        SemanticError errors;
    867881        std::back_insert_iterator< std::list< Declaration * > > out( outputList );
    868         const DeclarationNode * cur = firstNode;
    869 
     882        const DeclarationNode *cur = firstNode;
    870883        while ( cur ) {
    871884                try {
    872                         if ( DeclarationNode * extr = cur->extractAggregate() ) {
     885                        if ( DeclarationNode *extr = cur->extractAggregate() ) {
    873886                                // handle the case where a structure declaration is contained within an object or type declaration
    874                                 Declaration * decl = extr->build();
     887                                Declaration *decl = extr->build();
    875888                                if ( decl ) {
    876                                         * out++ = decl;
     889                                        *out++ = decl;
    877890                                } // if
    878891                                delete extr;
    879892                        } // if
    880 
    881                         Declaration * decl = cur->build();
     893                        Declaration *decl = cur->build();
    882894                        if ( decl ) {
    883                                 * out++ = decl;
     895                                *out++ = decl;
    884896                        } // if
    885897                } catch( SemanticError &e ) {
     
    888900                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    889901        } // while
    890 
    891902        if ( ! errors.isEmpty() ) {
    892903                throw errors;
    893904        } // if
    894 } // buildList
    895 
    896 void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) {
     905}
     906
     907void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType * > &outputList ) {
    897908        SemanticError errors;
    898909        std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList );
    899         const DeclarationNode * cur = firstNode;
     910        const DeclarationNode *cur = firstNode;
    900911        while ( cur ) {
    901912                try {
    902                         Declaration * decl = cur->build();
     913                        Declaration *decl = cur->build();
    903914                        if ( decl ) {
    904                                 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    905                                         * out++ = dwt;
    906                                 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    907                                         StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
    908                                         * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     915                                if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
     916                                        *out++ = dwt;
     917                                } else if ( StructDecl *agg = dynamic_cast< StructDecl * >( decl ) ) {
     918                                        StructInstType *inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
     919                                        *out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, 0, inst, 0 );
    909920                                        delete agg;
    910                                 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    911                                         UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
    912                                         * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     921                                } else if ( UnionDecl *agg = dynamic_cast< UnionDecl * >( decl ) ) {
     922                                        UnionInstType *inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
     923                                        *out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, 0, inst, 0 );
    913924                                } // if
    914925                        } // if
     
    921932                throw errors;
    922933        } // if
    923 } // buildList
    924 
    925 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) {
     934}
     935
     936void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList ) {
    926937        SemanticError errors;
    927938        std::back_insert_iterator< std::list< Type * > > out( outputList );
    928         const DeclarationNode * cur = firstNode;
    929 
     939        const DeclarationNode *cur = firstNode;
    930940        while ( cur ) {
    931941                try {
    932                         * out++ = cur->buildType();
     942                        *out++ = cur->buildType();
    933943                } catch( SemanticError &e ) {
    934944                        errors.append( e );
     
    936946                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    937947        } // while
    938 
    939948        if ( ! errors.isEmpty() ) {
    940949                throw errors;
    941950        } // if
    942 } // buildTypeList
    943 
    944 Declaration * DeclarationNode::build() const {
     951}
     952
     953Declaration *DeclarationNode::build() const {
    945954        if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this );
    946 
    947         if ( variable.name ) {
    948                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
    949                 TypeDecl * ret = new TypeDecl( *variable.name, DeclarationNode::NoStorageClass, nullptr, kindMap[ variable.tyClass ] );
    950                 buildList( variable.assertions, ret->get_assertions() );
    951                 return ret;
    952         } // if
    953 
    954955        if ( type ) {
    955                 return buildDecl( type, name ? *name : string( "" ), storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
    956         } // if
    957 
     956                if ( type->kind == TypeData::Variable ) {
     957                        static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
     958                        TypeDecl * ret = new TypeDecl( variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ variable.tyClass ] );
     959                        buildList( variable.assertions, ret->get_assertions() );
     960                        return ret;
     961                } else {
     962                        return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
     963                } // if
     964        } // if
    958965        if ( ! isInline && ! isNoreturn ) {
    959                 assertf( name, "ObjectDecl are assumed to have names\n" );
    960                 return (new ObjectDecl( *name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_extension( extension );
    961         } // if
    962 
     966                return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension );
     967        } // if
    963968        throw SemanticError( "invalid function specifier ", this );
    964969}
    965970
    966 Type * DeclarationNode::buildType() const {
     971Type *DeclarationNode::buildType() const {
    967972        assert( type );
    968 
    969         if ( attr.name ) {
    970                 AttrType * ret;
    971                 if ( attr.expr ) {
    972                         ret = new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() );
    973                 } else {
    974                         assert( attr.type );
    975                         ret = new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() );
    976                 } // if
    977                 return ret;
    978         } // if
    979973
    980974        switch ( type->kind ) {
    981975          case TypeData::Enum:
    982                 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name );
     976                return new EnumInstType( buildQualifiers( type ), type->enumeration.name );
    983977          case TypeData::Aggregate: {
    984                   ReferenceToType * ret;
     978                  ReferenceToType *ret;
    985979                  switch ( type->aggregate.kind ) {
    986980                        case DeclarationNode::Struct:
    987                           ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
     981                          ret = new StructInstType( buildQualifiers( type ), type->aggregate.name );
    988982                          break;
    989983                        case DeclarationNode::Union:
    990                           ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
     984                          ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name );
    991985                          break;
    992986                        case DeclarationNode::Trait:
    993                           ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
     987                          ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name );
    994988                          break;
    995989                        default:
     
    1000994          }
    1001995          case TypeData::Symbolic: {
    1002                   TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false );
     996                  TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic.name, false );
    1003997                  buildList( type->symbolic.actuals, ret->get_parameters() );
     998                  return ret;
     999          }
     1000          case TypeData::Attr: {
     1001                  assert( type->kind == TypeData::Attr );
     1002                  // assert( type->attr );
     1003                  AttrType * ret;
     1004                  if ( attr.expr ) {
     1005                          ret = new AttrType( buildQualifiers( type ), attr.name, attr.expr->build() );
     1006                  } else {
     1007                          assert( attr.type );
     1008                          ret = new AttrType( buildQualifiers( type ), attr.name, attr.type->buildType() );
     1009                  } // if
    10041010                  return ret;
    10051011          }
  • src/Parser/ExpressionNode.cc

    r9c23f31 r7ae930a  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep 16 16:27:44 2016
    13 // Update Count     : 508
     12// Last Modified On : Thu Aug 25 21:39:40 2016
     13// Update Count     : 503
    1414//
    1515
     
    3131
    3232using namespace std;
     33
     34ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.get_name() ), extension( other.extension ) {}
    3335
    3436//##############################################################################
  • src/Parser/ParseNode.h

    r9c23f31 r7ae930a  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:12:04 2016
    13 // Update Count     : 633
     12// Last Modified On : Mon Sep 12 08:00:05 2016
     13// Update Count     : 603
    1414//
    1515
     
    4141  public:
    4242        ParseNode() {};
    43         virtual ~ParseNode() { delete next; delete name; };
     43        ParseNode( const std::string * name ) : name( * name ) { assert( false ); delete name; }
     44        ParseNode( const std::string &name ) : name( name ) { assert( false ); }
     45        virtual ~ParseNode() { delete next; };
    4446        virtual ParseNode * clone() const = 0;
    4547
    4648        ParseNode * get_next() const { return next; }
    4749        ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; }
    48 
    4950        ParseNode * get_last() {
    5051                ParseNode * current;
    51                 for ( current = this; current->get_next() != nullptr; current = current->get_next() );
     52                for ( current = this; current->get_next() != 0; current = current->get_next() );
    5253                return current;
    5354        }
    5455        ParseNode * set_last( ParseNode * newlast ) {
    55                 if ( newlast != nullptr ) get_last()->set_next( newlast );
     56                if ( newlast != 0 ) get_last()->set_next( newlast );
    5657                return this;
    5758        }
     59
     60        const std::string &get_name() const { return name; }
     61        void set_name( const std::string &newValue ) { name = newValue; }
    5862
    5963        virtual void print( std::ostream &os, int indent = 0 ) const {}
    6064        virtual void printList( std::ostream &os, int indent = 0 ) const {}
    61 
     65  private:
    6266        static int indent_by;
    6367
    6468        ParseNode * next = nullptr;
    65         std::string * name = nullptr;
     69        std::string name;
    6670}; // ParseNode
    6771
     
    7074class InitializerNode : public ParseNode {
    7175  public:
    72         InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = nullptr );
    73         InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
     76        InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = 0 );
     77        InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = 0 );
    7478        ~InitializerNode();
    7579        virtual InitializerNode * clone() const { assert( false ); return nullptr; }
     
    102106  public:
    103107        ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {}
     108        ExpressionNode( Expression * expr, const std::string * name ) : ParseNode( name ), expr( expr ) {}
    104109        ExpressionNode( const ExpressionNode &other );
    105110        virtual ~ExpressionNode() {}
     
    178183Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node );
    179184Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node );
    180 Expression * build_tuple( ExpressionNode * expr_node = nullptr );
     185Expression * build_tuple( ExpressionNode * expr_node = 0 );
    181186Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node );
    182187Expression * build_range( ExpressionNode * low, ExpressionNode * high );
     
    214219        static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
    215220        static DeclarationNode * newQualifier( Qualifier );
    216         static DeclarationNode * newForall( DeclarationNode * );
     221        static DeclarationNode * newForall( DeclarationNode *);
    217222        static DeclarationNode * newStorageClass( StorageClass );
    218223        static DeclarationNode * newBasicType( BasicType );
     
    221226        static DeclarationNode * newLength( Length lnth );
    222227        static DeclarationNode * newBuiltinType( BuiltinType );
    223         static DeclarationNode * newFromTypedef( std::string * );
     228        static DeclarationNode * newFromTypedef( std::string *);
    224229        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    225230        static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants );
    226231        static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant );
    227         static DeclarationNode * newName( std::string * );
     232        static DeclarationNode * newName( std::string *);
    228233        static DeclarationNode * newFromTypeGen( std::string *, ExpressionNode * params );
    229         static DeclarationNode * newTypeParam( TypeClass, std::string * );
    230         static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts );
    231         static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params );
     234        static DeclarationNode * newTypeParam( TypeClass, std::string *);
     235        static DeclarationNode * newTrait( std::string * name, DeclarationNode * params, DeclarationNode * asserts );
     236        static DeclarationNode * newTraitUse( std::string * name, ExpressionNode * params );
    232237        static DeclarationNode * newTypeDecl( std::string * name, DeclarationNode * typeParams );
    233238        static DeclarationNode * newPointer( DeclarationNode * qualifiers );
     
    244249        DeclarationNode * clone() const;
    245250
    246         DeclarationNode * addQualifiers( DeclarationNode * );
     251        DeclarationNode * addQualifiers( DeclarationNode *);
    247252        void checkQualifiers( const TypeData *, const TypeData * );
    248         void checkStorageClasses( DeclarationNode * );
    249         DeclarationNode * copyStorageClasses( DeclarationNode * );
    250         DeclarationNode * addType( DeclarationNode * );
     253        void checkStorageClasses( DeclarationNode *q );
     254        DeclarationNode * copyStorageClasses( DeclarationNode *);
     255        DeclarationNode * addType( DeclarationNode *);
    251256        DeclarationNode * addTypedef();
    252         DeclarationNode * addAssertions( DeclarationNode * );
    253         DeclarationNode * addName( std::string * );
     257        DeclarationNode * addAssertions( DeclarationNode *);
     258        DeclarationNode * addName( std::string *);
    254259        DeclarationNode * addBitfield( ExpressionNode * size );
    255260        DeclarationNode * addVarArgs();
     
    265270
    266271        DeclarationNode * cloneType( std::string * newName );
     272        DeclarationNode * cloneType( DeclarationNode * existing );
     273        DeclarationNode * cloneType( int ) { return cloneType( ( std::string *)0 ); }
     274        DeclarationNode * cloneBaseType( std::string * newName );
    267275        DeclarationNode * cloneBaseType( DeclarationNode * newdecl );
    268276
     
    278286
    279287        bool get_hasEllipsis() const;
     288        const std::string &get_name() const { return name; }
    280289        LinkageSpec::Spec get_linkage() const { return linkage; }
    281290        DeclarationNode * extractAggregate() const;
     
    286295        DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
    287296  public:
     297        // StorageClass buildStorageClass() const;
     298        // bool buildFuncSpecifier( StorageClass key ) const;
     299
    288300        struct Variable_t {
    289                 const std::string * name;
    290301                DeclarationNode::TypeClass tyClass;
     302                std::string name;
    291303                DeclarationNode * assertions;
    292304        };
     
    294306
    295307        struct Attr_t {
    296                 const std::string * name;
     308                std::string name;
    297309                ExpressionNode * expr;
    298310                DeclarationNode * type;
     
    303315
    304316        TypeData * type;
     317        std::string name;
    305318        StorageClass storageClass;
    306319        bool isInline, isNoreturn;
     
    318331
    319332Type * buildType( TypeData * type );
     333//Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );
    320334
    321335static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) {
     
    379393Statement * build_finally( StatementNode * stmt );
    380394Statement * build_compound( StatementNode * first );
    381 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
     395Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = 0, ExpressionNode * input = 0, ExpressionNode * clobber = 0, LabelNode * gotolabels = 0 );
    382396
    383397//##############################################################################
  • src/Parser/TypeData.cc

    r9c23f31 r7ae930a  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:14:26 2016
    13 // Update Count     : 415
     12// Last Modified On : Mon Sep 12 21:11:22 2016
     13// Update Count     : 377
    1414//
    1515
     
    2424#include "SynTree/Statement.h"
    2525#include "SynTree/Initializer.h"
    26 using namespace std;
    27 
    28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {
     26
     27TypeData::TypeData( Kind k ) : kind( k ), base( 0 ), forall( 0 ) {
    2928        switch ( kind ) {
    3029          case Unknown:
     
    3837          case Array:
    3938                // array = new Array_t;
    40                 array.dimension = nullptr;
     39                array.dimension = 0;
    4140                array.isVarLen = false;
    4241                array.isStatic = false;
     
    4443          case Function:
    4544                // function = new Function_t;
    46                 function.params = nullptr;
    47                 function.idList = nullptr;
    48                 function.oldDeclList = nullptr;
    49                 function.body = nullptr;
     45                function.params = 0;
     46                function.idList = 0;
     47                function.oldDeclList = 0;
     48                function.body = 0;
    5049                function.hasBody = false;
    5150                function.newStyle = false;
     
    5352          case Aggregate:
    5453                // aggregate = new Aggregate_t;
    55                 aggregate.name = nullptr;
    56                 aggregate.params = nullptr;
    57                 aggregate.actuals = nullptr;
    58                 aggregate.fields = nullptr;
     54                aggregate.params = 0;
     55                aggregate.actuals = 0;
     56                aggregate.fields = 0;
    5957                break;
    6058          case AggregateInst:
    6159                // aggInst = new AggInst_t;
    62                 aggInst.aggregate = nullptr;
    63                 aggInst.params = nullptr;
     60                aggInst.aggregate = 0;
     61                aggInst.params = 0;
    6462                break;
    6563          case Enum:
    6664                // enumeration = new Enumeration_t;
    67                 enumeration.name = nullptr;
    68                 enumeration.constants = nullptr;
     65                enumeration.constants = 0;
    6966                break;
    7067          case Symbolic:
    7168          case SymbolicInst:
    7269                // symbolic = new Symbolic_t;
    73                 symbolic.name = nullptr;
    74                 symbolic.params = nullptr;
    75                 symbolic.actuals = nullptr;
    76                 symbolic.assertions = nullptr;
     70                symbolic.params = 0;
     71                symbolic.actuals = 0;
     72                symbolic.assertions = 0;
     73                break;
     74          case Variable:
     75                // variable = new Variable_t;
     76                // variable.tyClass = DeclarationNode::Type;
     77                // variable.assertions = 0;
    7778                break;
    7879          case Tuple:
     
    8384                // typeexpr = new Typeof_t;
    8485                typeexpr = nullptr;
     86                break;
     87          case Attr:
     88                // attr = new Attr_t;
     89                // attr.expr = nullptr;
     90                // attr.type = nullptr;
    8591                break;
    8692          case Builtin:
     
    115121                break;
    116122          case Aggregate:
    117                 delete aggregate.name;
    118123                delete aggregate.params;
    119124                delete aggregate.actuals;
     
    127132                break;
    128133          case Enum:
    129                 delete enumeration.name;
    130134                delete enumeration.constants;
    131135                // delete enumeration;
     
    133137          case Symbolic:
    134138          case SymbolicInst:
    135                 delete symbolic.name;
    136139                delete symbolic.params;
    137140                delete symbolic.actuals;
     
    139142                // delete symbolic;
    140143                break;
     144          case Variable:
     145                // delete variable.assertions;
     146                // delete variable;
     147                break;
    141148          case Tuple:
    142149                // delete tuple->members;
     
    146153                // delete typeexpr->expr;
    147154                delete typeexpr;
     155                break;
     156          case Attr:
     157                // delete attr.expr;
     158                // delete attr.type;
     159                // delete attr;
    148160                break;
    149161          case Builtin:
     
    185197                break;
    186198          case Aggregate:
    187                 newtype->aggregate.name = aggregate.name ? new string( *aggregate.name ) : nullptr;
    188199                newtype->aggregate.params = maybeClone( aggregate.params );
    189200                newtype->aggregate.actuals = maybeClone( aggregate.actuals );
    190201                newtype->aggregate.fields = maybeClone( aggregate.fields );
     202                newtype->aggregate.name = aggregate.name;
    191203                newtype->aggregate.kind = aggregate.kind;
    192204                newtype->aggregate.body = aggregate.body;
     
    197209                break;
    198210          case Enum:
    199                 newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr;
     211                newtype->enumeration.name = enumeration.name;
    200212                newtype->enumeration.constants = maybeClone( enumeration.constants );
    201213                break;
    202214          case Symbolic:
    203215          case SymbolicInst:
    204                 newtype->symbolic.name = symbolic.name ? new string( *symbolic.name ) : nullptr;
    205216                newtype->symbolic.params = maybeClone( symbolic.params );
    206217                newtype->symbolic.actuals = maybeClone( symbolic.actuals );
    207218                newtype->symbolic.assertions = maybeClone( symbolic.assertions );
    208219                newtype->symbolic.isTypedef = symbolic.isTypedef;
     220                newtype->symbolic.name = symbolic.name;
     221                break;
     222          case Variable:
     223                assert( false );
     224                // newtype->variable.assertions = maybeClone( variable.assertions );
     225                // newtype->variable.name = variable.name;
     226                // newtype->variable.tyClass = variable.tyClass;
    209227                break;
    210228          case Tuple:
     
    213231          case Typeof:
    214232                newtype->typeexpr = maybeClone( typeexpr );
     233                break;
     234          case Attr:
     235                assert( false );
     236                // newtype->attr.expr = maybeClone( attr.expr );
     237                // newtype->attr.type = maybeClone( attr.type );
    215238                break;
    216239          case Builtin:
     
    222245} // TypeData::clone
    223246
    224 void TypeData::print( ostream &os, int indent ) const {
     247void TypeData::print( std::ostream &os, int indent ) const {
     248        using std::endl;
     249        using std::string;
     250
    225251        for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) {
    226252                if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';
     
    300326                break;
    301327          case Aggregate:
    302                 os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << *aggregate.name << endl;
     328                os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << aggregate.name << endl;
    303329                if ( aggregate.params ) {
    304330                        os << string( indent + 2, ' ' ) << "with type parameters " << endl;
     
    337363                break;
    338364          case SymbolicInst:
    339                 os << "instance of type " << *symbolic.name;
     365                os << "instance of type " << symbolic.name;
    340366                if ( symbolic.actuals ) {
    341367                        os << " with parameters" << endl;
     
    363389                } // if
    364390                break;
     391          case Variable:
     392                // os << DeclarationNode::typeClassName[ variable.tyClass ] << " variable ";
     393                // if ( variable.assertions ) {
     394                //      os << endl << string( indent + 2, ' ' ) << "with assertions" << endl;
     395                //      variable.assertions->printList( os, indent + 4 );
     396                //      os << string( indent + 2, ' ' );
     397                // } // if
     398                break;
    365399          case Tuple:
    366400                os << "tuple ";
     
    376410                } // if
    377411                break;
     412          case Attr:
     413                // os << "attribute type decl " << attr.name << " applied to ";
     414                // if ( attr.expr ) {
     415                //      attr.expr->print( os, indent + 2 );
     416                // } // if
     417                // if ( attr.type ) {
     418                //      attr.type->print( os, indent + 2 );
     419                // } // if
     420                break;
    378421          case Builtin:
    379422                os << "gcc builtin type";
     
    385428} // TypeData::print
    386429
    387 void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) {
     430void buildForall( const DeclarationNode * firstNode, std::list< TypeDecl* > &outputList ) {
    388431        buildList( firstNode, outputList );
    389         for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     432        for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    390433                if ( (*i)->get_kind() == TypeDecl::Any ) {
    391434                        // add assertion parameters to `type' tyvars in reverse order
    392435                        // add dtor:  void ^?{}(T *)
    393436                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    394                         dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    395                         (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
     437                        dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     438                        (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) );
    396439
    397440                        // add copy ctor:  void ?{}(T *, T)
    398441                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );
    399                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    400                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    401                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
     442                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     443                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );
     444                        (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, 0, false, false ) );
    402445
    403446                        // add default ctor:  void ?{}(T *)
    404447                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    405                         ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    406                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
     448                        ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     449                        (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) );
    407450
    408451                        // add assignment operator:  T * ?=?(T *, T)
    409452                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );
    410                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );
    411                         assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    412                         assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );
    413                         (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
     453                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     454                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );
     455                        assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );
     456                        (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, 0, false, false ) );
    414457                } // if
    415458        } // for
     
    443486          case TypeData::Builtin:
    444487                return new VarArgsType( buildQualifiers( td ) );
     488          case TypeData::Attr:
     489                assert( false );
     490                return buildAttr( td );
    445491          case TypeData::Symbolic:
    446492          case TypeData::Enum:
    447493          case TypeData::Aggregate:
     494          case TypeData::Variable:
    448495                assert( false );
    449496        } // switch
    450         return nullptr;
     497        return 0;
    451498} // typebuild
    452499
    453500TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) {
    454         TypeData * ret = nullptr;
     501        TypeData * ret = 0;
    455502
    456503        switch ( td->kind ) {
     
    502549          case DeclarationNode::Bool:
    503550                if ( td->signedness != DeclarationNode::NoSignedness ) {
    504                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     551                        throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
    505552                } // if
    506553                if ( td->length != DeclarationNode::NoLength ) {
    507                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     554                        throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    508555                } // if
    509556
     
    518565
    519566                if ( td->length != DeclarationNode::NoLength ) {
    520                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     567                        throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    521568                } // if
    522569
     
    548595          FloatingPoint: ;
    549596                if ( td->signedness != DeclarationNode::NoSignedness ) {
    550                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     597                        throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
    551598                } // if
    552599                if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
    553                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     600                        throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    554601                } // if
    555602                if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
     
    608655        switch ( td->aggregate.kind ) {
    609656          case DeclarationNode::Struct:
    610                 at = new StructDecl( *td->aggregate.name );
     657                at = new StructDecl( td->aggregate.name );
    611658                buildForall( td->aggregate.params, at->get_parameters() );
    612659                break;
    613660          case DeclarationNode::Union:
    614                 at = new UnionDecl( *td->aggregate.name );
     661                at = new UnionDecl( td->aggregate.name );
    615662                buildForall( td->aggregate.params, at->get_parameters() );
    616663                break;
    617664          case DeclarationNode::Trait:
    618                 at = new TraitDecl( *td->aggregate.name );
     665                at = new TraitDecl( td->aggregate.name );
    619666                buildList( td->aggregate.params, at->get_parameters() );
    620667                break;
     
    634681        ReferenceToType * ret;
    635682        if ( td->aggInst.aggregate->kind == TypeData::Enum ) {
    636                 ret = new EnumInstType( buildQualifiers( td ), *td->aggInst.aggregate->enumeration.name );
     683                ret = new EnumInstType( buildQualifiers( td ), td->aggInst.aggregate->enumeration.name );
    637684        } else {
    638685                assert( td->aggInst.aggregate->kind == TypeData::Aggregate );
    639686                switch ( td->aggInst.aggregate->aggregate.kind ) {
    640687                  case DeclarationNode::Struct:
    641                         assert( td->aggInst.aggregate->aggregate.name );
    642                         ret = new StructInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
     688                        ret = new StructInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
    643689                        break;
    644690                  case DeclarationNode::Union:
    645                         ret = new UnionInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
     691                        ret = new UnionInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
    646692                        break;
    647693                  case DeclarationNode::Trait:
    648                         ret = new TraitInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
     694                        ret = new TraitInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
    649695                        break;
    650696                  default:
     
    657703} // buildAggInst
    658704
    659 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClass sc ) {
     705NamedTypeDecl * buildSymbolic( const TypeData * td, const std::string & name, DeclarationNode::StorageClass sc ) {
    660706        assert( td->kind == TypeData::Symbolic );
    661707        NamedTypeDecl * ret;
     
    671717} // buildSymbolic
    672718
     719TypeDecl * buildVariable( const TypeData * td ) {
     720        assert( false );
     721        return nullptr;
     722        // assert( td->kind == TypeData::Variable );
     723        // static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
     724
     725        // TypeDecl * ret = new TypeDecl( td->variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable.tyClass ] );
     726        // buildList( td->variable.assertions, ret->get_assertions() );
     727        // return ret;
     728} // buildSymbolic
     729
    673730EnumDecl * buildEnum( const TypeData * td ) {
    674731        assert( td->kind == TypeData::Enum );
    675         EnumDecl * ret = new EnumDecl( *td->enumeration.name );
     732        EnumDecl * ret = new EnumDecl( td->enumeration.name );
    676733        buildList( td->enumeration.constants, ret->get_members() );
    677         list< Declaration * >::iterator members = ret->get_members().begin();
     734        std::list< Declaration * >::iterator members = ret->get_members().begin();
    678735        for ( const DeclarationNode * cur = td->enumeration. constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    679736                if ( cur->has_enumeratorValue() ) {
    680737                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    681                         member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), list< Expression * >() ) );
     738                        member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), std::list< Expression * >() ) );
    682739                } // if
    683740        } // for
     
    687744TypeInstType * buildSymbolicInst( const TypeData * td ) {
    688745        assert( td->kind == TypeData::SymbolicInst );
    689         TypeInstType * ret = new TypeInstType( buildQualifiers( td ), *td->symbolic.name, false );
     746        TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic.name, false );
    690747        buildList( td->symbolic.actuals, ret->get_parameters() );
    691748        buildForall( td->forall, ret->get_forall() );
     
    708765} // buildTypeof
    709766
    710 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) {
     767AttrType * buildAttr( const TypeData * td ) {
     768        assert( false );
     769        return nullptr;
     770        // assert( td->kind == TypeData::Attr );
     771        // // assert( td->attr );
     772        // AttrType * ret;
     773        // if ( td->attr.expr ) {
     774        //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.expr->build() );
     775        // } else {
     776        //      assert( td->attr.type );
     777        //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.type->buildType() );
     778        // } // if
     779        // return ret;
     780} // buildAttr
     781
     782Declaration * buildDecl( const TypeData * td, std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) {
    711783        if ( td->kind == TypeData::Function ) {
    712784                FunctionDecl * decl;
     
    718790                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn );
    719791                        } else {
    720                                 // list< Label > ls;
    721                                 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( list< Label >() ), isInline, isNoreturn );
     792                                // std::list< Label > ls;
     793                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( std::list< Label >() ), isInline, isNoreturn );
    722794                        } // if
    723795                } else {
    724                         decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), nullptr, isInline, isNoreturn );
    725                 } // if
    726                 for ( DeclarationNode * cur = td->function.idList; cur != nullptr; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {
    727                         if ( cur->name ) {
    728                                 decl->get_oldIdents().insert( decl->get_oldIdents().end(), *cur->name );
     796                        decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), 0, isInline, isNoreturn );
     797                } // if
     798                for ( DeclarationNode * cur = td->function.idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {
     799                        if ( cur->get_name() != "" ) {
     800                                decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() );
    729801                        } // if
    730802                } // for
     
    737809        } else if ( td->kind == TypeData::Symbolic ) {
    738810                return buildSymbolic( td, name, sc );
     811        } else if ( td->kind == TypeData::Variable ) {
     812                assert( false );
     813                return buildVariable( td );
    739814        } else {
    740                 return new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, list< Attribute * >(), isInline, isNoreturn );
     815                return new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, std::list< Attribute * >(), isInline, isNoreturn );
    741816        } // if
    742         return nullptr;
     817        return 0;
    743818} // buildDecl
    744819
     
    756831                        break;
    757832                  default:
    758                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base,  "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall ) ) );
     833                        ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base,  "", DeclarationNode::NoStorageClass, 0, false, false, LinkageSpec::Cforall ) ) );
    759834                } // switch
    760835        } else {
    761                 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
     836                ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ) );
    762837        } // if
    763838        return ft;
  • src/Parser/TypeData.h

    r9c23f31 r7ae930a  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 11:10:38 2016
    13 // Update Count     : 141
     12// Last Modified On : Mon Sep 12 17:15:49 2016
     13// Update Count     : 129
    1414//
    1515
     
    2424struct TypeData {
    2525        enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
    26                                 Enum, EnumConstant, Symbolic, SymbolicInst, Tuple, Typeof, Builtin };
     26                                Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr };
    2727
    2828        struct Aggregate_t {
    2929                DeclarationNode::Aggregate kind;
    30                 const std::string * name;
     30                std::string name;
    3131                DeclarationNode * params;
    32                 ExpressionNode * actuals;                                               // holds actual parameters later applied to AggInst
     32                ExpressionNode  * actuals;                                              // holds actual parameters later applied to AggInst
    3333                DeclarationNode * fields;
    3434                bool body;
     
    4747
    4848        struct Enumeration_t {
    49                 const std::string * name;
     49                std::string name;
    5050                DeclarationNode * constants;
    5151        };
     
    6161
    6262        struct Symbolic_t {
    63                 const std::string * name;
     63                std::string name;
    6464                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
    6565                DeclarationNode * params;
     
    8888                DeclarationNode * tuple;
    8989                ExpressionNode * typeexpr;
     90                // Attr_t attr;
    9091                // DeclarationNode::BuiltinType builtin;
    9192
     
    110111TupleType * buildTuple( const TypeData * );
    111112TypeofType * buildTypeof( const TypeData * );
    112 Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = nullptr );
     113AttrType * buildAttr( const TypeData * );
     114Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 );
    113115FunctionType * buildFunction( const TypeData * );
    114116
  • src/Parser/parser.h

    r9c23f31 r7ae930a  
    262262
    263263/* Line 2068 of yacc.c  */
    264 #line 116 "parser.yy"
     264#line 115 "parser.yy"
    265265
    266266        Token tok;
  • src/Parser/parser.yy

    r9c23f31 r7ae930a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 24 12:16:53 2016
    13 // Update Count     : 1992
     12// Last Modified On : Mon Sep 12 17:29:45 2016
     13// Update Count     : 1969
    1414//
    1515
     
    5454#include "TypeData.h"
    5555#include "LinkageSpec.h"
    56 using namespace std;
    5756
    5857extern DeclarationNode * parseTree;
     
    6059extern TypedefTable typedefTable;
    6160
    62 stack< LinkageSpec::Spec > linkageStack;
    63 
    64 void appendStr( string *to, string *from ) {
     61std::stack< LinkageSpec::Spec > linkageStack;
     62
     63void appendStr( std::string *to, std::string *from ) {
    6564        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    6665        to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) );
     
    360359                { $$ = $2; }
    361360        | '(' compound_statement ')'                                            // GCC, lambda expression
    362                 { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     361        { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    363362        ;
    364363
     
    390389                {
    391390                        Token fn;
    392                         fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
     391                        fn.str = new std::string( "?{}" ); // location undefined - use location of '{'?
    393392                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    394393                }
     
    667666                {
    668667                        Token fn;
    669                         fn.str = new string( "^?{}" );                          // location undefined
     668                        fn.str = new std::string( "^?{}" ); // location undefined
    670669                        $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    671670                }
     
    897896                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    898897        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    899                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     898        { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    900899        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    901900                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     
    969968                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    970969        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    971                 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     970        { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    972971        ;
    973972
     
    14681467aggregate_name:
    14691468        aggregate_key '{' field_declaration_list '}'
    1470                 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $3, true ); }
     1469                { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }
    14711470        | aggregate_key no_attr_identifier_or_type_name
    14721471                {
    14731472                        typedefTable.makeTypedef( *$2 );
    1474                         $$ = DeclarationNode::newAggregate( $1, $2, nullptr, nullptr, false );
     1473                        $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, false );
    14751474                }
    14761475        | aggregate_key no_attr_identifier_or_type_name
    14771476                { typedefTable.makeTypedef( *$2 ); }
    14781477                '{' field_declaration_list '}'
    1479                 { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }
     1478                { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }
    14801479        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1481                 { $$ = DeclarationNode::newAggregate( $1, nullptr, $3, $6, false ); }
     1480                { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); }
    14821481        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14831482                { $$ = $2; }
     
    15601559enum_name:
    15611560        enum_key '{' enumerator_list comma_opt '}'
    1562                 { $$ = DeclarationNode::newEnum( nullptr, $3 ); }
     1561                { $$ = DeclarationNode::newEnum( 0, $3 ); }
    15631562        | enum_key no_attr_identifier_or_type_name
    15641563                {
     
    25212520abstract_function:
    25222521        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2523                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
     2522                { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
    25242523        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25252524                { $$ = $2->addParamList( $6 ); }
     
    25902589abstract_parameter_function:
    25912590        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2592                 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
     2591                { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
    25932592        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25942593                { $$ = $2->addParamList( $6 ); }
     
    27942793                // empty (void) function return type.
    27952794        '[' ']' type_specifier
    2796                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2795                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    27972796        | '[' ']' multi_array_dimension type_specifier
    2798                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2797                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    27992798        | multi_array_dimension type_specifier
    28002799                { $$ = $2->addNewArray( $1 ); }
    28012800        | '[' ']' new_abstract_ptr
    2802                 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2801                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    28032802        | '[' ']' multi_array_dimension new_abstract_ptr
    2804                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
     2803                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    28052804        | multi_array_dimension new_abstract_ptr
    28062805                { $$ = $2->addNewArray( $1 ); }
     
    28142813new_abstract_function:                                                                  // CFA
    28152814        '[' ']' '(' new_parameter_type_list_opt ')'
    2816                 { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
     2815                { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
    28172816        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    2818                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     2817                { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
    28192818        | new_function_return '(' push new_parameter_type_list_opt pop ')'
    2820                 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
     2819                { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
    28212820        ;
    28222821
     
    28532852
    28542853void yyerror( const char * ) {
    2855         cout << "Error ";
     2854        std::cout << "Error ";
    28562855        if ( yyfilename ) {
    2857                 cout << "in file " << yyfilename << " ";
     2856                std::cout << "in file " << yyfilename << " ";
    28582857        } // if
    2859         cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << endl;
     2858        std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
    28602859}
    28612860
Note: See TracChangeset for help on using the changeset viewer.