summaryrefslogtreecommitdiff
path: root/colm/pdabuild.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-05-19 21:59:43 -0400
committerAdrian Thurston <thurston@complang.org>2012-05-19 21:59:43 -0400
commit577e7426eb757aa118fbabf7dfa70d1308b8ac22 (patch)
treee8139ea0427fce258c053a1013413bc1c55d5d19 /colm/pdabuild.cc
parent8125026c4e458a9b3d6ef35508e59488343b890d (diff)
downloadcolm-577e7426eb757aa118fbabf7dfa70d1308b8ac22.tar.gz
a follow-ignore that appears to work
Duplicated the tokenRegion array with the preRegion taken from the same state. This turns the region into a pair of values. The pre-region is tried first. Eliminates the need to carry the pre-region anywhere in runtime state. Just checked when setting cs. If present cs is set using the pre-region and ncs is used for the real region. Not optimal space usage but that's okay for now. Many test case failures. Need to verify thew new output is correct.
Diffstat (limited to 'colm/pdabuild.cc')
-rw-r--r--colm/pdabuild.cc36
1 files changed, 22 insertions, 14 deletions
diff --git a/colm/pdabuild.cc b/colm/pdabuild.cc
index 613227ab..e645395e 100644
--- a/colm/pdabuild.cc
+++ b/colm/pdabuild.cc
@@ -1964,15 +1964,6 @@ PdaTables *ParseData::makePdaTables( PdaGraph *pdaGraph )
pos += state->regions.length() + 1;
}
- /*
- * tokenPreRegionInds. Continues on pos.
- */
- count = 0;
- pdaTables->tokenPreRegionInds = new int[pdaTables->numStates];
- for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ ) {
- pdaTables->tokenPreRegionInds[count++] = pos;
- pos += state->preRegions.length() + 1;
- }
/*
* tokenRegions. Build in a null at the beginning.
@@ -1981,8 +1972,6 @@ PdaTables *ParseData::makePdaTables( PdaGraph *pdaGraph )
count = 1;
for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ )
count += state->regions.length() + 1;
- for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ )
- count += state->preRegions.length() + 1;
pdaTables->numRegionItems = count;
pdaTables->tokenRegions = new int[pdaTables->numRegionItems];
@@ -1996,13 +1985,32 @@ PdaTables *ParseData::makePdaTables( PdaGraph *pdaGraph )
pdaTables->tokenRegions[count++] = 0;
}
+ /*
+ * tokenPreRegions. Build in a null at the beginning.
+ */
+
+ count = 1;
+ for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ )
+ count += state->regions.length() + 1;
+
+ pdaTables->numPreRegionItems = count;
+ pdaTables->tokenPreRegions = new int[pdaTables->numPreRegionItems];
+
+ count = 0;
+ pdaTables->tokenPreRegions[count++] = 0;
for ( PdaStateList::Iter state = pdaGraph->stateList; state.lte(); state++ ) {
- for ( RegionVect::Iter reg = state->preRegions; reg.lte(); reg++ )
- pdaTables->tokenRegions[count++] = (*reg)->id + 1;
+ for ( RegionVect::Iter reg = state->regions; reg.lte(); reg++ ) {
+ assert( state->preRegions.length() <= 1 );
+ if ( state->preRegions.length() == 0 || state->preRegions[0]->wasEmpty )
+ pdaTables->tokenPreRegions[count++] = -1;
+ else
+ pdaTables->tokenPreRegions[count++] = state->preRegions[0]->id + 1;
+ }
- pdaTables->tokenRegions[count++] = 0;
+ pdaTables->tokenPreRegions[count++] = 0;
}
+
return pdaTables;
}