From 1dd4f6d1c834fbdec9464d0618f5f8a9bce38a20 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Tue, 12 Feb 2013 20:27:31 -0500 Subject: removed RegionGraphDictEl, can just use RegionDef directly --- colm/compiler.cc | 17 +++++++---------- colm/lmparse.kl | 8 ++------ colm/parsedata.h | 2 +- colm/parsetree.h | 32 +++++++------------------------- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/colm/compiler.cc b/colm/compiler.cc index 4bf9d7c1..2d94a9f3 100644 --- a/colm/compiler.cc +++ b/colm/compiler.cc @@ -847,9 +847,9 @@ NameInst *Compiler::makeNameTree() /* First make the name tree. */ initNameWalk( rootName ); - for ( RegionGraphList::Iter glel = instanceList; glel.lte(); glel++ ) { + for ( RegionDefList::Iter rdel = regionDefList; rdel.lte(); rdel++ ) { /* Recurse on the instance. */ - glel->value->makeNameTree( glel->loc, this ); + rdel->makeNameTree( rdel->loc, this ); } return rootName; @@ -865,13 +865,13 @@ FsmGraph *Compiler::makeAllRegions() referenceRegions( rootName ); int numGraphs = 0; - FsmGraph **graphs = new FsmGraph*[instanceList.length()]; + FsmGraph **graphs = new FsmGraph*[regionDefList.length()]; /* Make all the instantiations, we know that main exists in this list. */ initNameWalk( rootName ); - for ( RegionGraphList::Iter glel = instanceList; glel.lte(); glel++ ) { + for ( RegionDefList::Iter rdel = regionDefList; rdel.lte(); rdel++ ) { /* Build the graph from a walk of the parse tree. */ - FsmGraph *newGraph = glel->value->walk( this ); + FsmGraph *newGraph = rdel->walk( this ); /* Wrap up the construction. */ finishGraphBuild( newGraph ); @@ -1004,11 +1004,8 @@ void Compiler::createDefaultScanner() regionList.append( defaultRegion ); /* Insert the machine definition into the graph dictionary. */ - RegionGraphDictEl *newEl = new RegionGraphDictEl( name ); - assert( newEl != 0 ); - newEl->value = new RegionDef( name, defaultRegion ); - newEl->isInstance = true; - instanceList.append( newEl ); + RegionDef *rdel = new RegionDef( name, defaultRegion, loc ); + regionDefList.append( rdel ); LexJoin *join = new LexJoin( LexExpression::cons( BT_Any ) ); diff --git a/colm/lmparse.kl b/colm/lmparse.kl index 28976d79..80bba360 100644 --- a/colm/lmparse.kl +++ b/colm/lmparse.kl @@ -2743,15 +2743,11 @@ void ColmParser::popRegionSet() void ColmParser::addRegionDef( const InputLoc &loc, Namespace *nspace, const String &name, TokenRegion *tokenRegion ) { - RegionGraphDictEl *newEl = new RegionGraphDictEl( name ); - /* New element in the dict, all good. */ - newEl->value = new RegionDef( name, tokenRegion ); - newEl->isInstance = true; - newEl->loc = loc; + RegionDef *regionDef = new RegionDef( name, tokenRegion, loc ); /* It it is an instance, put on the instance list. */ - pd->instanceList.append( newEl ); + pd->regionDefList.append( regionDef ); } ostream &ColmParser::parse_error( int tokId, Token &token ) diff --git a/colm/parsedata.h b/colm/parsedata.h index f3a0121a..bef7756f 100644 --- a/colm/parsedata.h +++ b/colm/parsedata.h @@ -602,7 +602,7 @@ struct Compiler */ /* The list of instances. */ - RegionGraphList instanceList; + RegionDefList regionDefList; /* Dictionary of actions. Lets actions be defined and then referenced. */ ActionDict actionDict; diff --git a/colm/parsetree.h b/colm/parsetree.h index 76b35702..36913282 100644 --- a/colm/parsetree.h +++ b/colm/parsetree.h @@ -331,9 +331,11 @@ struct LexDefinition * A Variable Definition */ struct RegionDef +: + public DListEl { - RegionDef( const String &name, TokenRegion *tokenRegion ) - : name(name), tokenRegion(tokenRegion) { } + RegionDef( const String &name, TokenRegion *tokenRegion, const InputLoc &loc ) + : name(name), tokenRegion(tokenRegion), loc(loc) { } /* Parse tree traversal. */ FsmGraph *walk( Compiler *pd ); @@ -341,6 +343,7 @@ struct RegionDef String name; TokenRegion *tokenRegion; + InputLoc loc; }; typedef Vector StringVect; @@ -664,6 +667,7 @@ struct GraphDictEl { GraphDictEl( const String &key ) : key(key), value(0), isInstance(false) { } + GraphDictEl( const String &key, LexDefinition *value ) : key(key), value(value), isInstance(false) { } @@ -680,29 +684,7 @@ struct GraphDictEl typedef AvlTree GraphDict; typedef DList GraphList; -/* Graph dictionary. */ -struct RegionGraphDictEl -: - public AvlTreeEl, - public DListEl -{ - RegionGraphDictEl( const String &key ) - : key(key), value(0), isInstance(false) { } - RegionGraphDictEl( const String &key, RegionDef *value ) - : key(key), value(value), isInstance(false) { } - - const String &getKey() { return key; } - - String key; - RegionDef *value; - bool isInstance; - - /* Location info of graph definition. Points to variable name of assignment. */ - InputLoc loc; -}; - -typedef AvlTree RegionGraphDict; -typedef DList RegionGraphList; +typedef DList RegionDefList; struct TypeAlias { -- cgit v1.2.1