diff options
author | David Robillard <d@drobilla.net> | 2021-02-25 11:16:13 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 64024d0fa6a6dc048b2b846738846da597025f56 (patch) | |
tree | 7966dc76915aee1e4f284abe3685aa5b28e14dd3 /src/reader.c | |
parent | 456bdeef35ffbfbdad7609e8b8a4ef71372786fd (diff) | |
download | serd-64024d0fa6a6dc048b2b846738846da597025f56.tar.gz serd-64024d0fa6a6dc048b2b846738846da597025f56.tar.bz2 serd-64024d0fa6a6dc048b2b846738846da597025f56.zip |
Leave statement caret at the start of literals
This allows a precise location to be reported for errors within literals, by
adding the offset of the error in the literal to the caret. This will be used
to report nice errors for things like regular expressions and supported XSD
datatypes.
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/reader.c b/src/reader.c index f34f7974..7e0864cc 100644 --- a/src/reader.c +++ b/src/reader.c @@ -162,9 +162,10 @@ tokcmp(const SerdNode* const node, const char* const tok, const size_t n) } SerdStatus -emit_statement(SerdReader* const reader, - const ReadContext ctx, - SerdNode* const o) +emit_statement_at(SerdReader* const reader, + const ReadContext ctx, + SerdNode* const o, + SerdCaret* const caret) { if (reader->stack.size + (2 * sizeof(SerdNode)) > reader->stack.buf_size) { return SERD_BAD_STACK; @@ -175,7 +176,7 @@ emit_statement(SerdReader* const reader, serd_node_zero_pad(o); const SerdStatement statement = {{ctx.subject, ctx.predicate, o, ctx.graph}, - &reader->source->caret}; + caret}; const SerdStatus st = serd_sink_write_statement(reader->sink, *ctx.flags, &statement); @@ -185,6 +186,14 @@ emit_statement(SerdReader* const reader, } SerdStatus +emit_statement(SerdReader* const reader, + const ReadContext ctx, + SerdNode* const o) +{ + return emit_statement_at(reader, ctx, o, &reader->source->caret); +} + +SerdStatus serd_reader_read_document(SerdReader* const reader) { assert(reader); |