Skip to content

Commit 211bf07

Browse files
committed
fix: dont interpret }| as {|
1 parent 8ce8428 commit 211bf07

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/N3Lexer.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,19 @@ export default class N3Lexer {
294294
case '!':
295295
if (!this._n3Mode)
296296
break;
297+
case '{':
298+
// Note the input[0] === '{' is required as this could be a fall-through from the above case
299+
if (input.length > 1 && input[0] === '{' && input[1] === '|') {
300+
type = '{|', matchLength = 2;
301+
break;
302+
}
297303
case ',':
298304
case ';':
299305
case '[':
300306
case ']':
301307
case '(':
302308
case ')':
303-
case '{':
304309
case '}':
305-
if (input.length > 1 && input[1] === '|') {
306-
type = '{|', matchLength = 2;
307-
break;
308-
}
309310
if (
310311
!this._lineMode &&
311312
// The token might actually be {| and we just have not encountered the pipe yet

test/N3Parser-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,12 @@ describe('Parser', () => {
12531253
['a', 'b', 'c'],
12541254
[['a', 'b', 'c'], 'd', 'e']));
12551255

1256+
it('should not parse }|',
1257+
shouldNotParse('<a> <b> <c> }| <d> <e> |} .', 'Unexpected graph closing on line 1.'));
1258+
1259+
it('should not parse |{',
1260+
shouldNotParse('<a> <b> <c> {| <d> <e> |{ .', 'Unexpected "|{" on line 1.'));
1261+
12561262
it('should parse an explicit triple with reified annotation that is chunked at the pipe',
12571263
shouldParseChunks(['<a> <b> <c> {| <d> <e> |', '} .'],
12581264
['a', 'b', 'c'],

0 commit comments

Comments
 (0)