Changes in / [7ae930a:9c23f31]


Ignore:
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r7ae930a r9c23f31  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun  8 17:33:59 2016
    13 // Update Count     : 22
     12// Last Modified On : Fri Sep 23 11:46:47 2016
     13// Update Count     : 28
    1414//
    1515
     
    2525#include <sstream>
    2626#include <string>
     27#include <cassert>
    2728
    2829template< typename T >
     
    101102                } // if
    102103        } // for
    103 }
    104 
    105 static 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
    114104}
    115105
     
    141131
    142132template < typename T >
    143 void toString_single ( std::ostream & os, const T & value ) {
     133void toString_single( std::ostream & os, const T & value ) {
    144134        os << value;
    145135}
    146136
    147137template < typename T, typename... Params >
    148 void toString_single ( std::ostream & os, const T & value, const Params & ... params ) {
     138void toString_single( std::ostream & os, const T & value, const Params & ... params ) {
    149139        os << value;
    150140        toString_single( os, params ... );
     
    152142
    153143template < typename ... Params >
    154 std::string toString ( const Params & ... params ) {
     144std::string toString( const Params & ... params ) {
    155145        std::ostringstream os;
    156146        toString_single( os, params... );
  • src/Parser/DeclarationNode.cc

    r7ae930a r9c23f31  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Sep 14 23:13:28 2016
    13 // Update Count     : 502
     12// Last Modified On : Sat Sep 24 11:12:52 2016
     13// Update Count     : 627
    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( 0 ),
     48                type( nullptr ),
    4949                storageClass( NoStorageClass ),
    5050                isInline( false ),
    5151                isNoreturn( false ),
    52                 bitfieldWidth( 0 ),
    53                 initializer( 0 ),
     52                bitfieldWidth( nullptr ),
     53                initializer( nullptr ),
    5454                hasEllipsis( false ),
    5555                linkage( ::linkage ),
    5656                extension( false ) {
     57
     58        variable.name = nullptr;
    5759        variable.tyClass = DeclarationNode::Otype;
    5860        variable.assertions = nullptr;
    5961
     62        attr.name = nullptr;
    6063        attr.expr = nullptr;
    6164        attr.type = nullptr;
     
    6366
    6467DeclarationNode::~DeclarationNode() {
     68        delete attr.name;
    6569        delete attr.expr;
    6670        delete attr.type;
     71
     72        delete variable.name;
     73        delete variable.assertions;
     74
    6775        delete type;
    6876        delete bitfieldWidth;
     
    7078}
    7179
    72 DeclarationNode *DeclarationNode::clone() const {
    73         DeclarationNode *newnode = new DeclarationNode;
     80DeclarationNode * DeclarationNode::clone() const {
     81        DeclarationNode * newnode = new DeclarationNode;
    7482        newnode->type = maybeClone( type );
    75         newnode->name = name;
     83        newnode->name = name ? new string( *name ) : nullptr;
    7684        newnode->storageClass = storageClass;
    7785        newnode->isInline = isInline;
     
    8391        newnode->linkage = linkage;
    8492
     93        newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr;
    8594        newnode->variable.assertions = maybeClone( variable.assertions );
    86         newnode->variable.name = variable.name;
    8795        newnode->variable.tyClass = variable.tyClass;
    8896
     97        newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
    8998        newnode->attr.expr = maybeClone( attr.expr );
    9099        newnode->attr.type = maybeClone( attr.type );
     
    98107void DeclarationNode::print( std::ostream &os, int indent ) const {
    99108        os << string( indent, ' ' );
    100         if ( name == "" ) {
     109        if ( name ) {
     110                os << *name << ": ";
     111        } else {
    101112                os << "unnamed: ";
    102         } else {
    103                 os << name << ": ";
    104113        } // if
    105114
     
    122131        } // if
    123132
    124         if ( initializer != 0 ) {
     133        if ( initializer ) {
    125134                os << endl << string( indent + 2, ' ' ) << "with initializer ";
    126135                initializer->printOneLine( os );
     
    139148}
    140149
    141 DeclarationNode *DeclarationNode::newFunction( std::string *name, DeclarationNode *ret, DeclarationNode *param, StatementNode *body, bool newStyle ) {
    142         DeclarationNode *newnode = new DeclarationNode;
    143         newnode->name = assign_strptr( name );
     150DeclarationNode * DeclarationNode::newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
     151        DeclarationNode * newnode = new DeclarationNode;
     152        newnode->name = name;
    144153
    145154        newnode->type = new TypeData( TypeData::Function );
     
    147156        newnode->type->function.newStyle = newStyle;
    148157        newnode->type->function.body = body;
    149         typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
     158        // ignore unnamed routine declarations: void p( int (*)(int) );
     159        if ( newnode->name ) {
     160                typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID );
     161        } // if
    150162
    151163        if ( body ) {
     
    155167        if ( ret ) {
    156168                newnode->type->base = ret->type;
    157                 ret->type = 0;
     169                ret->type = nullptr;
    158170                delete ret;
    159171        } // if
     
    163175
    164176DeclarationNode * DeclarationNode::newQualifier( Qualifier q ) {
    165         DeclarationNode *newnode = new DeclarationNode;
     177        DeclarationNode * newnode = new DeclarationNode;
    166178        newnode->type = new TypeData();
    167179        newnode->type->qualifiers[ q ] = 1;
     
    169181} // DeclarationNode::newQualifier
    170182
    171 DeclarationNode * DeclarationNode::newForall( DeclarationNode *forall ) {
    172         DeclarationNode *newnode = new DeclarationNode;
     183DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) {
     184        DeclarationNode * newnode = new DeclarationNode;
    173185        newnode->type = new TypeData( TypeData::Unknown );
    174186        newnode->type->forall = forall;
     
    177189
    178190DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {
    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         //}
     191        DeclarationNode * newnode = new DeclarationNode;
    185192        newnode->storageClass = sc;
    186193        return newnode;
     
    188195
    189196DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) {
    190         DeclarationNode *newnode = new DeclarationNode;
     197        DeclarationNode * newnode = new DeclarationNode;
    191198        newnode->type = new TypeData( TypeData::Basic );
    192199        newnode->type->basictype = bt;
     
    195202
    196203DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) {
    197         DeclarationNode *newnode = new DeclarationNode;
     204        DeclarationNode * newnode = new DeclarationNode;
    198205        newnode->type = new TypeData( TypeData::Basic );
    199206        newnode->type->complextype = ct;
     
    202209
    203210DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) {
    204         DeclarationNode *newnode = new DeclarationNode;
     211        DeclarationNode * newnode = new DeclarationNode;
    205212        newnode->type = new TypeData( TypeData::Basic );
    206213        newnode->type->signedness = sn;
     
    209216
    210217DeclarationNode * DeclarationNode::newLength( Length lnth ) {
    211         DeclarationNode *newnode = new DeclarationNode;
     218        DeclarationNode * newnode = new DeclarationNode;
    212219        newnode->type = new TypeData( TypeData::Basic );
    213220        newnode->type->length = lnth;
     
    215222} // DeclarationNode::newLength
    216223
    217 DeclarationNode * DeclarationNode::newFromTypedef( std::string *name ) {
    218         DeclarationNode *newnode = new DeclarationNode;
     224DeclarationNode * DeclarationNode::newFromTypedef( std::string * name ) {
     225        DeclarationNode * newnode = new DeclarationNode;
    219226        newnode->type = new TypeData( TypeData::SymbolicInst );
    220         newnode->type->symbolic.name = assign_strptr( name );
     227        newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
    221228        newnode->type->symbolic.isTypedef = true;
    222         newnode->type->symbolic.params = 0;
     229        newnode->type->symbolic.params = nullptr;
    223230        return newnode;
    224231} // DeclarationNode::newFromTypedef
    225232
    226 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields, bool body ) {
    227         DeclarationNode *newnode = new DeclarationNode;
     233DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     234        DeclarationNode * newnode = new DeclarationNode;
    228235        newnode->type = new TypeData( TypeData::Aggregate );
    229236        newnode->type->aggregate.kind = kind;
    230         newnode->type->aggregate.name = assign_strptr( name );
    231         if ( newnode->type->aggregate.name == "" ) {            // anonymous aggregate ?
    232                 newnode->type->aggregate.name = anonymous.newName();
     237        if ( name ) {
     238                newnode->type->aggregate.name = new string( *name );
     239        } else {                                                                                        // anonymous aggregate ?
     240                newnode->type->aggregate.name = new string( anonymous.newName() );
    233241        } // if
    234242        newnode->type->aggregate.actuals = actuals;
     
    238246} // DeclarationNode::newAggregate
    239247
    240 DeclarationNode *DeclarationNode::newEnum( std::string *name, DeclarationNode *constants ) {
    241         DeclarationNode *newnode = new DeclarationNode;
    242         newnode->name = assign_strptr( name );
     248DeclarationNode * DeclarationNode::newEnum( std::string * name, DeclarationNode * constants ) {
     249        DeclarationNode * newnode = new DeclarationNode;
     250        newnode->name = name;
    243251        newnode->type = new TypeData( TypeData::Enum );
    244         newnode->type->enumeration.name = newnode->name;
    245         if ( newnode->type->enumeration.name == "" ) {          // anonymous enumeration ?
    246                 newnode->type->enumeration.name = DeclarationNode::anonymous.newName();
     252        if ( name ) {
     253                newnode->type->enumeration.name = new string( *name );
     254        } else {                                                                                        // anonymous aggregate ?
     255                newnode->type->enumeration.name = new string( anonymous.newName() );
    247256        } // if
    248257        newnode->type->enumeration.constants = constants;
     
    250259} // DeclarationNode::newEnum
    251260
    252 DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) {
    253         DeclarationNode *newnode = new DeclarationNode;
    254         newnode->name = assign_strptr( name );
     261DeclarationNode * DeclarationNode::newEnumConstant( std::string * name, ExpressionNode * constant ) {
     262        DeclarationNode * newnode = new DeclarationNode;
     263        newnode->name = name;
    255264        newnode->enumeratorValue.reset( constant );
    256         typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
     265        typedefTable.addToEnclosingScope( *newnode->name, TypedefTable::ID );
    257266        return newnode;
    258267} // DeclarationNode::newEnumConstant
    259268
    260 DeclarationNode *DeclarationNode::newName( std::string *name ) {
    261         DeclarationNode *newnode = new DeclarationNode;
    262         newnode->name = assign_strptr( name );
     269DeclarationNode * DeclarationNode::newName( std::string * name ) {
     270        DeclarationNode * newnode = new DeclarationNode;
     271        newnode->name = name;
    263272        return newnode;
    264273} // DeclarationNode::newName
    265274
    266 DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) {
    267         DeclarationNode *newnode = new DeclarationNode;
     275DeclarationNode * DeclarationNode::newFromTypeGen( std::string * name, ExpressionNode * params ) {
     276        DeclarationNode * newnode = new DeclarationNode;
    268277        newnode->type = new TypeData( TypeData::SymbolicInst );
    269         newnode->type->symbolic.name = assign_strptr( name );
     278        newnode->type->symbolic.name = name ? new string( *name ) : nullptr;
    270279        newnode->type->symbolic.isTypedef = false;
    271280        newnode->type->symbolic.actuals = params;
     
    273282} // DeclarationNode::newFromTypeGen
    274283
    275 DeclarationNode *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 );
     284DeclarationNode * 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;
    279289        newnode->variable.tyClass = tc;
    280         newnode->variable.name = newnode->name;
     290        newnode->variable.name = newnode->name ? new string( *newnode->name ) : nullptr;
    281291        return newnode;
    282292} // DeclarationNode::newTypeParam
    283293
    284 DeclarationNode *DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) {
    285         DeclarationNode *newnode = new DeclarationNode;
     294DeclarationNode * DeclarationNode::newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ) {
     295        DeclarationNode * newnode = new DeclarationNode;
    286296        newnode->type = new TypeData( TypeData::Aggregate );
     297        newnode->type->aggregate.name = name;
    287298        newnode->type->aggregate.kind = Trait;
    288299        newnode->type->aggregate.params = params;
    289300        newnode->type->aggregate.fields = asserts;
    290         newnode->type->aggregate.name = assign_strptr( name );
    291301        return newnode;
    292302} // DeclarationNode::newTrait
    293303
    294 DeclarationNode *DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) {
    295         DeclarationNode *newnode = new DeclarationNode;
     304DeclarationNode * DeclarationNode::newTraitUse( const std::string * name, ExpressionNode * params ) {
     305        DeclarationNode * newnode = new DeclarationNode;
    296306        newnode->type = new TypeData( TypeData::AggregateInst );
    297307        newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate );
    298308        newnode->type->aggInst.aggregate->aggregate.kind = Trait;
    299         newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name );
     309        newnode->type->aggInst.aggregate->aggregate.name = name;
    300310        newnode->type->aggInst.params = params;
    301311        return newnode;
    302312} // DeclarationNode::newTraitUse
    303313
    304 DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) {
    305         DeclarationNode *newnode = new DeclarationNode;
    306         newnode->name = assign_strptr( name );
     314DeclarationNode * DeclarationNode::newTypeDecl( std::string * name, DeclarationNode * typeParams ) {
     315        DeclarationNode * newnode = new DeclarationNode;
     316        newnode->name = name;
    307317        newnode->type = new TypeData( TypeData::Symbolic );
    308318        newnode->type->symbolic.isTypedef = false;
     
    312322} // DeclarationNode::newTypeDecl
    313323
    314 DeclarationNode *DeclarationNode::newPointer( DeclarationNode *qualifiers ) {
    315         DeclarationNode *newnode = new DeclarationNode;
     324DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers ) {
     325        DeclarationNode * newnode = new DeclarationNode;
    316326        newnode->type = new TypeData( TypeData::Pointer );
    317327        return newnode->addQualifiers( qualifiers );
    318328} // DeclarationNode::newPointer
    319329
    320 DeclarationNode *DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) {
    321         DeclarationNode *newnode = new DeclarationNode;
     330DeclarationNode * DeclarationNode::newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic ) {
     331        DeclarationNode * newnode = new DeclarationNode;
    322332        newnode->type = new TypeData( TypeData::Array );
    323333        newnode->type->array.dimension = size;
    324334        newnode->type->array.isStatic = isStatic;
    325         if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) {
     335        if ( newnode->type->array.dimension == nullptr || newnode->type->array.dimension->isExpressionType<ConstantExpr * >() ) {
    326336                newnode->type->array.isVarLen = false;
    327337        } else {
     
    331341} // DeclarationNode::newArray
    332342
    333 DeclarationNode *DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {
    334         DeclarationNode *newnode = new DeclarationNode;
     343DeclarationNode * DeclarationNode::newVarArray( DeclarationNode * qualifiers ) {
     344        DeclarationNode * newnode = new DeclarationNode;
    335345        newnode->type = new TypeData( TypeData::Array );
    336         newnode->type->array.dimension = 0;
     346        newnode->type->array.dimension = nullptr;
    337347        newnode->type->array.isStatic = false;
    338348        newnode->type->array.isVarLen = true;
     
    340350}
    341351
    342 DeclarationNode *DeclarationNode::newBitfield( ExpressionNode *size ) {
    343         DeclarationNode *newnode = new DeclarationNode;
     352DeclarationNode * DeclarationNode::newBitfield( ExpressionNode * size ) {
     353        DeclarationNode * newnode = new DeclarationNode;
    344354        newnode->bitfieldWidth = size;
    345355        return newnode;
    346356}
    347357
    348 DeclarationNode *DeclarationNode::newTuple( DeclarationNode *members ) {
    349         DeclarationNode *newnode = new DeclarationNode;
     358DeclarationNode * DeclarationNode::newTuple( DeclarationNode * members ) {
     359        DeclarationNode * newnode = new DeclarationNode;
    350360        newnode->type = new TypeData( TypeData::Tuple );
    351361        newnode->type->tuple = members;
     
    353363}
    354364
    355 DeclarationNode *DeclarationNode::newTypeof( ExpressionNode *expr ) {
    356         DeclarationNode *newnode = new DeclarationNode;
     365DeclarationNode * DeclarationNode::newTypeof( ExpressionNode * expr ) {
     366        DeclarationNode * newnode = new DeclarationNode;
    357367        newnode->type = new TypeData( TypeData::Typeof );
    358368        newnode->type->typeexpr = expr;
     
    361371
    362372DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {
    363         DeclarationNode *newnode = new DeclarationNode;
     373        DeclarationNode * newnode = new DeclarationNode;
    364374        newnode->type = new TypeData( TypeData::Builtin );
    365375        newnode->builtin = bt;
     
    367377} // DeclarationNode::newBuiltinType
    368378
    369 DeclarationNode *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 );
     379DeclarationNode * 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;
    373384        newnode->attr.expr = expr;
    374385        return newnode;
    375386}
    376387
    377 DeclarationNode *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 );
     388DeclarationNode * 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;
    381393        newnode->attr.type = type;
    382394        return newnode;
     
    389401} // appendError
    390402
    391 void DeclarationNode::checkQualifiers( const TypeData *src, const TypeData *dst ) {
     403void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) {
    392404        TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization
    393405
     
    401413} // DeclarationNode::checkQualifiers
    402414
    403 void DeclarationNode::checkStorageClasses( DeclarationNode *q ) {
     415void DeclarationNode::checkStorageClasses( DeclarationNode * q ) {
    404416        if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) {
    405417                if ( storageClass == q->storageClass ) {                // duplicate qualifier
     
    413425} // DeclarationNode::copyStorageClasses
    414426
    415 DeclarationNode *DeclarationNode::copyStorageClasses( DeclarationNode *q ) {
     427DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) {
    416428        isInline = isInline || q->isInline;
    417429        isNoreturn = isNoreturn || q->isNoreturn;
     
    424436} // DeclarationNode::copyStorageClasses
    425437
    426 static void addQualifiersToType( TypeData *&src, TypeData *dst ) {
     438static void addQualifiersToType( TypeData *&src, TypeData * dst ) {
    427439        if ( src->forall && dst->kind == TypeData::Function ) {
    428440                if ( dst->forall ) {
     
    431443                        dst->forall = src->forall;
    432444                } // if
    433                 src->forall = 0;
     445                src->forall = nullptr;
    434446        } // if
    435447        if ( dst->base ) {
     
    437449        } else if ( dst->kind == TypeData::Function ) {
    438450                dst->base = src;
    439                 src = 0;
     451                src = nullptr;
    440452        } else {
    441453                dst->qualifiers |= src->qualifiers;
     
    443455} // addQualifiersToType
    444456
    445 DeclarationNode *DeclarationNode::addQualifiers( DeclarationNode *q ) {
    446         if ( ! q ) return this;
     457DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) {
     458        if ( ! q ) { delete q; return this; }
    447459
    448460        checkStorageClasses( q );
    449461        copyStorageClasses( q );
    450462
    451         if ( ! q->type ) { delete q; return this; }
     463        if ( ! q->type ) {
     464                delete q;
     465                return this;
     466        } // if
    452467
    453468        if ( ! type ) {
    454 //              type = new TypeData;
    455                 type = q->type;
     469                type = q->type;                                                                 // reuse this structure
     470                q->type = nullptr;
     471                delete q;
    456472                return this;
    457473        } // if
     
    467483                                type->aggregate.params = q->type->forall;
    468484                                // change implicit typedef from TYPEDEFname to TYPEGENname
    469                                 typedefTable.changeKind( type->aggregate.name, TypedefTable::TG );
     485                                typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG );
    470486                        } else {
    471487                                type->forall = q->type->forall;
    472488                        } // if
    473489                } // if
    474                 q->type->forall = 0;
     490                q->type->forall = nullptr;
    475491        } // if
    476492        delete q;
     
    485501                        dst->forall = src->forall;
    486502                } // if
    487                 src->forall = 0;
     503                src->forall = nullptr;
    488504        } // if
    489505        if ( dst->base ) {
     
    494510                        src->qualifiers |= dst->qualifiers;
    495511                        dst = src;
    496                         src = 0;
     512                        src = nullptr;
    497513                        break;
    498514                  case TypeData::Basic:
     
    534550                                } // if
    535551                                dst->base->qualifiers |= src->qualifiers;
    536                                 src = 0;
     552                                src = nullptr;
    537553                                break;
    538554                          default:
     
    542558                                        dst->forall = src->forall;
    543559                                } // if
    544                                 src->forall = 0;
     560                                src->forall = nullptr;
    545561                                dst->base = src;
    546                                 src = 0;
     562                                src = nullptr;
    547563                        } // switch
    548564                } // switch
     
    550566}
    551567
    552 DeclarationNode *DeclarationNode::addType( DeclarationNode *o ) {
     568DeclarationNode * DeclarationNode::addType( DeclarationNode * o ) {
    553569        if ( o ) {
    554570                checkStorageClasses( o );
     
    566582                                        type = o->type;
    567583                                } // if
    568                                 o->type = 0;
     584                                o->type = nullptr;
    569585                        } else {
    570586                                addTypeToType( o->type, type );
     
    584600}
    585601
    586 DeclarationNode *DeclarationNode::addTypedef() {
    587         TypeData *newtype = new TypeData( TypeData::Symbolic );
    588         newtype->symbolic.params = 0;
     602DeclarationNode * DeclarationNode::addTypedef() {
     603        TypeData * newtype = new TypeData( TypeData::Symbolic );
     604        newtype->symbolic.params = nullptr;
    589605        newtype->symbolic.isTypedef = true;
    590         newtype->symbolic.name = name;
     606        newtype->symbolic.name = name ? new string( *name ) : nullptr;
    591607        newtype->base = type;
    592608        type = newtype;
     
    594610}
    595611
    596 DeclarationNode *DeclarationNode::addAssertions( DeclarationNode *assertions ) {
     612DeclarationNode * 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
    597622        assert( type );
    598623        switch ( type->kind ) {
     
    604629                } // if
    605630                break;
    606           case TypeData::Variable:
    607                 if ( variable.assertions ) {
    608                         variable.assertions->appendList( assertions );
    609                 } else {
    610                         variable.assertions = assertions;
    611                 } // if
    612                 break;
     631          // case TypeData::Variable:
     632          //    if ( variable.assertions ) {
     633          //            variable.assertions->appendList( assertions );
     634          //    } else {
     635          //            variable.assertions = assertions;
     636          //    } // if
     637          //    break;
    613638          default:
    614639                assert( false );
     
    618643}
    619644
    620 DeclarationNode *DeclarationNode::addName( std::string *newname ) {
    621         name = assign_strptr( newname );
    622         return this;
    623 }
    624 
    625 DeclarationNode *DeclarationNode::addBitfield( ExpressionNode *size ) {
     645DeclarationNode * DeclarationNode::addName( std::string * newname ) {
     646        assert( ! name );
     647        name = newname;
     648        return this;
     649}
     650
     651DeclarationNode * DeclarationNode::addBitfield( ExpressionNode * size ) {
    626652        bitfieldWidth = size;
    627653        return this;
    628654}
    629655
    630 DeclarationNode *DeclarationNode::addVarArgs() {
     656DeclarationNode * DeclarationNode::addVarArgs() {
    631657        assert( type );
    632658        hasEllipsis = true;
     
    634660}
    635661
    636 DeclarationNode *DeclarationNode::addFunctionBody( StatementNode *body ) {
     662DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) {
    637663        assert( type );
    638664        assert( type->kind == TypeData::Function );
    639         assert( type->function.body == 0 );
     665        assert( ! type->function.body );
    640666        type->function.body = body;
    641667        type->function.hasBody = true;
     
    643669}
    644670
    645 DeclarationNode *DeclarationNode::addOldDeclList( DeclarationNode *list ) {
     671DeclarationNode * DeclarationNode::addOldDeclList( DeclarationNode * list ) {
    646672        assert( type );
    647673        assert( type->kind == TypeData::Function );
    648         assert( type->function.oldDeclList == 0 );
     674        assert( ! type->function.oldDeclList );
    649675        type->function.oldDeclList = list;
    650676        return this;
    651677}
    652678
    653 static void setBase( TypeData *&type, TypeData *newType ) {
     679static void setBase( TypeData *&type, TypeData * newType ) {
    654680        if ( type ) {
    655                 TypeData *prevBase = type;
    656                 TypeData *curBase = type->base;
    657                 while ( curBase != 0 ) {
     681                TypeData * prevBase = type;
     682                TypeData * curBase = type->base;
     683                while ( curBase != nullptr ) {
    658684                        prevBase = curBase;
    659685                        curBase = curBase->base;
     
    665691}
    666692
    667 DeclarationNode *DeclarationNode::addPointer( DeclarationNode *p ) {
     693DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) {
    668694        if ( p ) {
    669695                assert( p->type->kind == TypeData::Pointer );
    670696                setBase( type, p->type );
    671                 p->type = 0;
     697                p->type = nullptr;
    672698                delete p;
    673699        } // if
     
    675701}
    676702
    677 DeclarationNode *DeclarationNode::addArray( DeclarationNode *a ) {
     703DeclarationNode * DeclarationNode::addArray( DeclarationNode * a ) {
    678704        if ( a ) {
    679705                assert( a->type->kind == TypeData::Array );
    680706                setBase( type, a->type );
    681                 a->type = 0;
     707                a->type = nullptr;
    682708                delete a;
    683709        } // if
     
    685711}
    686712
    687 DeclarationNode *DeclarationNode::addNewPointer( DeclarationNode *p ) {
     713DeclarationNode * DeclarationNode::addNewPointer( DeclarationNode * p ) {
    688714        if ( p ) {
    689715                assert( p->type->kind == TypeData::Pointer );
     
    703729                                p->type->base = type;
    704730                        } // switch
    705                         type = 0;
     731                        type = nullptr;
    706732                } // if
    707733                delete this;
     
    712738}
    713739
    714 static TypeData *findLast( TypeData *a ) {
     740static TypeData * findLast( TypeData * a ) {
    715741        assert( a );
    716         TypeData *cur = a;
     742        TypeData * cur = a;
    717743        while ( cur->base ) {
    718744                cur = cur->base;
     
    721747}
    722748
    723 DeclarationNode *DeclarationNode::addNewArray( DeclarationNode *a ) {
     749DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) {
    724750        if ( a ) {
    725751                assert( a->type->kind == TypeData::Array );
    726                 TypeData *lastArray = findLast( a->type );
     752                TypeData * lastArray = findLast( a->type );
    727753                if ( type ) {
    728754                        switch ( type->kind ) {
     
    739765                                lastArray->base = type;
    740766                        } // switch
    741                         type = 0;
     767                        type = nullptr;
    742768                } // if
    743769                delete this;
     
    748774}
    749775
    750 DeclarationNode *DeclarationNode::addParamList( DeclarationNode *params ) {
    751         TypeData *ftype = new TypeData( TypeData::Function );
     776DeclarationNode * DeclarationNode::addParamList( DeclarationNode * params ) {
     777        TypeData * ftype = new TypeData( TypeData::Function );
    752778        ftype->function.params = params;
    753779        setBase( type, ftype );
     
    755781}
    756782
    757 static TypeData *addIdListToType( TypeData *type, DeclarationNode *ids ) {
     783static TypeData * addIdListToType( TypeData * type, DeclarationNode * ids ) {
    758784        if ( type ) {
    759785                if ( type->kind != TypeData::Function ) {
     
    764790                return type;
    765791        } else {
    766                 TypeData *newtype = new TypeData( TypeData::Function );
     792                TypeData * newtype = new TypeData( TypeData::Function );
    767793                newtype->function.idList = ids;
    768794                return newtype;
    769795        } // if
    770 }
    771 
    772 DeclarationNode *DeclarationNode::addIdList( DeclarationNode *ids ) {
     796} // addIdListToType
     797
     798DeclarationNode * DeclarationNode::addIdList( DeclarationNode * ids ) {
    773799        type = addIdListToType( type, ids );
    774800        return this;
    775801}
    776802
    777 DeclarationNode *DeclarationNode::addInitializer( InitializerNode *init ) {
    778         //assert
     803DeclarationNode * DeclarationNode::addInitializer( InitializerNode * init ) {
    779804        initializer = init;
    780805        return this;
    781806}
    782807
    783 DeclarationNode *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 
    808 DeclarationNode *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 
    840 DeclarationNode *DeclarationNode::cloneType( string *newName ) {
    841         DeclarationNode *newnode = new DeclarationNode;
     808DeclarationNode * DeclarationNode::cloneType( string * newName ) {
     809        DeclarationNode * newnode = new DeclarationNode;
    842810        newnode->type = maybeClone( type );
    843811        assert( storageClass == NoStorageClass );
    844812        newnode->copyStorageClasses( this );
    845         newnode->name = assign_strptr( newName );
    846         return newnode;
    847 }
    848 
    849 DeclarationNode *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;
     813        assert( newName );
     814        newnode->name = newName;
     815        return newnode;
     816}
     817
     818DeclarationNode * DeclarationNode::cloneBaseType( DeclarationNode * o ) {
     819        if ( ! o ) return nullptr;
     820
     821        o->copyStorageClasses( this );
     822        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;
    857835                        } else {
    858                                 addTypeToType( newType, o->type );
    859                                 delete newType;
     836                                assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
     837                                delete newType->aggInst.aggregate->aggregate.fields;
     838                                newType->aggInst.aggregate->aggregate.fields = nullptr;
    860839                        } // if
    861840                } // if
    862         } // if
    863         delete o;
     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
    864850        return o;
    865851}
    866852
    867 DeclarationNode *DeclarationNode::extractAggregate() const {
     853DeclarationNode * DeclarationNode::extractAggregate() const {
    868854        if ( type ) {
    869                 TypeData *ret = typeextractAggregate( type );
     855                TypeData * ret = typeextractAggregate( type );
    870856                if ( ret ) {
    871                         DeclarationNode *newnode = new DeclarationNode;
     857                        DeclarationNode * newnode = new DeclarationNode;
    872858                        newnode->type = ret;
    873859                        return newnode;
    874860                } // if
    875861        } // if
    876         return 0;
    877 }
    878 
    879 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList ) {
     862        return nullptr;
     863}
     864
     865void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) {
    880866        SemanticError errors;
    881867        std::back_insert_iterator< std::list< Declaration * > > out( outputList );
    882         const DeclarationNode *cur = firstNode;
     868        const DeclarationNode * cur = firstNode;
     869
    883870        while ( cur ) {
    884871                try {
    885                         if ( DeclarationNode *extr = cur->extractAggregate() ) {
     872                        if ( DeclarationNode * extr = cur->extractAggregate() ) {
    886873                                // handle the case where a structure declaration is contained within an object or type declaration
    887                                 Declaration *decl = extr->build();
     874                                Declaration * decl = extr->build();
    888875                                if ( decl ) {
    889                                         *out++ = decl;
     876                                        * out++ = decl;
    890877                                } // if
    891878                                delete extr;
    892879                        } // if
    893                         Declaration *decl = cur->build();
     880
     881                        Declaration * decl = cur->build();
    894882                        if ( decl ) {
    895                                 *out++ = decl;
     883                                * out++ = decl;
    896884                        } // if
    897885                } catch( SemanticError &e ) {
     
    900888                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    901889        } // while
     890
    902891        if ( ! errors.isEmpty() ) {
    903892                throw errors;
    904893        } // if
    905 }
    906 
    907 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType * > &outputList ) {
     894} // buildList
     895
     896void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) {
    908897        SemanticError errors;
    909898        std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList );
    910         const DeclarationNode *cur = firstNode;
     899        const DeclarationNode * cur = firstNode;
    911900        while ( cur ) {
    912901                try {
    913                         Declaration *decl = cur->build();
     902                        Declaration * decl = cur->build();
    914903                        if ( decl ) {
    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 );
     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 );
    920909                                        delete agg;
    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 );
     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 );
    924913                                } // if
    925914                        } // if
     
    932921                throw errors;
    933922        } // if
    934 }
    935 
    936 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList ) {
     923} // buildList
     924
     925void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) {
    937926        SemanticError errors;
    938927        std::back_insert_iterator< std::list< Type * > > out( outputList );
    939         const DeclarationNode *cur = firstNode;
     928        const DeclarationNode * cur = firstNode;
     929
    940930        while ( cur ) {
    941931                try {
    942                         *out++ = cur->buildType();
     932                        * out++ = cur->buildType();
    943933                } catch( SemanticError &e ) {
    944934                        errors.append( e );
     
    946936                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    947937        } // while
     938
    948939        if ( ! errors.isEmpty() ) {
    949940                throw errors;
    950941        } // if
    951 }
    952 
    953 Declaration *DeclarationNode::build() const {
     942} // buildTypeList
     943
     944Declaration * DeclarationNode::build() const {
    954945        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
    955954        if ( type ) {
    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;
     955                return buildDecl( type, name ? *name : string( "" ), storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
     956        } // if
     957
     958        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
     963        throw SemanticError( "invalid function specifier ", this );
     964}
     965
     966Type * DeclarationNode::buildType() const {
     967        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() );
    961973                } else {
    962                         return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
    963                 } // if
    964         } // if
    965         if ( ! isInline && ! isNoreturn ) {
    966                 return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension );
    967         } // if
    968         throw SemanticError( "invalid function specifier ", this );
    969 }
    970 
    971 Type *DeclarationNode::buildType() const {
    972         assert( type );
     974                        assert( attr.type );
     975                        ret = new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() );
     976                } // if
     977                return ret;
     978        } // if
    973979
    974980        switch ( type->kind ) {
    975981          case TypeData::Enum:
    976                 return new EnumInstType( buildQualifiers( type ), type->enumeration.name );
     982                return new EnumInstType( buildQualifiers( type ), *type->enumeration.name );
    977983          case TypeData::Aggregate: {
    978                   ReferenceToType *ret;
     984                  ReferenceToType * ret;
    979985                  switch ( type->aggregate.kind ) {
    980986                        case DeclarationNode::Struct:
    981                           ret = new StructInstType( buildQualifiers( type ), type->aggregate.name );
     987                          ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    982988                          break;
    983989                        case DeclarationNode::Union:
    984                           ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name );
     990                          ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    985991                          break;
    986992                        case DeclarationNode::Trait:
    987                           ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name );
     993                          ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name );
    988994                          break;
    989995                        default:
     
    9941000          }
    9951001          case TypeData::Symbolic: {
    996                   TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic.name, false );
     1002                  TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false );
    9971003                  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
    10101004                  return ret;
    10111005          }
  • src/Parser/ExpressionNode.cc

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

    r7ae930a r9c23f31  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 08:00:05 2016
    13 // Update Count     : 603
     12// Last Modified On : Sat Sep 24 11:12:04 2016
     13// Update Count     : 633
    1414//
    1515
     
    4141  public:
    4242        ParseNode() {};
    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; };
     43        virtual ~ParseNode() { delete next; delete name; };
    4644        virtual ParseNode * clone() const = 0;
    4745
    4846        ParseNode * get_next() const { return next; }
    4947        ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; }
     48
    5049        ParseNode * get_last() {
    5150                ParseNode * current;
    52                 for ( current = this; current->get_next() != 0; current = current->get_next() );
     51                for ( current = this; current->get_next() != nullptr; current = current->get_next() );
    5352                return current;
    5453        }
    5554        ParseNode * set_last( ParseNode * newlast ) {
    56                 if ( newlast != 0 ) get_last()->set_next( newlast );
     55                if ( newlast != nullptr ) get_last()->set_next( newlast );
    5756                return this;
    5857        }
    59 
    60         const std::string &get_name() const { return name; }
    61         void set_name( const std::string &newValue ) { name = newValue; }
    6258
    6359        virtual void print( std::ostream &os, int indent = 0 ) const {}
    6460        virtual void printList( std::ostream &os, int indent = 0 ) const {}
    65   private:
     61
    6662        static int indent_by;
    6763
    6864        ParseNode * next = nullptr;
    69         std::string name;
     65        std::string * name = nullptr;
    7066}; // ParseNode
    7167
     
    7470class InitializerNode : public ParseNode {
    7571  public:
    76         InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = 0 );
    77         InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = 0 );
     72        InitializerNode( ExpressionNode *, bool aggrp = false,  ExpressionNode * des = nullptr );
     73        InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
    7874        ~InitializerNode();
    7975        virtual InitializerNode * clone() const { assert( false ); return nullptr; }
     
    106102  public:
    107103        ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {}
    108         ExpressionNode( Expression * expr, const std::string * name ) : ParseNode( name ), expr( expr ) {}
    109104        ExpressionNode( const ExpressionNode &other );
    110105        virtual ~ExpressionNode() {}
     
    183178Expression * build_attrexpr( NameExpr * var, ExpressionNode * expr_node );
    184179Expression * build_attrtype( NameExpr * var, DeclarationNode * decl_node );
    185 Expression * build_tuple( ExpressionNode * expr_node = 0 );
     180Expression * build_tuple( ExpressionNode * expr_node = nullptr );
    186181Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node );
    187182Expression * build_range( ExpressionNode * low, ExpressionNode * high );
     
    219214        static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
    220215        static DeclarationNode * newQualifier( Qualifier );
    221         static DeclarationNode * newForall( DeclarationNode *);
     216        static DeclarationNode * newForall( DeclarationNode * );
    222217        static DeclarationNode * newStorageClass( StorageClass );
    223218        static DeclarationNode * newBasicType( BasicType );
     
    226221        static DeclarationNode * newLength( Length lnth );
    227222        static DeclarationNode * newBuiltinType( BuiltinType );
    228         static DeclarationNode * newFromTypedef( std::string *);
     223        static DeclarationNode * newFromTypedef( std::string * );
    229224        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    230225        static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants );
    231226        static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant );
    232         static DeclarationNode * newName( std::string *);
     227        static DeclarationNode * newName( std::string * );
    233228        static DeclarationNode * newFromTypeGen( std::string *, 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 );
     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 );
    237232        static DeclarationNode * newTypeDecl( std::string * name, DeclarationNode * typeParams );
    238233        static DeclarationNode * newPointer( DeclarationNode * qualifiers );
     
    249244        DeclarationNode * clone() const;
    250245
    251         DeclarationNode * addQualifiers( DeclarationNode *);
     246        DeclarationNode * addQualifiers( DeclarationNode * );
    252247        void checkQualifiers( const TypeData *, const TypeData * );
    253         void checkStorageClasses( DeclarationNode *q );
    254         DeclarationNode * copyStorageClasses( DeclarationNode *);
    255         DeclarationNode * addType( DeclarationNode *);
     248        void checkStorageClasses( DeclarationNode * );
     249        DeclarationNode * copyStorageClasses( DeclarationNode * );
     250        DeclarationNode * addType( DeclarationNode * );
    256251        DeclarationNode * addTypedef();
    257         DeclarationNode * addAssertions( DeclarationNode *);
    258         DeclarationNode * addName( std::string *);
     252        DeclarationNode * addAssertions( DeclarationNode * );
     253        DeclarationNode * addName( std::string * );
    259254        DeclarationNode * addBitfield( ExpressionNode * size );
    260255        DeclarationNode * addVarArgs();
     
    270265
    271266        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 );
    275267        DeclarationNode * cloneBaseType( DeclarationNode * newdecl );
    276268
     
    286278
    287279        bool get_hasEllipsis() const;
    288         const std::string &get_name() const { return name; }
    289280        LinkageSpec::Spec get_linkage() const { return linkage; }
    290281        DeclarationNode * extractAggregate() const;
     
    295286        DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
    296287  public:
    297         // StorageClass buildStorageClass() const;
    298         // bool buildFuncSpecifier( StorageClass key ) const;
    299 
    300288        struct Variable_t {
     289                const std::string * name;
    301290                DeclarationNode::TypeClass tyClass;
    302                 std::string name;
    303291                DeclarationNode * assertions;
    304292        };
     
    306294
    307295        struct Attr_t {
    308                 std::string name;
     296                const std::string * name;
    309297                ExpressionNode * expr;
    310298                DeclarationNode * type;
     
    315303
    316304        TypeData * type;
    317         std::string name;
    318305        StorageClass storageClass;
    319306        bool isInline, isNoreturn;
     
    331318
    332319Type * buildType( TypeData * type );
    333 //Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );
    334320
    335321static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) {
     
    393379Statement * build_finally( StatementNode * stmt );
    394380Statement * build_compound( StatementNode * first );
    395 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = 0, ExpressionNode * input = 0, ExpressionNode * clobber = 0, LabelNode * gotolabels = 0 );
     381Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
    396382
    397383//##############################################################################
  • src/Parser/TypeData.cc

    r7ae930a r9c23f31  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 21:11:22 2016
    13 // Update Count     : 377
     12// Last Modified On : Sat Sep 24 11:14:26 2016
     13// Update Count     : 415
    1414//
    1515
     
    2424#include "SynTree/Statement.h"
    2525#include "SynTree/Initializer.h"
    26 
    27 TypeData::TypeData( Kind k ) : kind( k ), base( 0 ), forall( 0 ) {
     26using namespace std;
     27
     28TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {
    2829        switch ( kind ) {
    2930          case Unknown:
     
    3738          case Array:
    3839                // array = new Array_t;
    39                 array.dimension = 0;
     40                array.dimension = nullptr;
    4041                array.isVarLen = false;
    4142                array.isStatic = false;
     
    4344          case Function:
    4445                // function = new Function_t;
    45                 function.params = 0;
    46                 function.idList = 0;
    47                 function.oldDeclList = 0;
    48                 function.body = 0;
     46                function.params = nullptr;
     47                function.idList = nullptr;
     48                function.oldDeclList = nullptr;
     49                function.body = nullptr;
    4950                function.hasBody = false;
    5051                function.newStyle = false;
     
    5253          case Aggregate:
    5354                // aggregate = new Aggregate_t;
    54                 aggregate.params = 0;
    55                 aggregate.actuals = 0;
    56                 aggregate.fields = 0;
     55                aggregate.name = nullptr;
     56                aggregate.params = nullptr;
     57                aggregate.actuals = nullptr;
     58                aggregate.fields = nullptr;
    5759                break;
    5860          case AggregateInst:
    5961                // aggInst = new AggInst_t;
    60                 aggInst.aggregate = 0;
    61                 aggInst.params = 0;
     62                aggInst.aggregate = nullptr;
     63                aggInst.params = nullptr;
    6264                break;
    6365          case Enum:
    6466                // enumeration = new Enumeration_t;
    65                 enumeration.constants = 0;
     67                enumeration.name = nullptr;
     68                enumeration.constants = nullptr;
    6669                break;
    6770          case Symbolic:
    6871          case SymbolicInst:
    6972                // symbolic = new Symbolic_t;
    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;
     73                symbolic.name = nullptr;
     74                symbolic.params = nullptr;
     75                symbolic.actuals = nullptr;
     76                symbolic.assertions = nullptr;
    7877                break;
    7978          case Tuple:
     
    8483                // typeexpr = new Typeof_t;
    8584                typeexpr = nullptr;
    86                 break;
    87           case Attr:
    88                 // attr = new Attr_t;
    89                 // attr.expr = nullptr;
    90                 // attr.type = nullptr;
    9185                break;
    9286          case Builtin:
     
    121115                break;
    122116          case Aggregate:
     117                delete aggregate.name;
    123118                delete aggregate.params;
    124119                delete aggregate.actuals;
     
    132127                break;
    133128          case Enum:
     129                delete enumeration.name;
    134130                delete enumeration.constants;
    135131                // delete enumeration;
     
    137133          case Symbolic:
    138134          case SymbolicInst:
     135                delete symbolic.name;
    139136                delete symbolic.params;
    140137                delete symbolic.actuals;
     
    142139                // delete symbolic;
    143140                break;
    144           case Variable:
    145                 // delete variable.assertions;
    146                 // delete variable;
    147                 break;
    148141          case Tuple:
    149142                // delete tuple->members;
     
    153146                // delete typeexpr->expr;
    154147                delete typeexpr;
    155                 break;
    156           case Attr:
    157                 // delete attr.expr;
    158                 // delete attr.type;
    159                 // delete attr;
    160148                break;
    161149          case Builtin:
     
    197185                break;
    198186          case Aggregate:
     187                newtype->aggregate.name = aggregate.name ? new string( *aggregate.name ) : nullptr;
    199188                newtype->aggregate.params = maybeClone( aggregate.params );
    200189                newtype->aggregate.actuals = maybeClone( aggregate.actuals );
    201190                newtype->aggregate.fields = maybeClone( aggregate.fields );
    202                 newtype->aggregate.name = aggregate.name;
    203191                newtype->aggregate.kind = aggregate.kind;
    204192                newtype->aggregate.body = aggregate.body;
     
    209197                break;
    210198          case Enum:
    211                 newtype->enumeration.name = enumeration.name;
     199                newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr;
    212200                newtype->enumeration.constants = maybeClone( enumeration.constants );
    213201                break;
    214202          case Symbolic:
    215203          case SymbolicInst:
     204                newtype->symbolic.name = symbolic.name ? new string( *symbolic.name ) : nullptr;
    216205                newtype->symbolic.params = maybeClone( symbolic.params );
    217206                newtype->symbolic.actuals = maybeClone( symbolic.actuals );
    218207                newtype->symbolic.assertions = maybeClone( symbolic.assertions );
    219208                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;
    227209                break;
    228210          case Tuple:
     
    231213          case Typeof:
    232214                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 );
    238215                break;
    239216          case Builtin:
     
    245222} // TypeData::clone
    246223
    247 void TypeData::print( std::ostream &os, int indent ) const {
    248         using std::endl;
    249         using std::string;
    250 
     224void TypeData::print( ostream &os, int indent ) const {
    251225        for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) {
    252226                if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';
     
    326300                break;
    327301          case Aggregate:
    328                 os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << aggregate.name << endl;
     302                os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << *aggregate.name << endl;
    329303                if ( aggregate.params ) {
    330304                        os << string( indent + 2, ' ' ) << "with type parameters " << endl;
     
    363337                break;
    364338          case SymbolicInst:
    365                 os << "instance of type " << symbolic.name;
     339                os << "instance of type " << *symbolic.name;
    366340                if ( symbolic.actuals ) {
    367341                        os << " with parameters" << endl;
     
    389363                } // if
    390364                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;
    399365          case Tuple:
    400366                os << "tuple ";
     
    410376                } // if
    411377                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;
    421378          case Builtin:
    422379                os << "gcc builtin type";
     
    428385} // TypeData::print
    429386
    430 void buildForall( const DeclarationNode * firstNode, std::list< TypeDecl* > &outputList ) {
     387void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) {
    431388        buildList( firstNode, outputList );
    432         for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     389        for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    433390                if ( (*i)->get_kind() == TypeDecl::Any ) {
    434391                        // add assertion parameters to `type' tyvars in reverse order
    435392                        // add dtor:  void ^?{}(T *)
    436393                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    439396
    440397                        // add copy ctor:  void ?{}(T *, T)
    441398                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    445402
    446403                        // add default ctor:  void ?{}(T *)
    447404                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    450407
    451408                        // add assignment operator:  T * ?=?(T *, T)
    452409                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), 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 ) );
     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 ) );
    457414                } // if
    458415        } // for
     
    486443          case TypeData::Builtin:
    487444                return new VarArgsType( buildQualifiers( td ) );
    488           case TypeData::Attr:
    489                 assert( false );
    490                 return buildAttr( td );
    491445          case TypeData::Symbolic:
    492446          case TypeData::Enum:
    493447          case TypeData::Aggregate:
    494           case TypeData::Variable:
    495448                assert( false );
    496449        } // switch
    497         return 0;
     450        return nullptr;
    498451} // typebuild
    499452
    500453TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) {
    501         TypeData * ret = 0;
     454        TypeData * ret = nullptr;
    502455
    503456        switch ( td->kind ) {
     
    549502          case DeclarationNode::Bool:
    550503                if ( td->signedness != DeclarationNode::NoSignedness ) {
    551                         throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     504                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
    552505                } // if
    553506                if ( td->length != DeclarationNode::NoLength ) {
    554                         throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     507                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    555508                } // if
    556509
     
    565518
    566519                if ( td->length != DeclarationNode::NoLength ) {
    567                         throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     520                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    568521                } // if
    569522
     
    595548          FloatingPoint: ;
    596549                if ( td->signedness != DeclarationNode::NoSignedness ) {
    597                         throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     550                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
    598551                } // if
    599552                if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
    600                         throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     553                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
    601554                } // if
    602555                if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
     
    655608        switch ( td->aggregate.kind ) {
    656609          case DeclarationNode::Struct:
    657                 at = new StructDecl( td->aggregate.name );
     610                at = new StructDecl( *td->aggregate.name );
    658611                buildForall( td->aggregate.params, at->get_parameters() );
    659612                break;
    660613          case DeclarationNode::Union:
    661                 at = new UnionDecl( td->aggregate.name );
     614                at = new UnionDecl( *td->aggregate.name );
    662615                buildForall( td->aggregate.params, at->get_parameters() );
    663616                break;
    664617          case DeclarationNode::Trait:
    665                 at = new TraitDecl( td->aggregate.name );
     618                at = new TraitDecl( *td->aggregate.name );
    666619                buildList( td->aggregate.params, at->get_parameters() );
    667620                break;
     
    681634        ReferenceToType * ret;
    682635        if ( td->aggInst.aggregate->kind == TypeData::Enum ) {
    683                 ret = new EnumInstType( buildQualifiers( td ), td->aggInst.aggregate->enumeration.name );
     636                ret = new EnumInstType( buildQualifiers( td ), *td->aggInst.aggregate->enumeration.name );
    684637        } else {
    685638                assert( td->aggInst.aggregate->kind == TypeData::Aggregate );
    686639                switch ( td->aggInst.aggregate->aggregate.kind ) {
    687640                  case DeclarationNode::Struct:
    688                         ret = new StructInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     641                        assert( td->aggInst.aggregate->aggregate.name );
     642                        ret = new StructInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
    689643                        break;
    690644                  case DeclarationNode::Union:
    691                         ret = new UnionInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     645                        ret = new UnionInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
    692646                        break;
    693647                  case DeclarationNode::Trait:
    694                         ret = new TraitInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     648                        ret = new TraitInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name );
    695649                        break;
    696650                  default:
     
    703657} // buildAggInst
    704658
    705 NamedTypeDecl * buildSymbolic( const TypeData * td, const std::string & name, DeclarationNode::StorageClass sc ) {
     659NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, DeclarationNode::StorageClass sc ) {
    706660        assert( td->kind == TypeData::Symbolic );
    707661        NamedTypeDecl * ret;
     
    717671} // buildSymbolic
    718672
    719 TypeDecl * 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 
    730673EnumDecl * buildEnum( const TypeData * td ) {
    731674        assert( td->kind == TypeData::Enum );
    732         EnumDecl * ret = new EnumDecl( td->enumeration.name );
     675        EnumDecl * ret = new EnumDecl( *td->enumeration.name );
    733676        buildList( td->enumeration.constants, ret->get_members() );
    734         std::list< Declaration * >::iterator members = ret->get_members().begin();
     677        list< Declaration * >::iterator members = ret->get_members().begin();
    735678        for ( const DeclarationNode * cur = td->enumeration. constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    736679                if ( cur->has_enumeratorValue() ) {
    737680                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    738                         member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), std::list< Expression * >() ) );
     681                        member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), list< Expression * >() ) );
    739682                } // if
    740683        } // for
     
    744687TypeInstType * buildSymbolicInst( const TypeData * td ) {
    745688        assert( td->kind == TypeData::SymbolicInst );
    746         TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic.name, false );
     689        TypeInstType * ret = new TypeInstType( buildQualifiers( td ), *td->symbolic.name, false );
    747690        buildList( td->symbolic.actuals, ret->get_parameters() );
    748691        buildForall( td->forall, ret->get_forall() );
     
    765708} // buildTypeof
    766709
    767 AttrType * 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 
    782 Declaration * buildDecl( const TypeData * td, std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) {
     710Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) {
    783711        if ( td->kind == TypeData::Function ) {
    784712                FunctionDecl * decl;
     
    790718                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn );
    791719                        } else {
    792                                 // std::list< Label > ls;
    793                                 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( std::list< Label >() ), isInline, isNoreturn );
     720                                // list< Label > ls;
     721                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( list< Label >() ), isInline, isNoreturn );
    794722                        } // if
    795723                } else {
    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() );
     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 );
    801729                        } // if
    802730                } // for
     
    809737        } else if ( td->kind == TypeData::Symbolic ) {
    810738                return buildSymbolic( td, name, sc );
    811         } else if ( td->kind == TypeData::Variable ) {
    812                 assert( false );
    813                 return buildVariable( td );
    814739        } else {
    815                 return new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, std::list< Attribute * >(), isInline, isNoreturn );
     740                return new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, list< Attribute * >(), isInline, isNoreturn );
    816741        } // if
    817         return 0;
     742        return nullptr;
    818743} // buildDecl
    819744
     
    831756                        break;
    832757                  default:
    833                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base,  "", DeclarationNode::NoStorageClass, 0, false, false, LinkageSpec::Cforall ) ) );
     758                        ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base,  "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall ) ) );
    834759                } // switch
    835760        } else {
    836                 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ) );
     761                ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
    837762        } // if
    838763        return ft;
  • src/Parser/TypeData.h

    r7ae930a r9c23f31  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 17:15:49 2016
    13 // Update Count     : 129
     12// Last Modified On : Sat Sep 24 11:10:38 2016
     13// Update Count     : 141
    1414//
    1515
     
    2424struct TypeData {
    2525        enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
    26                                 Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr };
     26                                Enum, EnumConstant, Symbolic, SymbolicInst, Tuple, Typeof, Builtin };
    2727
    2828        struct Aggregate_t {
    2929                DeclarationNode::Aggregate kind;
    30                 std::string name;
     30                const 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                 std::string name;
     49                const std::string * name;
    5050                DeclarationNode * constants;
    5151        };
     
    6161
    6262        struct Symbolic_t {
    63                 std::string name;
     63                const std::string * name;
    6464                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
    6565                DeclarationNode * params;
     
    8888                DeclarationNode * tuple;
    8989                ExpressionNode * typeexpr;
    90                 // Attr_t attr;
    9190                // DeclarationNode::BuiltinType builtin;
    9291
     
    111110TupleType * buildTuple( const TypeData * );
    112111TypeofType * buildTypeof( const TypeData * );
    113 AttrType * buildAttr( const TypeData * );
    114 Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 );
     112Declaration * buildDecl( const TypeData *, const std::string &, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = nullptr );
    115113FunctionType * buildFunction( const TypeData * );
    116114
  • src/Parser/parser.h

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

    r7ae930a r9c23f31  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 17:29:45 2016
    13 // Update Count     : 1969
     12// Last Modified On : Sat Sep 24 12:16:53 2016
     13// Update Count     : 1992
    1414//
    1515
     
    5454#include "TypeData.h"
    5555#include "LinkageSpec.h"
     56using namespace std;
    5657
    5758extern DeclarationNode * parseTree;
     
    5960extern TypedefTable typedefTable;
    6061
    61 std::stack< LinkageSpec::Spec > linkageStack;
    62 
    63 void appendStr( std::string *to, std::string *from ) {
     62stack< LinkageSpec::Spec > linkageStack;
     63
     64void appendStr( string *to, string *from ) {
    6465        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    6566        to->insert( to->length() - 1, from->substr( 1, from->length() - 2 ) );
     
    359360                { $$ = $2; }
    360361        | '(' compound_statement ')'                                            // GCC, lambda expression
    361         { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     362                { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    362363        ;
    363364
     
    389390                {
    390391                        Token fn;
    391                         fn.str = new std::string( "?{}" ); // location undefined - use location of '{'?
     392                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    392393                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    393394                }
     
    666667                {
    667668                        Token fn;
    668                         fn.str = new std::string( "^?{}" ); // location undefined
     669                        fn.str = new string( "^?{}" );                          // location undefined
    669670                        $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );
    670671                }
     
    896897                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    897898        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    898         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     899                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    899900        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    900901                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     
    968969                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    969970        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    970         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     971                { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    971972        ;
    972973
     
    14671468aggregate_name:
    14681469        aggregate_key '{' field_declaration_list '}'
    1469                 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }
     1470                { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $3, true ); }
    14701471        | aggregate_key no_attr_identifier_or_type_name
    14711472                {
    14721473                        typedefTable.makeTypedef( *$2 );
    1473                         $$ = DeclarationNode::newAggregate( $1, $2, 0, 0, false );
     1474                        $$ = DeclarationNode::newAggregate( $1, $2, nullptr, nullptr, false );
    14741475                }
    14751476        | aggregate_key no_attr_identifier_or_type_name
    14761477                { typedefTable.makeTypedef( *$2 ); }
    14771478                '{' field_declaration_list '}'
    1478                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }
     1479                { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }
    14791480        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1480                 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); }
     1481                { $$ = DeclarationNode::newAggregate( $1, nullptr, $3, $6, false ); }
    14811482        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14821483                { $$ = $2; }
     
    15591560enum_name:
    15601561        enum_key '{' enumerator_list comma_opt '}'
    1561                 { $$ = DeclarationNode::newEnum( 0, $3 ); }
     1562                { $$ = DeclarationNode::newEnum( nullptr, $3 ); }
    15621563        | enum_key no_attr_identifier_or_type_name
    15631564                {
     
    25202521abstract_function:
    25212522        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2522                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2523                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    25232524        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25242525                { $$ = $2->addParamList( $6 ); }
     
    25892590abstract_parameter_function:
    25902591        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2591                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2592                { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); }
    25922593        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25932594                { $$ = $2->addParamList( $6 ); }
     
    27932794                // empty (void) function return type.
    27942795        '[' ']' type_specifier
    2795                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2796                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    27962797        | '[' ']' multi_array_dimension type_specifier
    2797                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2798                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    27982799        | multi_array_dimension type_specifier
    27992800                { $$ = $2->addNewArray( $1 ); }
    28002801        | '[' ']' new_abstract_ptr
    2801                 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2802                { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    28022803        | '[' ']' multi_array_dimension new_abstract_ptr
    2803                 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
     2804                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }
    28042805        | multi_array_dimension new_abstract_ptr
    28052806                { $$ = $2->addNewArray( $1 ); }
     
    28132814new_abstract_function:                                                                  // CFA
    28142815        '[' ']' '(' new_parameter_type_list_opt ')'
    2815                 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
     2816                { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    28162817        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    2817                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2818                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28182819        | new_function_return '(' push new_parameter_type_list_opt pop ')'
    2819                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2820                { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); }
    28202821        ;
    28212822
     
    28522853
    28532854void yyerror( const char * ) {
    2854         std::cout << "Error ";
     2855        cout << "Error ";
    28552856        if ( yyfilename ) {
    2856                 std::cout << "in file " << yyfilename << " ";
     2857                cout << "in file " << yyfilename << " ";
    28572858        } // if
    2858         std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
     2859        cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << endl;
    28592860}
    28602861
Note: See TracChangeset for help on using the changeset viewer.