aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/n3.c15
-rw-r--r--tests/good/manifest.ttl7
-rw-r--r--tests/good/test-a-without-whitespace.nt6
-rw-r--r--tests/good/test-a-without-whitespace.ttl6
5 files changed, 23 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index aa9d74fa..eaa05124 100644
--- a/NEWS
+++ b/NEWS
@@ -5,9 +5,10 @@ serd (0.30.1) unstable;
* Fix colliding blank nodes when parsing TriG
* Fix missing parse error messages
* Fix parsing TriG graphs with several squashed trailing dots
+ * Fix parsing "a" abbreviation without padding whitespace
* Improve documentation
- -- David Robillard <d@drobilla.net> Sat, 30 Mar 2019 12:33:56 +0100
+ -- David Robillard <d@drobilla.net> Sat, 30 Mar 2019 12:57:54 +0100
serd (0.30.0) stable;
diff --git a/src/n3.c b/src/n3.c
index 5bd3052c..0037c829 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -801,18 +801,6 @@ except:
return r_err(reader, SERD_ERR_BAD_SYNTAX, "bad literal syntax\n");
}
-inline static bool
-is_token_end(uint8_t c)
-{
- switch (c) {
- case 0x9: case 0xA: case 0xD: case 0x20: case '\0':
- case '#': case '.': case ';': case '<':
- return true;
- default:
- return false;
- }
-}
-
static bool
read_verb(SerdReader* reader, Ref* dest)
{
@@ -827,8 +815,9 @@ read_verb(SerdReader* reader, Ref* dest)
const SerdStatus st = read_PN_PREFIX(reader, *dest);
bool ate_dot = false;
SerdNode* node = deref(reader, *dest);
+ const uint8_t next = peek_byte(reader);
if (!st && node->n_bytes == 1 && node->buf[0] == 'a' &&
- is_token_end(peek_byte(reader))) {
+ next != ':' && !is_PN_CHARS_BASE(next)) {
pop_node(reader, *dest);
return (*dest = push_node(reader, SERD_URI, NS_RDF "type", 47));
} else if (st > SERD_FAILURE ||
diff --git a/tests/good/manifest.ttl b/tests/good/manifest.ttl
index 25afdd5f..dd83a7e5 100644
--- a/tests/good/manifest.ttl
+++ b/tests/good/manifest.ttl
@@ -16,6 +16,7 @@
<#test-16>
<#test-18>
<#test-30>
+ <#test-a-without-whitespace>
<#test-backspace>
<#test-bad-utf8>
<#test-base-query>
@@ -96,6 +97,12 @@
mf:action <test-30.ttl> ;
mf:result <test-30.nt> .
+<#test-a-without-whitespace>
+ rdf:type rdft:TestTurtleEval ;
+ mf:name "test-a-without-whitespace" ;
+ mf:action <test-a-without-whitespace.ttl> ;
+ mf:result <test-a-without-whitespace.nt> .
+
<#test-backspace>
rdf:type rdft:TestTurtleEval ;
mf:name "test-backspace" ;
diff --git a/tests/good/test-a-without-whitespace.nt b/tests/good/test-a-without-whitespace.nt
new file mode 100644
index 00000000..27c5e7da
--- /dev/null
+++ b/tests/good/test-a-without-whitespace.nt
@@ -0,0 +1,6 @@
+_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/> .
+_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> _:b3 .
+_:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
+<http://example.org/s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Thing> .
+<http://example.org/s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> _:b5 .
+<http://example.org/s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
diff --git a/tests/good/test-a-without-whitespace.ttl b/tests/good/test-a-without-whitespace.ttl
new file mode 100644
index 00000000..2d6db000
--- /dev/null
+++ b/tests/good/test-a-without-whitespace.ttl
@@ -0,0 +1,6 @@
+[a<http://example.org/>].
+[a[]].
+[a()].
+<http://example.org/s>a<http://example.org/Thing>.
+<http://example.org/s>a[].
+<http://example.org/s>a().