summaryrefslogtreecommitdiff
path: root/colm/pdarun.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-05-14 11:57:05 -0400
committerAdrian Thurston <thurston@complang.org>2012-05-14 11:57:05 -0400
commitc07ff3da211df08d3fcbc3ea0b7fe67350a08142 (patch)
tree1ae1f0712869bd9d6c1a3378830285d53b4428ee /colm/pdarun.c
parent4c7b1e79d8c07485c067833cee998123acfcf57f (diff)
downloadcolm-c07ff3da211df08d3fcbc3ea0b7fe67350a08142.tar.gz
Added a separate Kid data structure for use with parse trees.
Diffstat (limited to 'colm/pdarun.c')
-rw-r--r--colm/pdarun.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 25bcbfdb..6cec9c6c 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -224,9 +224,9 @@ void sendBackTree( InputStream *inputStream, Tree *tree )
* PcrRevIgnore
*/
static void sendBackIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
- InputStream *inputStream, Kid *_ignore )
+ InputStream *inputStream, Kid2 *_ignore )
{
- Kid *ignoreKidList = pt(_ignore->tree)->shadow;
+ Kid *ignoreKidList = _ignore->tree->shadow;
Kid *ignore = ignoreKidList;
#ifdef COLM_LOG
@@ -259,8 +259,6 @@ static void sendBackIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsm
kidFree( prg, ignore );
}
-
-
void attachInput( FsmRun *fsmRun, InputStream *is )
{
if ( is->attached != 0 && is->attached != fsmRun )
@@ -431,15 +429,15 @@ void ignoreTree( Program *prg, PdaRun *pdaRun, Tree *tree )
parseTree->shadow = kidAllocate( prg );
parseTree->shadow->tree = tree;
- Kid *ignore = kidAllocate( prg );
- ignore->tree = (Tree*)parseTree;
+ Kid2 *ignore = kid2Allocate( prg );
+ ignore->tree = parseTree;
ignore->next = pdaRun->accumIgnore;
pdaRun->accumIgnore = ignore;
transferReverseCode( pdaRun, (Tree*)parseTree );
- setRegion( pdaRun, emptyIgnore, pt(pdaRun->accumIgnore->tree) );
+ setRegion( pdaRun, emptyIgnore, pdaRun->accumIgnore->tree );
}
Kid *makeTokenWithData( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream, int id,
@@ -554,18 +552,18 @@ static void attachIgnoreRight( Program *prg, Tree **sp, PdaRun *pdaRun )
/* The data list needs to be extracted and reversed. The parse tree list
* can remain in stack order. */
- Kid *child = pdaRun->accumIgnore, *last = 0;
- Kid *dataChild = 0;
+ Kid2 *child = pdaRun->accumIgnore;
+ Kid *dataChild = 0, *dataLast = 0;
while ( child ) {
- dataChild = pt(child->tree)->shadow;
+ dataChild = child->tree->shadow;
Kid *kid = kidAllocate( prg );
kid->tree = dataChild->tree;
- kid->next = last;
+ kid->next = dataLast;
treeUpref( kid->tree );
- last = kid;
+ dataLast = kid;
child = child->next;
}
@@ -615,17 +613,17 @@ static void attachIgnoreLeft( Program *prg, Tree **sp, PdaRun *pdaRun, Kid *to )
input->tree->flags &= ~AF_LEFT_IL_ATTACHED;
input->tree->flags &= ~AF_RIGHT_IL_ATTACHED;
- Kid *accum = pdaRun->accumIgnore;
+ Kid2 *accum = pdaRun->accumIgnore;
pdaRun->accumIgnore = 0;
/* The data list needs to be extracted and reversed. The parse tree list
* can remain in stack order. */
- Kid *child = accum, *last = 0;
+ Kid2 *child = accum, *last = 0;
Kid *dataChild = 0, *dataLast = 0;
while ( child ) {
dataChild = pt(child->tree)->shadow;
- Kid *next = child->next;
+ Kid2 *next = child->next;
/* Reverse the lists. */
dataChild->next = dataLast;
@@ -745,19 +743,20 @@ static void detachIgnoreLeft( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *f
assert( leftIgnore != 0 );
/* Transfer the trees to accumIgnore. */
- Kid *ignore = parseTree->ignore;
+ Kid2 *ignore = parseTree->ignore;
parseTree->ignore = 0;
Kid *dataIgnore = leftIgnore->child;
leftIgnore->child = 0;
- Kid *last = 0, *dataLast = 0;
+ Kid2 *last = 0;
+ Kid *dataLast = 0;
while ( ignore != 0 ) {
- Kid *next = ignore->next;
+ Kid2 *next = ignore->next;
Kid *dataNext = dataIgnore->next;
/* Put the data trees underneath the parse trees. */
- pt(ignore->tree)->shadow = dataIgnore;
+ ignore->tree->shadow = dataIgnore;
/* Reverse. */
ignore->next = last;
@@ -2178,11 +2177,11 @@ case PcrReverse:
/* Send back any accumulated ignore tokens, then trigger error
* in the the parser. */
- Kid *ignore = pdaRun->accumIgnore;
+ Kid2 *ignore = pdaRun->accumIgnore;
pdaRun->accumIgnore = pdaRun->accumIgnore->next;
ignore->next = 0;
- long region = pt(ignore->tree)->region;
+ long region = ignore->tree->region;
pdaRun->next = region > 0 ? region + 1 : 0;
pdaRun->checkNext = true;
pdaRun->checkStop = true;