From dc3aeed6ce84736100d713cac8f40e46d16d1289 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 Mar 2024 06:48:16 -0400 Subject: Support reading lone lists in lax mode This allows parsing documents like "(42) ." --- NEWS | 3 ++- src/n3.c | 2 +- test/extra/lax/manifest.ttl | 7 +++++++ test/extra/lax/test-lone-list.nt | 2 ++ test/extra/lax/test-lone-list.ttl | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/extra/lax/test-lone-list.nt create mode 100644 test/extra/lax/test-lone-list.ttl diff --git a/NEWS b/NEWS index 35754c88..8ca038a5 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,9 @@ serd (0.32.3) unstable; urgency=medium * Fix library current_version on MacOS * Fix parsing NQuads lines with no space before the final dot + * Support reading lone lists in lax mode - -- David Robillard Thu, 14 Mar 2024 16:43:17 +0000 + -- David Robillard Fri, 29 Mar 2024 10:48:45 +0000 serd (0.32.2) stable; urgency=medium diff --git a/src/n3.c b/src/n3.c index 662ea3f9..da3862db 100644 --- a/src/n3.c +++ b/src/n3.c @@ -1670,7 +1670,7 @@ read_n3_statement(SerdReader* const reader) return SERD_SUCCESS; } - if (ate_dot) { + if (ate_dot && (reader->strict || (s_type != '('))) { return r_err( reader, SERD_ERR_BAD_SYNTAX, "unexpected end of statement\n"); } diff --git a/test/extra/lax/manifest.ttl b/test/extra/lax/manifest.ttl index e2930a81..a04a74f6 100644 --- a/test/extra/lax/manifest.ttl +++ b/test/extra/lax/manifest.ttl @@ -9,6 +9,7 @@ <#test-bad-string> <#test-bad-uri> <#test-bad-utf8> + <#test-lone-list> ) . <#test-bad-string> @@ -28,3 +29,9 @@ mf:action ; mf:name "test-bad-utf8" ; mf:result . + +<#test-lone-list> + a rdft:TestTurtleNegativeSyntax ; + mf:name "test-lone-list" ; + mf:action ; + mf:result . diff --git a/test/extra/lax/test-lone-list.nt b/test/extra/lax/test-lone-list.nt new file mode 100644 index 00000000..400c2aba --- /dev/null +++ b/test/extra/lax/test-lone-list.nt @@ -0,0 +1,2 @@ +_:b1 "42"^^ . +_:b1 . diff --git a/test/extra/lax/test-lone-list.ttl b/test/extra/lax/test-lone-list.ttl new file mode 100644 index 00000000..e9c593b8 --- /dev/null +++ b/test/extra/lax/test-lone-list.ttl @@ -0,0 +1 @@ +(42) . -- cgit v1.2.1