summaryrefslogtreecommitdiff
path: root/colm/pdarun.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-04-06 10:09:30 -0400
committerAdrian Thurston <thurston@complang.org>2013-04-06 10:09:30 -0400
commit816628fc699237bf94e8e79c4a3890c30cd8c547 (patch)
treef695fde82f4f55732094158b3ce9e14a8e943bd2 /colm/pdarun.c
parentdf6297d0abaecdd0eb96dd41e51e9f50bd18de22 (diff)
downloadcolm-816628fc699237bf94e8e79c4a3890c30cd8c547.tar.gz
set new token location in the consume function
This way we get the location from the leaf stream that it was pulled from.
Diffstat (limited to 'colm/pdarun.c')
-rw-r--r--colm/pdarun.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 2bd37c07..0049b7a5 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -109,7 +109,8 @@ Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
char *dest = runBuf->data + runBuf->length;
is->funcs->getData( is, dest, length );
- is->funcs->consumeData( is, length );
+ Location *location = locationAllocate( prg );
+ is->funcs->consumeData( is, length, location );
runBuf->length += length;
@@ -119,10 +120,7 @@ Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
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;
+ head->location = location;
debug( prg, REALM_PARSE, "location byte: %d\n", is->byte );
@@ -173,7 +171,8 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
char *dest = runBuf->data + runBuf->length;
is->funcs->getData( is, dest, length );
- is->funcs->consumeData( is, length );
+ Location *loc = locationAllocate( prg );
+ is->funcs->consumeData( is, length, loc );
runBuf->length += length;
@@ -181,6 +180,7 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
fsmRun->toklen = 0;
Head *tokdata = stringAllocPointer( prg, dest, length );
+ tokdata->location = loc;
return tokdata;
}
@@ -189,7 +189,9 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
char *dest = (char*)head->data;
is->funcs->getData( is, dest, length );
- is->funcs->consumeData( is, length );
+ Location *loc = locationAllocate( prg );
+ is->funcs->consumeData( is, length, loc );
+ head->location = loc;
return head;
}