summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-04-06 22:06:15 -0400
committerAdrian Thurston <thurston@complang.org>2013-04-06 22:06:15 -0400
commitd93b9cea5c7711a4737b04cb6a3f0df7fc0d4f44 (patch)
tree78ddf62712a3d2f65ab89b069e54b3a8b83606f8
parentfd2321adba3b2fb536fb2dee778d5654ff554a01 (diff)
downloadcolm-d93b9cea5c7711a4737b04cb6a3f0df7fc0d4f44.tar.gz
some code movement to make static functions
-rw-r--r--colm/pdarun.c133
-rw-r--r--colm/pdarun.h2
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 );