diff options
author | David Robillard <d@drobilla.net> | 2011-01-22 19:40:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-22 19:40:25 +0000 |
commit | 70b81af9060efb3963949cdcf68611244a4c520c (patch) | |
tree | f42838a5b987aee725e01b849fdd540ffc843261 /src/reader.c | |
parent | 88a315b8ecf1534a92466bdc1ad37fe6a1bd6031 (diff) | |
download | serd-70b81af9060efb3963949cdcf68611244a4c520c.tar.gz serd-70b81af9060efb3963949cdcf68611244a4c520c.tar.bz2 serd-70b81af9060efb3963949cdcf68611244a4c520c.zip |
Emit triples in the correct order for streaming abbreviation.
git-svn-id: http://svn.drobilla.net/serd/trunk@38 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/reader.c b/src/reader.c index 0566617b..ea941770 100644 --- a/src/reader.c +++ b/src/reader.c @@ -1003,17 +1003,28 @@ read_blank(SerdReader reader, Context ctx, Node* dest) if (peek_byte(reader) == ']') { eat_byte(reader, ']'); *dest = make_node(BLANK, blank_id(reader), 0, 0); - return true; + if (ctx.subject) { + emit_statement(reader, ctx.graph, ctx.subject, ctx.predicate, dest); + } } else { *dest = make_node(BLANK, blank_id(reader), 0, 0); + if (ctx.subject) { + emit_statement(reader, ctx.graph, ctx.subject, ctx.predicate, dest); + } ctx.subject = dest; read_predicateObjectList(reader, ctx); read_ws_star(reader); eat_byte(reader, ']'); - return true; } + return true; case '(': - return read_collection(reader, ctx, dest); + if (read_collection(reader, ctx, dest)) { + if (ctx.subject) { + emit_statement(reader, ctx.graph, ctx.subject, ctx.predicate, dest); + } + return true; + } + return false; default: return error(reader, "illegal blank node\n"); } @@ -1041,13 +1052,17 @@ read_object(SerdReader reader, Context ctx) static const size_t XSD_BOOLEAN_LEN = 40; uint8_t pre[6]; - bool ret = false; - Node o = SERD_NODE_NULL; - const uint8_t c = peek_byte(reader); + bool ret = false; + bool emit = true; + Node o = SERD_NODE_NULL; + const uint8_t c = peek_byte(reader); switch (c) { case ')': return false; - case '[': case '(': case '_': + case '[': case '(': + emit = false; + // fall through + case '_': TRY_THROW(ret = read_blank(reader, ctx, &o)); break; case '<': case ':': @@ -1083,7 +1098,7 @@ read_object(SerdReader reader, Context ctx) ret = o.value; } - if (ret) { + if (ret && emit) { assert(o.value); emit_statement(reader, ctx.graph, ctx.subject, ctx.predicate, &o); } |