From 64024d0fa6a6dc048b2b846738846da597025f56 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 25 Feb 2021 11:16:13 -0500 Subject: 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. --- src/read_turtle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/read_turtle.c') diff --git a/src/read_turtle.c b/src/read_turtle.c index 027f0918..c3970a1e 100644 --- a/src/read_turtle.c +++ b/src/read_turtle.c @@ -13,6 +13,7 @@ #include "try.h" #include "turtle.h" +#include "serd/caret.h" #include "serd/node.h" #include "serd/reader.h" #include "serd/sink.h" @@ -610,6 +611,7 @@ read_object(SerdReader* const reader, bool* const ate_dot) { const size_t orig_stack_size = reader->stack.size; + SerdCaret orig_caret = reader->source->caret; assert(ctx->subject); @@ -660,6 +662,7 @@ read_object(SerdReader* const reader, break; case '\"': case '\'': + ++orig_caret.col; st = read_literal(reader, &o, ate_dot); break; default: @@ -668,7 +671,7 @@ read_object(SerdReader* const reader, } if (!st && simple && o) { - st = emit_statement(reader, *ctx, o); + st = emit_statement_at(reader, *ctx, o, &orig_caret); } serd_stack_pop_to(&reader->stack, orig_stack_size); -- cgit v1.2.1