diff options
-rw-r--r-- | src/n3.c | 55 | ||||
-rw-r--r-- | src/reader.h | 2 |
2 files changed, 25 insertions, 32 deletions
@@ -819,7 +819,6 @@ read_0_9(SerdReader* reader, SerdNode* str, bool at_least_one) static SerdStatus read_number(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, SerdNodeFlags* flags, bool* ate_dot) { @@ -875,16 +874,13 @@ read_number(SerdReader* reader, break; } TRY(st, read_0_9(reader, *dest, true)); - *datatype = push_node(reader, SERD_URI, XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); + push_node(reader, SERD_URI, XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); + *flags |= SERD_HAS_DATATYPE; } else if (has_decimal) { - *datatype = - push_node(reader, SERD_URI, XSD_DECIMAL, sizeof(XSD_DECIMAL) - 1); + push_node(reader, SERD_URI, XSD_DECIMAL, sizeof(XSD_DECIMAL) - 1); + *flags |= SERD_HAS_DATATYPE; } else { - *datatype = - push_node(reader, SERD_URI, XSD_INTEGER, sizeof(XSD_INTEGER) - 1); - } - - if (*datatype) { + push_node(reader, SERD_URI, XSD_INTEGER, sizeof(XSD_INTEGER) - 1); *flags |= SERD_HAS_DATATYPE; } @@ -908,8 +904,6 @@ read_iri(SerdReader* reader, SerdNode** dest, bool* ate_dot) static SerdStatus read_literal(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, - SerdNode** lang, SerdNodeFlags* flags, bool* ate_dot) { @@ -921,11 +915,13 @@ read_literal(SerdReader* reader, return st; } + SerdNode* datatype = NULL; + SerdNode* lang = NULL; switch (peek_byte(reader)) { case '@': eat_byte_safe(reader, '@'); *flags |= SERD_HAS_LANGUAGE; - if ((st = read_LANGTAG(reader, lang))) { + if ((st = read_LANGTAG(reader, &lang))) { return r_err(reader, st, "bad literal\n"); } break; @@ -933,7 +929,7 @@ read_literal(SerdReader* reader, eat_byte_safe(reader, '^'); eat_byte_check(reader, '^'); *flags |= SERD_HAS_DATATYPE; - if ((st = read_iri(reader, datatype, ate_dot))) { + if ((st = read_iri(reader, &datatype, ate_dot))) { return r_err(reader, st, "bad literal\n"); } break; @@ -1099,12 +1095,10 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) SerdStatus ret = SERD_FAILURE; - bool simple = (ctx->subject != 0); - SerdNode* o = 0; - SerdNode* datatype = 0; - SerdNode* lang = 0; - uint32_t flags = 0; - const int c = peek_byte(reader); + bool simple = (ctx->subject != 0); + SerdNode* o = 0; + uint32_t flags = 0; + const int c = peek_byte(reader); if (!fancy_syntax(reader)) { switch (c) { case '"': @@ -1148,11 +1142,11 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) case '7': case '8': case '9': - ret = read_number(reader, &o, &datatype, &flags, ate_dot); + ret = read_number(reader, &o, &flags, ate_dot); break; case '\"': case '\'': - ret = read_literal(reader, &o, &datatype, &lang, &flags, ate_dot); + ret = read_literal(reader, &o, &flags, ate_dot); break; default: /* Either a boolean literal, or a qname. Read the prefix first, and if @@ -1166,10 +1160,10 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) } if ((o->n_bytes == 4 && !memcmp(serd_node_string(o), "true", 4)) || (o->n_bytes == 5 && !memcmp(serd_node_string(o), "false", 5))) { - flags = flags | SERD_HAS_DATATYPE; - o->type = SERD_LITERAL; - datatype = push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN); - ret = SERD_SUCCESS; + flags = flags | SERD_HAS_DATATYPE; + o->type = SERD_LITERAL; + push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN); + ret = SERD_SUCCESS; } else if (read_PN_PREFIX_tail(reader, o) > SERD_FAILURE) { ret = SERD_ERR_BAD_SYNTAX; } else { @@ -1187,9 +1181,7 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) if (!ret && emit && simple) { ret = emit_statement(reader, *ctx, o); } else if (!ret && !emit) { - ctx->object = o; - ctx->datatype = datatype; - ctx->lang = lang; + ctx->object = o; return SERD_SUCCESS; } @@ -1545,7 +1537,7 @@ SerdStatus read_n3_statement(SerdReader* reader) { SerdStatementFlags flags = 0; - ReadContext ctx = {0, 0, 0, 0, 0, 0, &flags}; + ReadContext ctx = {0, 0, 0, 0, &flags}; bool ate_dot = false; int s_type = 0; SerdStatus st = SERD_SUCCESS; @@ -1638,10 +1630,12 @@ read_turtleTrigDoc(SerdReader* reader) serd_stack_pop_to(&reader->stack, orig_stack_size); return st; } + skip_until(reader, '\n'); } serd_stack_pop_to(&reader->stack, orig_stack_size); } + return SERD_SUCCESS; } @@ -1653,7 +1647,7 @@ read_nquadsDoc(SerdReader* reader) const size_t orig_stack_size = reader->stack.size; SerdStatementFlags flags = 0; - ReadContext ctx = {0, 0, 0, 0, 0, 0, &flags}; + ReadContext ctx = {0, 0, 0, 0, &flags}; bool ate_dot = false; int s_type = 0; read_ws_star(reader); @@ -1698,5 +1692,6 @@ read_nquadsDoc(SerdReader* reader) serd_stack_pop_to(&reader->stack, orig_stack_size); } + return SERD_SUCCESS; } diff --git a/src/reader.h b/src/reader.h index 0aebce81..4810c8f4 100644 --- a/src/reader.h +++ b/src/reader.h @@ -46,8 +46,6 @@ typedef struct { SerdNode* subject; SerdNode* predicate; SerdNode* object; - SerdNode* datatype; - SerdNode* lang; SerdStatementFlags* flags; } ReadContext; |