Skip to content

Commit

Permalink
Parse a without whitespace.
Browse files Browse the repository at this point in the history
Fixes #169.
  • Loading branch information
RubenVerborgh committed Mar 25, 2019
1 parent b3e8d7c commit e993d2a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/N3Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class N3Lexer {
this._boolean = /^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<])/;
this._keyword = /^@[a-z]+(?=[\s#<:])/i;
this._sparqlKeyword = /^(?:PREFIX|BASE|GRAPH)(?=[\s#<])/i;
this._shortPredicates = /^a(?=\s+|<)/;
this._shortPredicates = /^a(?=[\s()\[\]\{\}"'<])/;
this._newline = /^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/;
this._comment = /#([^\n\r]*)/;
this._whitespace = /^[ \t]+/;
Expand Down
35 changes: 35 additions & 0 deletions test/N3Lexer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,41 @@ describe('N3Lexer', function () {
{ type: '.', line: 1 },
{ type: 'eof', line: 1 }));

it('should tokenize the "a" predicate without spacing',
shouldTokenize('[a<>].\n[a[]].\n[a()].\n<>a<>.\n<>a[].\n<>a().\n',
{ type: '[', line: 1 },
{ type: 'abbreviation', value: 'a', line: 1 },
{ type: 'IRI', line: 1 },
{ type: ']', line: 1 },
{ type: '.', line: 1 },
{ type: '[', line: 2 },
{ type: 'abbreviation', value: 'a', line: 2 },
{ type: '[', line: 2 },
{ type: ']', line: 2 },
{ type: ']', line: 2 },
{ type: '.', line: 2 },
{ type: '[', line: 3 },
{ type: 'abbreviation', value: 'a', line: 3 },
{ type: '(', line: 3 },
{ type: ')', line: 3 },
{ type: ']', line: 3 },
{ type: '.', line: 3 },
{ type: 'IRI', line: 4 },
{ type: 'abbreviation', value: 'a', line: 4 },
{ type: 'IRI', line: 4 },
{ type: '.', line: 4 },
{ type: 'IRI', line: 5 },
{ type: 'abbreviation', value: 'a', line: 5 },
{ type: '[', line: 5 },
{ type: ']', line: 5 },
{ type: '.', line: 5 },
{ type: 'IRI', line: 6 },
{ type: 'abbreviation', value: 'a', line: 6 },
{ type: '(', line: 6 },
{ type: ')', line: 6 },
{ type: '.', line: 6 },
{ type: 'eof', line: 7 }));

it('should tokenize an empty default graph',
shouldTokenize('{}',
{ type: '{', line: 1 },
Expand Down

0 comments on commit e993d2a

Please sign in to comment.