diff options
author | Adrian Thurston <thurston@complang.org> | 2013-04-07 16:54:17 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2013-04-07 16:54:17 -0400 |
commit | bad9a15e0b56c3b047335832ae0e9e53fa4a41a6 (patch) | |
tree | b83ad984c3bda890eecedc264f922308fca75cca | |
parent | 2e827cbafe81c13ece6ad2e3309c1401932b75dc (diff) | |
download | colm-bad9a15e0b56c3b047335832ae0e9e53fa4a41a6.tar.gz |
eliminating EOF region concept to reduce static data
-rw-r--r-- | colm/parsedata.h | 1 | ||||
-rw-r--r-- | colm/parser.cc | 3 | ||||
-rw-r--r-- | colm/pdabuild.cc | 13 |
3 files changed, 10 insertions, 7 deletions
diff --git a/colm/parsedata.h b/colm/parsedata.h index cbd6c93c..fa227245 100644 --- a/colm/parsedata.h +++ b/colm/parsedata.h @@ -860,7 +860,6 @@ struct Compiler LangEl *ignoreLangEl; TokenRegion *rootRegion; - TokenRegion *eofTokenRegion; Namespace *rootNamespace; diff --git a/colm/parser.cc b/colm/parser.cc index eb244c65..2d9d7f8a 100644 --- a/colm/parser.cc +++ b/colm/parser.cc @@ -56,9 +56,6 @@ void BaseParser::init() pd->globalObjectDef = ObjectDef::cons( ObjectDef::UserType, global, pd->nextObjectId++ ); - /* The eofTokenRegion defaults to the root region. */ - pd->eofTokenRegion = rootRegion; - /* Initialize the dictionary of graphs. This is our symbol table. The * initialization needs to be done on construction which happens at the * beginning of a machine spec so any assignment operators can reference diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc index 57f54d20..c64f460f 100644 --- a/colm/pdabuild.cc +++ b/colm/pdabuild.cc @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define EOF_REGION 0 + #include <iostream> #include <iomanip> #include <errno.h> @@ -639,7 +641,7 @@ void Compiler::pdaActionOrder( PdaGraph *pdaGraph, LangElSet &parserEls ) PdaTrans *trans = tel->value; LangEl *lel = langElIndex[trans->lowKey]; if ( lel != 0 && lel->isEOF ) - state->regions.append( eofTokenRegion ); + state->regions.append( EOF_REGION ); } } } @@ -1347,6 +1349,9 @@ void Compiler::makeRuntimeData() memset( runtimeData->regionInfo, 0, sizeof(RegionInfo) * runtimeData->numRegions ); runtimeData->regionInfo[0].defaultToken = -1; + runtimeData->regionInfo[0].eofFrameId = -1; + runtimeData->regionInfo[0].ciLelId = 0; + for ( RegionList::Iter reg = regionList; reg.lte(); reg++ ) { long regId = reg->id+1; runtimeData->regionInfo[regId].defaultToken = @@ -2031,8 +2036,10 @@ PdaTables *Compiler::makePdaTables( PdaGraph *pdaGraph ) count = 0; pdaTables->tokenRegions[count++] = 0; for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ ) { - for ( RegionVect::Iter reg = state->regions; reg.lte(); reg++ ) - pdaTables->tokenRegions[count++] = (*reg)->id + 1; + for ( RegionVect::Iter reg = state->regions; reg.lte(); reg++ ) { + int id = ( *reg == EOF_REGION ) ? 0 : (*reg)->id + 1; + pdaTables->tokenRegions[count++] = id; + } pdaTables->tokenRegions[count++] = 0; } |