summaryrefslogtreecommitdiff
path: root/colm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-04-08 20:36:07 -0400
committerAdrian Thurston <thurston@complang.org>2013-04-08 20:36:07 -0400
commitaeec1f74feb2a083ee153403c5837f77adadd967 (patch)
tree74edaabe51cb1560edd282bc5e99fbdadc1adcbc /colm
parentbad9a15e0b56c3b047335832ae0e9e53fa4a41a6 (diff)
downloadcolm-aeec1f74feb2a083ee153403c5837f77adadd967.tar.gz
eliminated the root region
Diffstat (limited to 'colm')
-rw-r--r--colm/compiler.cc16
-rw-r--r--colm/declare.cc16
-rw-r--r--colm/parsedata.h2
-rw-r--r--colm/parser.cc10
-rw-r--r--colm/parser.h2
5 files changed, 19 insertions, 27 deletions
diff --git a/colm/compiler.cc b/colm/compiler.cc
index 72cdd9a8..7f7d6368 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -375,7 +375,6 @@ Compiler::Compiler( )
errorLangEl(0),
ignoreLangEl(0),
- rootRegion(0),
firstNonTermId(0),
prodIdIndex(0),
@@ -641,10 +640,17 @@ FsmGraph *Compiler::makeAllRegions()
* into the minimization algorithm. It is currently set by the longest
* match operator and not considered anywhere else. */
- /* Add all the other graphs into the first. */
- FsmGraph *all = graphs[0];
- all->globOp( graphs+1, numGraphs-1 );
- delete[] graphs;
+ FsmGraph *all;
+ if ( numGraphs == 0 ) {
+ all = new FsmGraph;
+ all->lambdaFsm();
+ }
+ else {
+ /* Add all the other graphs into the first. */
+ all = graphs[0];
+ all->globOp( graphs+1, numGraphs-1 );
+ delete[] graphs;
+ }
/* Go through all the token regions and check for lmRequiresErrorState. */
for ( RegionImplList::Iter reg = regionImplList; reg.lte(); reg++ ) {
diff --git a/colm/declare.cc b/colm/declare.cc
index 76a4bd5e..498b3b91 100644
--- a/colm/declare.cc
+++ b/colm/declare.cc
@@ -424,15 +424,13 @@ void Compiler::setPrecedence()
void Compiler::makeIgnoreCollectors()
{
for ( RegionSetList::Iter regionSet = regionSetList; regionSet.lte(); regionSet++ ) {
- if ( regionSet->tokenIgnore != rootRegion ) {
- String name( 128, "_ign_%p", regionSet->tokenIgnore );
- LangEl *zeroLel = new LangEl( rootNamespace, name, LangEl::Term );
- langEls.append( zeroLel );
- zeroLel->isZero = true;
- zeroLel->regionSet = regionSet;
-
- regionSet->collectIgnore->zeroLel = zeroLel;
- }
+ String name( 128, "_ign_%p", regionSet->tokenIgnore );
+ LangEl *zeroLel = new LangEl( rootNamespace, name, LangEl::Term );
+ langEls.append( zeroLel );
+ zeroLel->isZero = true;
+ zeroLel->regionSet = regionSet;
+
+ regionSet->collectIgnore->zeroLel = zeroLel;
}
}
diff --git a/colm/parsedata.h b/colm/parsedata.h
index fa227245..32c97a6f 100644
--- a/colm/parsedata.h
+++ b/colm/parsedata.h
@@ -859,8 +859,6 @@ struct Compiler
LangEl *errorLangEl;
LangEl *ignoreLangEl;
- TokenRegion *rootRegion;
-
Namespace *rootNamespace;
int nextSymbolId;
diff --git a/colm/parser.cc b/colm/parser.cc
index 2d9d7f8a..13e3208e 100644
--- a/colm/parser.cc
+++ b/colm/parser.cc
@@ -41,16 +41,6 @@ void BaseParser::init()
internal, String("___ROOT_NAMESPACE") );
pd->rootNamespace = rootNamespace;
- RegionImpl *rootImpl = new RegionImpl;
- pd->regionImplList.append( rootImpl );
- TokenRegion *rootRegion = createRegion( internal, rootImpl );
-
- RegionSet *rootRegionSet = new RegionSet( rootImpl, 0, 0, rootRegion, 0, 0, 0 );
- pd->regionSetList.append( rootRegionSet );
- regionStack.push( rootRegionSet );
-
- pd->rootRegion = rootRegion;
-
/* Set up the global object. */
String global = "global";
pd->globalObjectDef = ObjectDef::cons( ObjectDef::UserType,
diff --git a/colm/parser.h b/colm/parser.h
index a7a71c96..ed028065 100644
--- a/colm/parser.h
+++ b/colm/parser.h
@@ -46,7 +46,7 @@ struct BaseParser
bool enterRl;
bool insideRegion()
- { return regionStack.length() > 1; }
+ { return regionStack.length() > 0; }
/* Lexical feedback. */