summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-02-12 20:27:31 -0500
committerAdrian Thurston <thurston@complang.org>2013-02-12 20:27:31 -0500
commit1dd4f6d1c834fbdec9464d0618f5f8a9bce38a20 (patch)
tree467e011317a93e0e25d7fe9cd3d0b73979b105d3
parentdb6d1e59466b839f3d0615cffcf5ba688b695263 (diff)
downloadcolm-1dd4f6d1c834fbdec9464d0618f5f8a9bce38a20.tar.gz
removed RegionGraphDictEl, can just use RegionDef directly
-rw-r--r--colm/compiler.cc17
-rw-r--r--colm/lmparse.kl8
-rw-r--r--colm/parsedata.h2
-rw-r--r--colm/parsetree.h32
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>
{
- 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<String> 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<GraphDictEl, String, CmpStr> GraphDict;
typedef DList<GraphDictEl> GraphList;
-/* Graph dictionary. */
-struct RegionGraphDictEl
-:
- public AvlTreeEl<RegionGraphDictEl>,
- public DListEl<RegionGraphDictEl>
-{
- 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<RegionGraphDictEl, String, CmpStr> RegionGraphDict;
-typedef DList<RegionGraphDictEl> RegionGraphList;
+typedef DList<RegionDef> RegionDefList;
struct TypeAlias
{