aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-10 12:16:54 +0100
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commit233dc12e44eea2ebd967b5fc9fbfe8f1b153adf6 (patch)
tree802cabc8e6088d65787e06087b2c0d43c1090036
parente03e9fb1cf398aacb38e2364f43512a71e885138 (diff)
downloadserd-233dc12e44eea2ebd967b5fc9fbfe8f1b153adf6.tar.gz
serd-233dc12e44eea2ebd967b5fc9fbfe8f1b153adf6.tar.bz2
serd-233dc12e44eea2ebd967b5fc9fbfe8f1b153adf6.zip
Support reading lone lists in lax mode
This allows parsing documents like "(42) ."
-rw-r--r--src/n3.c2
-rw-r--r--test/extra/lax/manifest.ttl7
-rw-r--r--test/extra/lax/test-lone-list.nt2
-rw-r--r--test/extra/lax/test-lone-list.ttl1
4 files changed, 11 insertions, 1 deletions
diff --git a/src/n3.c b/src/n3.c
index dab83b12..006d28ba 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1649,7 +1649,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_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 <test-bad-utf8.ttl> ;
mf:name "test-bad-utf8" ;
mf:result <test-bad-utf8.nt> .
+
+<#test-lone-list>
+ a rdft:TestTurtleNegativeSyntax ;
+ mf:name "test-lone-list" ;
+ mf:action <test-lone-list.ttl> ;
+ mf:result <test-lone-list.nt> .
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 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "42"^^<http://www.w3.org/2001/XMLSchema#integer> .
+_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
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) .