Parse error when parsing TTL namespaced URI starting with a digit #1

Closed
opened 2025-12-23 16:46:03 +00:00 by scossu · 0 comments
Owner

When decoding TTL input that contains a namespaced URI, and the data part (after the colon) starts with a digit, the parser throws an error.

To reproduce:

#include "volksdata.h"

const char *rdf = "@prefix ns: <urn:ns1#> .\n <urn:s:1> ns:prop ns:34 .";
const VOLK_Codec *codec = &ttl_codec;

int main() {
    VOLK_init();
    VOLK_Graph *gr;
    size_t ct = 0;
    char *err = NULL;
    VOLK_rc rc = codec->decode_graph (NULL, rdf, &gr, &ct, &err);

    printf ("RC: %d\n", rc);
    printf ("Triples parsed: %d\n", ct);
    printf ("Error: %s\n", err);

    if (rc == VOLK_OK) VOLK_graph_free (gr);
    free (err);

    return 0;
}

Execute:

$ gcc t1.c -o t1.o -lvolksdata
$ ./t1.o 
11:46:50 INFO  src/environment.c:93: Volksdata environment initialized.
11:46:50 ERROR grammar_ttl.y:23: TTL parse error. Cannot continue.
11:46:50 INFO  lexer_ttl.re:367: Parsed 0 triples.
RC: -88898
Triples parsed: 0
Error: (null)

If ns:34 is replaced by ns:a34, the graph is parsed correctly.

When decoding TTL input that contains a namespaced URI, and the data part (after the colon) starts with a digit, the parser throws an error. To reproduce: ```c #include "volksdata.h" const char *rdf = "@prefix ns: <urn:ns1#> .\n <urn:s:1> ns:prop ns:34 ."; const VOLK_Codec *codec = &ttl_codec; int main() { VOLK_init(); VOLK_Graph *gr; size_t ct = 0; char *err = NULL; VOLK_rc rc = codec->decode_graph (NULL, rdf, &gr, &ct, &err); printf ("RC: %d\n", rc); printf ("Triples parsed: %d\n", ct); printf ("Error: %s\n", err); if (rc == VOLK_OK) VOLK_graph_free (gr); free (err); return 0; } ``` Execute: ```bash $ gcc t1.c -o t1.o -lvolksdata $ ./t1.o 11:46:50 INFO src/environment.c:93: Volksdata environment initialized. 11:46:50 ERROR grammar_ttl.y:23: TTL parse error. Cannot continue. 11:46:50 INFO lexer_ttl.re:367: Parsed 0 triples. RC: -88898 Triples parsed: 0 Error: (null) ``` If `ns:34` is replaced by `ns:a34`, the graph is parsed correctly.
scossu self-assigned this 2025-12-23 16:48:03 +00:00
scossu referenced this issue from a commit 2025-12-23 16:53:03 +00:00
scossu changed title from Parse error + segfault when parsing TTL namespaced URI starting with a digit to Parse error when parsing TTL namespaced URI starting with a digit 2025-12-24 04:14:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
scossu/volksdata#1
No description provided.