summaryrefslogtreecommitdiff
path: root/colm/pdabuild.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-05-22 20:33:51 -0400
committerAdrian Thurston <thurston@complang.org>2012-05-22 20:33:51 -0400
commit35f086e516696d13b13d129062ae45d186e3523e (patch)
treef3360707423e65dbad73c203ce27deccd65d070e /colm/pdabuild.cc
parentaa01add5ba8ea59850b4db058f6a0e53ab9c41fe (diff)
downloadcolm-35f086e516696d13b13d129062ae45d186e3523e.tar.gz
improvements to ignore handling in the parser
Every region now also has a duplicate scanning region that is only for tokens. The duplicate ignores and tokens generate the original tokens through a TokenDef ignore mechanism. Can turn off post ignore parsing and pre-igore parsing on a token-by-token basis. Probably want to move it into the productions and specify it there. Currently don't have a specification mechanism. If an ignore is a post-token ignore it is not right-attached.
Diffstat (limited to 'colm/pdabuild.cc')
-rw-r--r--colm/pdabuild.cc29
1 files changed, 23 insertions, 6 deletions
diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc
index 66af8846..aba017f7 100644
--- a/colm/pdabuild.cc
+++ b/colm/pdabuild.cc
@@ -89,7 +89,9 @@ LangEl::LangEl( Namespace *nspace, const String &name, Type type )
predType(PredNone),
predValue(0),
contextDef(0),
- contextIn(0)
+ contextIn(0),
+ preNoIgnore(false),
+ postNoIgnore(false)
{
}
@@ -479,11 +481,25 @@ void ParseData::addRegion( PdaState *tabState, PdaTrans *tabTrans, long pdaKey )
region = klangEl->tokenDef->tokenRegion;
if ( region != 0 ) {
- if ( !regionVectHas( tabState->regions, region ) )
- tabState->regions.append( region );
+ /* region. */
+ TokenRegion *scanRegion = region;
+
+ if ( klangEl->preNoIgnore )
+ scanRegion = region->tokenOnlyRegion;
+
+ if ( !regionVectHas( tabState->regions, scanRegion ) ) {
+ tabState->regions.append( scanRegion );
+ }
+
+ /* Pre-region of to state */
+ PdaState *toState = tabTrans->toState;
+ if ( !klangEl->postNoIgnore &&
+ region->ignoreOnlyRegion != 0 &&
+ !regionVectHas( toState->preRegions, region->ignoreOnlyRegion ) )
+ {
+ toState->preRegions.append( region->ignoreOnlyRegion );
+ }
- if ( region->ignoreRegion != 0 && !regionVectHas( tabTrans->toState->preRegions, region->ignoreRegion ) )
- tabTrans->toState->preRegions.append( region->ignoreRegion );
}
}
}
@@ -1335,8 +1351,9 @@ void ParseData::makeRuntimeData()
long regId = reg->id+1;
runtimeData->regionInfo[regId].name = reg->name;
runtimeData->regionInfo[regId].defaultToken =
- reg->defaultTokenDef == 0 ? -1 : reg->defaultTokenDef->token->id;
+ reg->defaultTokenDef == 0 ? -1 : reg->defaultTokenDef->tdLangEl->id;
runtimeData->regionInfo[regId].eofFrameId = -1;
+ runtimeData->regionInfo[regId].isIgnoreOnly = reg->isIgnoreOnly;
CodeBlock *block = reg->preEofBlock;
if ( block != 0 ) {