Skip to content

Commit a82c435

Browse files
committed
Parse "prefix", "base", and "graph" prefixes.
1 parent bce490a commit a82c435

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/N3Lexer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ N3Lexer.prototype = {
5959
_blank: /^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<]))/,
6060
_number: /^[\-+]?(?:\d+\.?\d*([eE](?:[\-\+])?\d+)|\d*\.?\d+)(?=[.,;:\s#()\[\]\{\}"'<])/,
6161
_boolean: /^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<])/,
62-
_keyword: /^@[a-z]+(?=[\s#<:])/i,
63-
_sparqlKeyword: /^(?:PREFIX|BASE|GRAPH)(?=[\s#<:])/i,
62+
_keyword: /^@[a-z]+(?=[\s#<])/i,
63+
_sparqlKeyword: /^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i,
6464
_shortPredicates: /^a(?=\s+|<)/,
6565
_newline: /^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/,
6666
_comment: /#([^\n\r]*)/,

test/N3Parser-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ describe('N3Parser', function () {
9191
':x a:a a:b.',
9292
['#x', 'a#a', 'a#b']));
9393

94+
it('should parse triples with the prefix "prefix"',
95+
shouldParse('@prefix prefix: <http://prefix.cc/>.' +
96+
'prefix:a prefix:b prefix:c.',
97+
['http://prefix.cc/a', 'http://prefix.cc/b', 'http://prefix.cc/c']));
98+
99+
it('should parse triples with the prefix "base"',
100+
shouldParse('PREFIX base: <http://prefix.cc/>' +
101+
'base:a base:b base:c.',
102+
['http://prefix.cc/a', 'http://prefix.cc/b', 'http://prefix.cc/c']));
103+
104+
it('should parse triples with the prefix "graph"',
105+
shouldParse('PREFIX graph: <http://prefix.cc/>' +
106+
'graph:a graph:b graph:c.',
107+
['http://prefix.cc/a', 'http://prefix.cc/b', 'http://prefix.cc/c']));
108+
94109
it('should not parse @PREFIX',
95110
shouldNotParse('@PREFIX : <#>.',
96111
'Expected entity but got @PREFIX on line 1.'));

0 commit comments

Comments
 (0)