diff options
-rw-r--r-- | colm/pdarun.c | 133 | ||||
-rw-r--r-- | colm/pdarun.h | 2 |
2 files changed, 66 insertions, 69 deletions
diff --git a/colm/pdarun.c b/colm/pdarun.c index faaf45fb..48d63ad6 100644 --- a/colm/pdarun.c +++ b/colm/pdarun.c @@ -93,70 +93,6 @@ void decrementSteps( PdaRun *pdaRun ) //debug( prg, REALM_PARSE, "steps down to %ld\n", pdaRun->steps ); } -Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is ) -{ - long length = fsmRun->toklen; - - //debug( prg, REALM_PARSE, "extracting token of length: %ld\n", length ); - - RunBuf *runBuf = fsmRun->consumeBuf; - if ( runBuf == 0 || length > ( FSM_BUFSIZE - runBuf->length ) ) { - runBuf = newRunBuf(); - runBuf->next = fsmRun->consumeBuf; - fsmRun->consumeBuf = runBuf; - } - - char *dest = runBuf->data + runBuf->length; - - is->funcs->getData( is, dest, length ); - Location *location = locationAllocate( prg ); - is->funcs->consumeData( is, length, location ); - - runBuf->length += length; - - fsmRun->p = fsmRun->pe = 0; - fsmRun->toklen = 0; - fsmRun->tokstart = 0; - - Head *head = stringAllocPointer( prg, dest, length ); - - head->location = location; - - debug( prg, REALM_PARSE, "location byte: %d\n", is->byte ); - - return head; -} - -Head *peekMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is ) -{ - long length = fsmRun->toklen; - - RunBuf *runBuf = fsmRun->consumeBuf; - if ( runBuf == 0 || length > ( FSM_BUFSIZE - runBuf->length ) ) { - runBuf = newRunBuf(); - runBuf->next = fsmRun->consumeBuf; - fsmRun->consumeBuf = runBuf; - } - - char *dest = runBuf->data + runBuf->length; - - is->funcs->getData( is, dest, length ); - - fsmRun->p = fsmRun->pe = 0; - fsmRun->toklen = 0; - - Head *head = stringAllocPointer( prg, dest, length ); - - head->location = locationAllocate( prg ); - head->location->line = is->line; - head->location->column = is->column; - head->location->byte = is->byte; - - debug( prg, REALM_PARSE, "location byte: %d\n", is->byte ); - - return head; -} - Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length ) { if ( pdaRun != 0 ) { @@ -793,7 +729,72 @@ void handleError( Program *prg, Tree **sp, PdaRun *pdaRun ) } } -void sendIgnore( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun *pdaRun, long id ) +static Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is ) +{ + long length = fsmRun->toklen; + + //debug( prg, REALM_PARSE, "extracting token of length: %ld\n", length ); + + RunBuf *runBuf = fsmRun->consumeBuf; + if ( runBuf == 0 || length > ( FSM_BUFSIZE - runBuf->length ) ) { + runBuf = newRunBuf(); + runBuf->next = fsmRun->consumeBuf; + fsmRun->consumeBuf = runBuf; + } + + char *dest = runBuf->data + runBuf->length; + + is->funcs->getData( is, dest, length ); + Location *location = locationAllocate( prg ); + is->funcs->consumeData( is, length, location ); + + runBuf->length += length; + + fsmRun->p = fsmRun->pe = 0; + fsmRun->toklen = 0; + fsmRun->tokstart = 0; + + Head *head = stringAllocPointer( prg, dest, length ); + + head->location = location; + + debug( prg, REALM_PARSE, "location byte: %d\n", is->byte ); + + return head; +} + +static Head *peekMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is ) +{ + long length = fsmRun->toklen; + + RunBuf *runBuf = fsmRun->consumeBuf; + if ( runBuf == 0 || length > ( FSM_BUFSIZE - runBuf->length ) ) { + runBuf = newRunBuf(); + runBuf->next = fsmRun->consumeBuf; + fsmRun->consumeBuf = runBuf; + } + + char *dest = runBuf->data + runBuf->length; + + is->funcs->getData( is, dest, length ); + + fsmRun->p = fsmRun->pe = 0; + fsmRun->toklen = 0; + + Head *head = stringAllocPointer( prg, dest, length ); + + head->location = locationAllocate( prg ); + head->location->line = is->line; + head->location->column = is->column; + head->location->byte = is->byte; + + debug( prg, REALM_PARSE, "location byte: %d\n", is->byte ); + + return head; +} + + +static void sendIgnore( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun *pdaRun, long id ) { debug( prg, REALM_PARSE, "ignoring: %s\n", prg->rtd->lelInfo[id].name ); @@ -863,8 +864,6 @@ static void sendCi( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, Pda { debug( prg, REALM_PARSE, "token: CI\n" ); -/**/ - int emptyIgnore = pdaRun->accumIgnore == 0; /* Make the token data. */ diff --git a/colm/pdarun.h b/colm/pdarun.h index f30e602a..afc687f0 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -442,8 +442,6 @@ void executeGenerationAction( struct ColmProgram *prg, Tree **sp, FsmRun *fsmRun StreamImpl *inputStream, int frameId, Code *code, long id, Head *tokdata ); Kid *extractIgnore( PdaRun *pdaRun ); void clearIgnoreList( struct ColmProgram *prg, Tree **sp, Kid *kid ); -Head *extractMatch( struct ColmProgram *prg, FsmRun *fsmRun, StreamImpl *inputStream ); -Head *extractMatch( struct ColmProgram *prg, FsmRun *fsmRun, StreamImpl *inputStream ); long parseLoop( struct ColmProgram *prg, Tree **sp, PdaRun *pdaRun, StreamImpl *inputStream, long entry ); Tree *getParsedRoot( PdaRun *pdaRun, int stop ); |