aboutsummaryrefslogtreecommitdiffstats
path: root/src/n3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/n3.c')
-rw-r--r--src/n3.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/n3.c b/src/n3.c
index c0c00985..929b1a97 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -842,10 +842,11 @@ read_0_9(SerdReader* const reader, const Ref str, const bool at_least_one)
}
static SerdStatus
-read_number(SerdReader* const reader,
- Ref* const dest,
- Ref* const datatype,
- bool* const ate_dot)
+read_number(SerdReader* const reader,
+ Ref* const dest,
+ Ref* const datatype,
+ SerdNodeFlags* const flags,
+ bool* const ate_dot)
{
#define XSD_DECIMAL NS_XSD "decimal"
#define XSD_DOUBLE NS_XSD "double"
@@ -904,6 +905,10 @@ read_number(SerdReader* const reader,
push_node(reader, SERD_URI, XSD_INTEGER, sizeof(XSD_INTEGER) - 1);
}
+ if (*datatype) {
+ *flags |= SERD_HAS_DATATYPE;
+ }
+
return SERD_SUCCESS;
}
@@ -938,6 +943,7 @@ read_literal(SerdReader* const reader,
switch (peek_byte(reader)) {
case '@':
skip_byte(reader, '@');
+ *flags |= SERD_HAS_LANGUAGE;
if ((st = read_LANGTAG(reader, lang))) {
*datatype = pop_node(reader, *datatype);
*lang = pop_node(reader, *lang);
@@ -951,6 +957,7 @@ read_literal(SerdReader* const reader,
return r_err(reader, SERD_BAD_SYNTAX, "expected '^'\n");
}
+ *flags |= SERD_HAS_DATATYPE;
if ((st = read_iri(reader, datatype, ate_dot))) {
*datatype = pop_node(reader, *datatype);
*lang = pop_node(reader, *lang);
@@ -959,7 +966,6 @@ read_literal(SerdReader* const reader,
}
break;
}
-
return SERD_SUCCESS;
}
@@ -1076,7 +1082,7 @@ read_anon(SerdReader* const reader,
// Emit statement with this anonymous object first
SerdStatus st = SERD_SUCCESS;
if (ctx.subject) {
- TRY(st, emit_statement(reader, ctx, *dest, 0, 0));
+ TRY(st, emit_statement(reader, ctx, *dest));
}
// Switch the subject to the anonymous node and read its description
@@ -1086,19 +1092,16 @@ read_anon(SerdReader* const reader,
if (!subject) {
*ctx.flags |= SERD_ANON_CONT;
}
-
bool ate_dot_in_list = false;
TRY_FAILING(st, read_predicateObjectList(reader, ctx, &ate_dot_in_list));
if (ate_dot_in_list) {
return r_err(reader, SERD_BAD_SYNTAX, "'.' inside blank\n");
}
-
read_ws_star(reader);
if (reader->end_func) {
reader->end_func(reader->handle, deref(reader, *dest));
}
-
*ctx.flags = old_flags;
}
@@ -1175,7 +1178,7 @@ read_object(SerdReader* const reader,
case '7':
case '8':
case '9':
- st = read_number(reader, &o, &datatype, ate_dot);
+ st = read_number(reader, &o, &datatype, &flags, ate_dot);
break;
case '\"':
case '\'':
@@ -1191,6 +1194,7 @@ read_object(SerdReader* const reader,
node = deref(reader, o);
if ((node->length == 4 && !memcmp(serd_node_string(node), "true", 4)) ||
(node->length == 5 && !memcmp(serd_node_string(node), "false", 5))) {
+ flags = flags | SERD_HAS_DATATYPE;
node->type = SERD_LITERAL;
datatype = push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN);
st = SERD_SUCCESS;
@@ -1210,7 +1214,7 @@ read_object(SerdReader* const reader,
}
if (!st && emit && simple) {
- st = emit_statement(reader, *ctx, o, datatype, lang);
+ st = emit_statement(reader, *ctx, o);
} else if (!st && !emit) {
ctx->object = o;
ctx->datatype = datatype;
@@ -1305,6 +1309,7 @@ static SerdStatus
read_collection(SerdReader* const reader, ReadContext ctx, Ref* const dest)
{
SerdStatus st = SERD_SUCCESS;
+
skip_byte(reader, '(');
bool end = peek_delim(reader, ')');
@@ -1312,7 +1317,7 @@ read_collection(SerdReader* const reader, ReadContext ctx, Ref* const dest)
*dest = end ? reader->rdf_nil : blank_id(reader);
if (ctx.subject) { // Reading a collection object
*ctx.flags |= (end ? 0 : SERD_LIST_O_BEGIN);
- TRY(st, emit_statement(reader, ctx, *dest, 0, 0));
+ TRY(st, emit_statement(reader, ctx, *dest));
*ctx.flags &= SERD_LIST_O_BEGIN;
*ctx.flags |= SERD_LIST_CONT;
} else { // Reading a collection subject
@@ -1352,7 +1357,7 @@ read_collection(SerdReader* const reader, ReadContext ctx, Ref* const dest)
// _:node rdf:rest _:rest
*ctx.flags |= SERD_LIST_CONT;
ctx.predicate = reader->rdf_rest;
- TRY(st, emit_statement(reader, ctx, (end ? reader->rdf_nil : rest), 0, 0));
+ TRY(st, emit_statement(reader, ctx, (end ? reader->rdf_nil : rest)));
ctx.subject = rest; // _:node = _:rest
rest = node; // _:rest = (old)_:node
@@ -1745,7 +1750,7 @@ read_nquads_statement(SerdReader* const reader)
}
}
- TRY(st, emit_statement(reader, ctx, ctx.object, ctx.datatype, ctx.lang));
+ TRY(st, emit_statement(reader, ctx, ctx.object));
pop_node(reader, ctx.graph);
pop_node(reader, ctx.lang);