|
From: Richard C. <ri...@cy...> - 2006-02-26 21:01:19
|
Hi,
The N3 parser has a bug that causes broken triples in cases like this:
<foo>
:bar "bar";
:baz "baz";
.
The last statement (<foo> :baz "baz") is terminated by a semicolon
*and* a dot. This is legal in N3, and in fact quite common because
that way you can't mix up the end-of-line punctuation.
RAP's parser doesn't recognize this, sees a third triple with a null
predicate and object, and generates two notices.
Here's a test case for /test/unit/Syntax/n3Parser_test.php that
catches the bug:
function testLoneSemicolon() {
$n3 = '<a> <b> <c> ; .';
$parser = &new N3Parser();
$model = &$parser->parse2model($n3, false);
$this->assertEqual(1, $model->size());
$this->assertNoErrors();
}
Here's the fix for /api/syntax/N3Parser.php . I've added two lines to
the getPovs method, it's the comment line and the one after.
function getPovs($list) {
$povs = array();
while (in_array(';', $list)) {
$r=$this->posns($list,';');
$pos=array_slice($r,0,2);
$r = $this->getSpan($list, $pos[0], $pos[1]);
$pov=$r[0];
$list=$r[1];
// skip lone semicolons, e.g. "<a> <b> <c> ; ."
if (count($pov) == 1) continue;
$povs[]=array_slice($pov,1);
}
Best,
Richard
|