summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-05-29 13:07:34 +0000
committerAdrian Thurston <thurston@complang.org>2012-05-29 13:07:34 +0000
commitdc24efc973f9c02b5fa778a99b6874b0eed43b45 (patch)
treee6136d2063fe29cc805f6b42b37f040676b01571
parent96c1648420152ddc6b91220dcca0156ec477587a (diff)
downloadcolm-dc24efc973f9c02b5fa778a99b6874b0eed43b45.tar.gz
flattened the reg lang name tree down to a list for regions
-rw-r--r--colm/parsetree.cc42
-rw-r--r--colm/redbuild.cc16
2 files changed, 14 insertions, 44 deletions
diff --git a/colm/parsetree.cc b/colm/parsetree.cc
index 38f2e503..084ffbb8 100644
--- a/colm/parsetree.cc
+++ b/colm/parsetree.cc
@@ -201,11 +201,6 @@ FsmGraph *VarDef::walk( Compiler *pd )
/* We can now unset entry points that are not longer used. */
pd->unsetObsoleteEntries( rtnVal );
- /* If the name of the variable is referenced then add the entry point to
- * the graph. */
- if ( pd->curNameInst->numRefs > 0 )
- rtnVal->setEntry( pd->curNameInst->id, rtnVal->startState );
-
return rtnVal;
}
@@ -244,14 +239,16 @@ void RegionDef::makeNameTree( const InputLoc &loc, Compiler *pd )
NameInst *prevNameInst = pd->curNameInst;
pd->curNameInst = pd->addNameInst( loc, name, false );
- pd->curNameInst->isLongestMatch = true;
-
- /* Recurse. */
- tokenRegion->makeNameTree( pd );
-
/* Guess we do this now. */
tokenRegion->makeActions( pd );
+ /* Save off the name inst into the token region. This is only legal for
+ * token regions because they are only ever referenced once (near the root
+ * of the name tree). They cannot have more than one corresponding name
+ * inst. */
+ assert( tokenRegion->regionNameInst == 0 );
+ tokenRegion->regionNameInst = pd->curNameInst;
+
/* The name scope ends, pop the name instantiation. */
pd->curNameInst = prevNameInst;
}
@@ -343,25 +340,6 @@ void TokenRegion::makeActions( Compiler *pd )
lmActSelect = newAction( pd, loc, "lagsel", il6 );
}
-void TokenRegion::makeNameTree( Compiler *pd )
-{
- /* Create an anonymous scope for the longest match. Will be used for
- * restarting machine after matching a token. */
- NameInst *prevNameInst = pd->curNameInst;
- pd->curNameInst = pd->addNameInst( loc, 0, false );
-
- /* Save off the name inst into the token region. This is only legal for
- * token regions because they are only ever referenced once (near the root
- * of the name tree). They cannot have more than one corresponding name
- * inst. */
- assert( regionNameInst == 0 );
- regionNameInst = pd->curNameInst;
-
- /* The name scope ends, pop the name instantiation. */
- pd->curNameInst = prevNameInst;
-}
-
-
void TokenRegion::restart( FsmGraph *graph, FsmTrans *trans )
{
FsmState *fromState = trans->fromState;
@@ -552,9 +530,6 @@ void TokenRegion::transferScannerLeavingActions( FsmGraph *graph )
FsmGraph *TokenRegion::walk( Compiler *pd )
{
- /* The longest match has it's own name scope. */
- NameFrame nameFrame = pd->enterNameScope( true, 1 );
-
/* Make each part of the longest match. */
int numParts = 0;
FsmGraph **parts = new FsmGraph*[tokenDefList.length()];
@@ -602,9 +577,6 @@ FsmGraph *TokenRegion::walk( Compiler *pd )
delete[] parts;
}
- /* Pop the name scope. */
- pd->popNameScope( nameFrame );
-
return retFsm;
}
diff --git a/colm/redbuild.cc b/colm/redbuild.cc
index e85d74ca..ae5faf38 100644
--- a/colm/redbuild.cc
+++ b/colm/redbuild.cc
@@ -556,17 +556,15 @@ void RedFsmBuild::makeEntryPoints()
}
for ( RegionList::Iter reg = pd->regionList; reg.lte(); reg++ ) {
- if ( reg->regionNameInst == 0 )
- addRegionToEntry( reg->id, pd->defaultRegion->id );
- else {
- TokenRegion *use = reg;
+ assert( reg->regionNameInst != 0 );
- if ( use->isCiOnly )
- use = use->derivedFrom->ignoreOnlyRegion;
+ TokenRegion *use = reg;
- NameInst *regionName = use->regionNameInst->parent;
- addRegionToEntry( reg->id, regionName->id );
- }
+ if ( use->isCiOnly )
+ use = use->derivedFrom->ignoreOnlyRegion;
+
+ NameInst *regionName = use->regionNameInst;
+ addRegionToEntry( reg->id, regionName->id );
}
}