diff options
author | David Robillard <d@drobilla.net> | 2018-05-13 00:47:58 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:04 +0200 |
commit | 540aa01afd60e68b751baaa47cd05729e023a527 (patch) | |
tree | c0b3caf0eed7b0f41d49f480acb80887282ff9fb /src | |
parent | 49fbf2a9a6549018ce9a640946597af32eb602d3 (diff) | |
download | serd-540aa01afd60e68b751baaa47cd05729e023a527.tar.gz serd-540aa01afd60e68b751baaa47cd05729e023a527.tar.bz2 serd-540aa01afd60e68b751baaa47cd05729e023a527.zip |
Remove datatype and language from reader context
Diffstat (limited to 'src')
-rw-r--r-- | src/n3.c | 45 | ||||
-rw-r--r-- | src/reader.h | 2 |
2 files changed, 17 insertions, 30 deletions
@@ -741,7 +741,6 @@ read_0_9(SerdReader* reader, SerdNode* str, bool at_least_one) static bool read_number(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, SerdNodeFlags* flags, bool* ate_dot) { @@ -793,14 +792,11 @@ read_number(SerdReader* reader, default: break; } TRY_THROW(read_0_9(reader, ref, true)); - *datatype = push_node(reader, SERD_URI, - XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); + push_node(reader, SERD_URI, XSD_DOUBLE, sizeof(XSD_DOUBLE) - 1); } 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); } else { - *datatype = push_node(reader, SERD_URI, - XSD_INTEGER, sizeof(XSD_INTEGER) - 1); + push_node(reader, SERD_URI, XSD_INTEGER, sizeof(XSD_INTEGER) - 1); } *flags |= SERD_HAS_DATATYPE; *dest = ref; @@ -827,8 +823,6 @@ read_iri(SerdReader* reader, SerdNode** dest, bool* ate_dot) static bool read_literal(SerdReader* reader, SerdNode** dest, - SerdNode** datatype, - SerdNode** lang, SerdNodeFlags* flags, bool* ate_dot) { @@ -837,24 +831,23 @@ read_literal(SerdReader* reader, return false; } + SerdNode* datatype = NULL; switch (peek_byte(reader)) { case '@': eat_byte_safe(reader, '@'); *flags |= SERD_HAS_LANGUAGE; - TRY_THROW(*lang = read_LANGTAG(reader)); + TRY_THROW(read_LANGTAG(reader)); break; case '^': eat_byte_safe(reader, '^'); eat_byte_check(reader, '^'); *flags |= SERD_HAS_DATATYPE; - TRY_THROW(read_iri(reader, datatype, ate_dot)); + TRY_THROW(read_iri(reader, &datatype, ate_dot)); break; } *dest = str; return true; except: - *datatype = NULL; - *lang = NULL; return r_err(reader, SERD_ERR_BAD_SYNTAX, "bad literal syntax\n"); } @@ -1015,13 +1008,11 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) const size_t orig_stack_size = reader->stack.size; - bool ret = false; - 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 ret = false; + 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 '"': case ':': case '<': case '_': break; @@ -1048,11 +1039,11 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) break; case '+': case '-': case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - TRY_THROW(ret = read_number(reader, &o, &datatype, &flags, ate_dot)); + TRY_THROW(ret = read_number(reader, &o, &flags, ate_dot)); break; case '\"': case '\'': - TRY_THROW(ret = read_literal(reader, &o, &datatype, &lang, &flags, ate_dot)); + TRY_THROW(ret = read_literal(reader, &o, &flags, ate_dot)); break; default: /* Either a boolean literal, or a qname. Read the prefix first, and if @@ -1066,8 +1057,8 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) !memcmp(serd_node_get_string(o), "false", 5))) { flags = flags | SERD_HAS_DATATYPE; o->type = SERD_LITERAL; - TRY_THROW(datatype = push_node( - reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN)); + TRY_THROW( + push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN)); ret = true; } else if (read_PN_PREFIX_tail(reader, o) > SERD_FAILURE) { ret = false; @@ -1086,8 +1077,6 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot) ret = emit_statement(reader, *ctx, o); } else if (ret && !emit) { ctx->object = o; - ctx->datatype = datatype; - ctx->lang = lang; return true; } @@ -1408,7 +1397,7 @@ bool read_n3_statement(SerdReader* reader) { SerdStatementFlags flags = 0; - ReadContext ctx = { 0, 0, 0, 0, 0, 0, &flags }; + ReadContext ctx = { 0, 0, 0, 0, &flags }; SerdNode* subj = 0; bool ate_dot = false; int s_type = 0; @@ -1505,7 +1494,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); diff --git a/src/reader.h b/src/reader.h index b9afc402..dd78d5c0 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; |