summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-12-26 17:45:17 -0500
committerAdrian Thurston <thurston@complang.org>2015-12-26 17:45:17 -0500
commit3a44350de6d68378eb235c2305ecfe2a1496e5b6 (patch)
treead9a802b08715ff00533b770b88a998082250274
parent5a80d5bf17dd9b176c034bae4d708710f6305419 (diff)
downloadcolm-3a44350de6d68378eb235c2305ecfe2a1496e5b6.tar.gz
when pushing data in front of a stream, source the location
When pushing data onto a stream in front of a source with locaiton information, grab that location information.
-rw-r--r--src/input.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/input.c b/src/input.c
index 95e7f9ab..94b0c85d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -673,8 +673,12 @@ static int stream_consume_data( program_t *prg, tree_t **sp, struct stream_impl
is->consumed += slen;
}
- if ( !loc_set( loc ) )
- default_loc( loc );
+ if ( !loc_set( loc ) ) {
+ if ( is->line > 0 )
+ transfer_loc( loc, is );
+ else
+ default_loc( loc );
+ }
}
if ( length == 0 ) {
@@ -778,6 +782,17 @@ static void stream_prepend_data( struct stream_impl *is, const char *data, long
stream_prepend_data( stream_to_impl( (stream_t*)is->queue->tree ), data, length );
}
else {
+ if ( is_source_stream( is ) ) {
+ message( "sourcing line info\n" );
+
+ /* steal the location information. */
+ stream_t *s = ((stream_t*)is->queue->tree);
+ is->line = s->impl->line;
+ is->column = s->impl->column;
+ is->byte = s->impl->byte;
+ is->name = s->impl->name;
+ }
+
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
* data that can be pushed back to the inputStream. */