diff --git a/lib/Parser/Turtle.php b/lib/Parser/Turtle.php index 1368d396..ad414edd 100644 --- a/lib/Parser/Turtle.php +++ b/lib/Parser/Turtle.php @@ -948,7 +948,10 @@ protected function parseQNameOrBoolean() // Last char of name must not be a dot if (mb_substr($localName, -1) === '.') { - throw new Exception("Turtle Parse Error: last character of QName must not be a dot", $this->line, $this->column - 1); + $localName = substr_replace($localName, '', -1); + $this->unread($c); // step back + $this->unread('.'); // return dot to input buffer + $c = $this->read(); // read, because below the unread($c) is done for all cases } } diff --git a/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.out b/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.out index f1bee29f..521cb92c 100644 --- a/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.out +++ b/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.out @@ -1,2 +1,3 @@ . . + . diff --git a/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.ttl b/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.ttl index 502bc150..512979b3 100644 --- a/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.ttl +++ b/test/fixtures/turtle/gh51-sweetrdf-dot-in-name.ttl @@ -5,3 +5,6 @@ # See https://github.com/sweetrdf/easyrdf/issues/51 :Subject.WithADot :predicate.withADot :Object.WithADot . :Subject.With.Dots :predicate.with.dots :Object.With.Dots . + +# A dot as last char is not part of the name but parsed as statement ending +:sub :pred :Object.WithADot. diff --git a/tests/EasyRdf/Parser/TurtleTest.php b/tests/EasyRdf/Parser/TurtleTest.php index ffbcf7c1..d7799f79 100644 --- a/tests/EasyRdf/Parser/TurtleTest.php +++ b/tests/EasyRdf/Parser/TurtleTest.php @@ -594,7 +594,7 @@ public function testIssue51Bad() // Test long literals with missing end $this->expectException('EasyRdf\Parser\Exception'); $this->expectExceptionMessage( - 'Turtle Parse Error: last character of QName must not be a dot on line 7, column 20' + 'Turtle Parse Error: Illegal predicate type: literal on line 7, column 19' ); $this->parseTurtle('turtle/gh51-sweetrdf-dot-in-name-bad.ttl'); }