diff options
author | David Robillard <d@drobilla.net> | 2023-12-01 21:59:18 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 9b1139fe7045a0630e87501235af21803860b80c (patch) | |
tree | 3a7cd3ee639e0b7a6f2244177819f8843202c692 /src/read_turtle.c | |
parent | 94879f376f1d2b8fbb2322bf2a7dab5c3bb9e098 (diff) | |
download | serd-9b1139fe7045a0630e87501235af21803860b80c.tar.gz serd-9b1139fe7045a0630e87501235af21803860b80c.tar.bz2 serd-9b1139fe7045a0630e87501235af21803860b80c.zip |
[WIP] Add support for reading and writing variables
[WIP] Command line option, move later?
This adds a reader flag and serdi option for extending a syntax with support
for SPARQL-like variables, for storing things like patterns or simple queries.
Diffstat (limited to 'src/read_turtle.c')
-rw-r--r-- | src/read_turtle.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/read_turtle.c b/src/read_turtle.c index 828818ba..027f0918 100644 --- a/src/read_turtle.c +++ b/src/read_turtle.c @@ -458,10 +458,15 @@ read_literal(SerdReader* const reader, } static SerdStatus -read_verb(SerdReader* const reader, SerdNode** const dest) +read_verb(SerdReader* reader, SerdNode** const dest) { const size_t orig_stack_size = reader->stack.size; - if (peek_byte(reader) == '<') { + + switch (peek_byte(reader)) { + case '$': + case '?': + return read_Var(reader, dest); + case '<': return read_IRIREF(reader, dest); } @@ -617,6 +622,10 @@ read_object(SerdReader* const reader, case EOF: case ')': return r_err(reader, SERD_BAD_SYNTAX, "expected object"); + case '$': + case '?': + st = read_Var(reader, &o); + break; case '[': simple = false; st = read_anon(reader, *ctx, false, &o); @@ -813,6 +822,10 @@ read_turtle_subject(SerdReader* const reader, SerdStatus st = SERD_SUCCESS; bool ate_dot = false; switch ((*s_type = peek_byte(reader))) { + case '$': + case '?': + st = read_Var(reader, dest); + break; case '[': st = read_anon(reader, ctx, true, dest); break; |