summaryrefslogtreecommitdiff
path: root/colm/pdarun.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-04-04 20:27:00 -0400
committerAdrian Thurston <thurston@complang.org>2013-04-04 20:27:00 -0400
commit52ac774a4c4dcc6beb0b87e708e738efbe0e915d (patch)
tree4051a0b1acb75c8f3ddef2c75bdd7795cb01847b /colm/pdarun.c
parent6355aa3155a050d1a84212625dcc55fc407fbf79 (diff)
downloadcolm-52ac774a4c4dcc6beb0b87e708e738efbe0e915d.tar.gz
moving position updates into the consume operation
Diffstat (limited to 'colm/pdarun.c')
-rw-r--r--colm/pdarun.c44
1 files changed, 1 insertions, 43 deletions
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 915da819..2bd37c07 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -81,36 +81,6 @@ void clearFsmRun( Program *prg, FsmRun *fsmRun )
}
}
-/* Keep the position up to date after consuming text. */
-void updatePosition( StreamImpl *is, const char *data, long length )
-{
- int i;
- for ( i = 0; i < length; i++ ) {
- if ( data[i] != '\n' )
- is->column += 1;
- else {
- is->line += 1;
- is->column = 1;
- }
- }
-
- is->byte += length;
-}
-
-/* Keep the position up to date after sending back text. */
-void undoPosition( StreamImpl *is, const char *data, long length )
-{
- /* FIXME: this needs to fetch the position information from the parsed
- * token and restore based on that.. */
- int i;
- for ( i = 0; i < length; i++ ) {
- if ( data[i] == '\n' )
- is->line -= 1;
- }
-
- is->byte -= length;
-}
-
void incrementSteps( PdaRun *pdaRun )
{
pdaRun->steps += 1;
@@ -211,7 +181,6 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
fsmRun->toklen = 0;
Head *tokdata = stringAllocPointer( prg, dest, length );
- updatePosition( is, dest, length );
return tokdata;
}
@@ -222,7 +191,6 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
is->funcs->getData( is, dest, length );
is->funcs->consumeData( is, length );
- updatePosition( is, dest, length );
return head;
}
}
@@ -286,7 +254,6 @@ static void sendBackText( FsmRun *fsmRun, StreamImpl *is, const char *data, long
// (int)length, data );
is->funcs->undoConsumeData( is, data, length );
- undoPosition( is, data, length );
}
void sendBackTree( StreamImpl *is, Tree *tree )
@@ -364,10 +331,6 @@ static void sendBack( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
debug( prg, REALM_PARSE, "sending back: %s\n", prg->rtd->lelInfo[parseTree->id].name );
if ( parseTree->flags & PF_NAMED ) {
- ///* Send back anything in the buffer that has not been parsed. */
- //if ( fsmRun->p == fsmRun->runBuf->data )
- // sendBackRunBufHead( fsmRun, is );
-
/* Send the named lang el back first, then send back any leading
* whitespace. */
is->funcs->undoConsumeLangEl( is );
@@ -821,8 +784,7 @@ void sendIgnore( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun
/* Make the ignore string. */
Head *ignoreStr = extractMatch( prg, fsmRun, is );
- updatePosition( is, ignoreStr->data, ignoreStr->length );
-
+
debug( prg, REALM_PARSE, "ignoring: %.*s\n", ignoreStr->length, ignoreStr->data );
Tree *tree = treeAllocate( prg );
@@ -846,8 +808,6 @@ static void sendToken( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun,
prg->rtd->lelInfo[id].name,
stringLength(tokdata), stringData(tokdata) );
- updatePosition( is, stringData(tokdata), stringLength(tokdata) );
-
Kid *input = makeTokenWithData( prg, pdaRun, fsmRun, is, id, tokdata );
incrementSteps( pdaRun );
@@ -903,8 +863,6 @@ static void sendCi( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, Pda
prg->rtd->lelInfo[id].name,
stringLength(tokdata), stringData(tokdata) );
- updatePosition( is, stringData(tokdata), stringLength(tokdata) );
-
Kid *input = makeTokenWithData( prg, pdaRun, fsmRun, is, id, tokdata );
incrementSteps( pdaRun );