Comparing version 0.6.0 to 0.6.1
@@ -303,3 +303,3 @@ // **N3Lexer** tokenizes N3 documents. | ||
this._input = null; | ||
return new Error('Syntax error: unexpected "' + issue + '" on line ' + this._line + '.'); | ||
return new Error('Unexpected "' + issue + '" on line ' + this._line + '.'); | ||
}, | ||
@@ -306,0 +306,0 @@ |
@@ -61,7 +61,10 @@ // **N3Parser** parses N3 documents. | ||
if (!baseIRI) | ||
baseIRI = null; | ||
else if (baseIRI.indexOf('#') >= 0) | ||
throw new Error('Invalid base IRI ' + baseIRI); | ||
// Set base IRI and its components | ||
if (this._base = baseIRI) { | ||
this._base = null; | ||
else { | ||
// Remove fragment if present | ||
var fragmentPos = baseIRI.indexOf('#'); | ||
if (fragmentPos >= 0) | ||
baseIRI = baseIRI.substr(0, fragmentPos); | ||
// Set base IRI and its components | ||
this._base = baseIRI; | ||
this._basePath = baseIRI.replace(/[^\/?]*(?:\?.*)?$/, ''); | ||
@@ -518,7 +521,4 @@ baseIRI = baseIRI.match(schemeAuthority); | ||
return this._error('Expected IRI to follow base declaration', token); | ||
try { | ||
this._setBase(this._base === null || | ||
absoluteIRI.test(token.value) ? token.value : this._resolveIRI(token)); | ||
} | ||
catch (error) { this._error(error.message, token); } | ||
this._setBase(this._base === null || absoluteIRI.test(token.value) ? | ||
token.value : this._resolveIRI(token)); | ||
return this._readDeclarationPunctuation; | ||
@@ -575,3 +575,3 @@ }, | ||
_error: function (message, token) { | ||
this._callback(new Error(message + ' at line ' + token.line + '.')); | ||
this._callback(new Error(message + ' on line ' + token.line + '.')); | ||
}, | ||
@@ -578,0 +578,0 @@ |
{ | ||
"name": "n3", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.", | ||
@@ -19,14 +19,14 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>", | ||
"devDependencies": { | ||
"async": "~0.9.0", | ||
"browserify": "~3.x", | ||
"chai": "~1.4.2", | ||
"chai-things": "~0.1.1", | ||
"colors": "~0.6.0", | ||
"docco": "~0.6.2", | ||
"eslint": "~1.2.1", | ||
"istanbul": "~0.3.0", | ||
"mocha": "~2.3.0", | ||
"pre-commit": "~0.0.9", | ||
"request": "~2.22.0", | ||
"uglify-js": "~2.4.3" | ||
"async": "^2.0.1", | ||
"browserify": "^13.1.0", | ||
"chai": "^3.5.0", | ||
"chai-things": "^0.2.0", | ||
"colors": "^1.1.2", | ||
"docco": "^0.7.0", | ||
"eslint": "^3.4.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.0.2", | ||
"pre-commit": "^1.1.3", | ||
"request": "^2.74.0", | ||
"uglify-js": "^2.7.3" | ||
}, | ||
@@ -37,3 +37,3 @@ "scripts": { | ||
"browser": "node browser/build-browser-versions", | ||
"coverage": "istanbul cover node_modules/.bin/_mocha -- -R spec --timeout 100", | ||
"coverage": "istanbul cover node_modules/.bin/_mocha -- -R spec --timeout 1000", | ||
"spec": "node spec/turtle-spec && node spec/trig-spec && node spec/ntriples-spec && node spec/nquads-spec", | ||
@@ -40,0 +40,0 @@ "spec-clean": "rm -r spec/turtle spec/trig", |
@@ -52,19 +52,19 @@ var N3Lexer = require('../N3').Lexer; | ||
shouldNotTokenize('<http://ex.org/bla"foo>', | ||
'Syntax error: unexpected "<http://ex.org/bla"foo>" on line 1.')); | ||
'Unexpected "<http://ex.org/bla"foo>" on line 1.')); | ||
it('should not tokenize an IRI with escaped characters', | ||
shouldNotTokenize('<http://ex.org/bla\\"foo>', | ||
'Syntax error: unexpected "<http://ex.org/bla\\"foo>" on line 1.')); | ||
'Unexpected "<http://ex.org/bla\\"foo>" on line 1.')); | ||
it('should not tokenize an IRI with disallowed escaped characters', | ||
shouldNotTokenize('<http://ex.org/bla\\u0020foo>', | ||
'Syntax error: unexpected "<http://ex.org/bla\\u0020foo>" on line 1.')); | ||
'Unexpected "<http://ex.org/bla\\u0020foo>" on line 1.')); | ||
it('should not tokenize an IRI with invalid 4-digit unicode escapes', | ||
shouldNotTokenize('<http://ex.org/bla\\uXYZZfoo>', | ||
'Syntax error: unexpected "<http://ex.org/bla\\uXYZZfoo>" on line 1.')); | ||
'Unexpected "<http://ex.org/bla\\uXYZZfoo>" on line 1.')); | ||
it('should not tokenize an IRI with invalid 8-digit unicode escapes', | ||
shouldNotTokenize('<http://ex.org/bla\\uXYZZxyzzfoo>', | ||
'Syntax error: unexpected "<http://ex.org/bla\\uXYZZxyzzfoo>" on line 1.')); | ||
'Unexpected "<http://ex.org/bla\\uXYZZxyzzfoo>" on line 1.')); | ||
@@ -79,3 +79,3 @@ it('should not tokenize an IRI with a non-numeric 4-digit unicode escapes', function (done) { | ||
error.should.be.an.instanceof(Error); | ||
error.message.should.equal('Syntax error: unexpected "<\\u1234>" on line 1.'); | ||
error.message.should.equal('Unexpected "<\\u1234>" on line 1.'); | ||
done(token); | ||
@@ -96,3 +96,3 @@ }); | ||
error.should.be.an.instanceof(Error); | ||
error.message.should.equal('Syntax error: unexpected "<\\U12345678>" on line 1.'); | ||
error.message.should.equal('Unexpected "<\\U12345678>" on line 1.'); | ||
done(token); | ||
@@ -183,27 +183,27 @@ }); | ||
shouldNotTokenize('ex:bla"foo', | ||
'Syntax error: unexpected ""foo" on line 1.')); | ||
'Unexpected ""foo" on line 1.')); | ||
it('should not tokenize a prefixed name with escaped characters', | ||
shouldNotTokenize('ex:bla\\"foo', | ||
'Syntax error: unexpected "ex:bla\\"foo" on line 1.')); | ||
'Unexpected "ex:bla\\"foo" on line 1.')); | ||
it('should not tokenize a prefixed name with disallowed escaped characters', | ||
shouldNotTokenize('ex:bla\\u0020foo', | ||
'Syntax error: unexpected "ex:bla\\u0020foo" on line 1.')); | ||
'Unexpected "ex:bla\\u0020foo" on line 1.')); | ||
it('should not tokenize a prefixed name with invalid 4-digit unicode escapes', | ||
shouldNotTokenize('ex:bla\\uXYZZfoo', | ||
'Syntax error: unexpected "ex:bla\\uXYZZfoo" on line 1.')); | ||
'Unexpected "ex:bla\\uXYZZfoo" on line 1.')); | ||
it('should not tokenize a prefixed name with invalid 8-digit unicode escapes', | ||
shouldNotTokenize('ex:bla\\uXYZZxyzzfoo', | ||
'Syntax error: unexpected "ex:bla\\uXYZZxyzzfoo" on line 1.')); | ||
'Unexpected "ex:bla\\uXYZZxyzzfoo" on line 1.')); | ||
it('should not tokenize a prefixed name with four-digit unicode escapes', | ||
shouldNotTokenize('ex:foo\\u0073bar', | ||
'Syntax error: unexpected "ex:foo\\u0073bar" on line 1.')); | ||
'Unexpected "ex:foo\\u0073bar" on line 1.')); | ||
it('should not tokenize a prefixed name with eight-digit unicode escapes', | ||
shouldNotTokenize('ex:foo\\U00000073\\U00A00073bar', | ||
'Syntax error: unexpected "ex:foo\\U00000073\\U00A00073bar" on line 1.')); | ||
'Unexpected "ex:foo\\U00000073\\U00A00073bar" on line 1.')); | ||
@@ -266,7 +266,7 @@ it('should tokenize two prefixed names separated by whitespace', | ||
shouldNotTokenize('"\\uXYZX" ', | ||
'Syntax error: unexpected ""\\uXYZX"" on line 1.')); | ||
'Unexpected ""\\uXYZX"" on line 1.')); | ||
it('should not tokenize a triple-quoted string with invalid characters', | ||
shouldNotTokenize('"""\\uXYZX""" ', | ||
'Syntax error: unexpected """"\\uXYZX"""" on line 1.')); | ||
'Unexpected """"\\uXYZX"""" on line 1.')); | ||
@@ -293,11 +293,11 @@ it('should tokenize a quoted string literal with language code', | ||
shouldNotTokenize('"stringA"^<type> "stringB"^^ns:mytype ', | ||
'Syntax error: unexpected "^<type>" on line 1.')); | ||
'Unexpected "^<type>" on line 1.')); | ||
it('should not tokenize a single hat', | ||
shouldNotTokenize('^', | ||
'Syntax error: unexpected "^" on line 1.')); | ||
'Unexpected "^" on line 1.')); | ||
it('should not tokenize a double hat followed by a non-IRI', | ||
shouldNotTokenize('^^1', | ||
'Syntax error: unexpected "1" on line 1.')); | ||
'Unexpected "1" on line 1.')); | ||
@@ -381,3 +381,3 @@ it('should tokenize a single-quoted string literal', | ||
shouldNotTokenize('10-10 ', | ||
'Syntax error: unexpected "10-10" on line 1.')); | ||
'Unexpected "10-10" on line 1.')); | ||
@@ -453,12 +453,12 @@ it('should tokenize booleans', | ||
it('should immediately signal an error if a linebreak occurs anywhere outside a triple-quoted literal', | ||
shouldNotTokenize(streamOf('abc\n', null), 'Syntax error: unexpected "abc" on line 1.')); | ||
shouldNotTokenize(streamOf('abc\n', null), 'Unexpected "abc" on line 1.')); | ||
it('should immediately signal an error if a linebreak occurs inside a single-quoted literal', | ||
shouldNotTokenize(streamOf('"abc\n', null), 'Syntax error: unexpected ""abc" on line 1.')); | ||
shouldNotTokenize(streamOf('"abc\n', null), 'Unexpected ""abc" on line 1.')); | ||
it('should immediately signal an error if a carriage return occurs anywhere outside a triple-quoted literal', | ||
shouldNotTokenize(streamOf('abc\r', null), 'Syntax error: unexpected "abc" on line 1.')); | ||
shouldNotTokenize(streamOf('abc\r', null), 'Unexpected "abc" on line 1.')); | ||
it('should immediately signal an error if a carriage return occurs inside a single-quoted literal', | ||
shouldNotTokenize(streamOf('"abc\r', null), 'Syntax error: unexpected ""abc" on line 1.')); | ||
shouldNotTokenize(streamOf('"abc\r', null), 'Unexpected ""abc" on line 1.')); | ||
@@ -484,3 +484,3 @@ it('should tokenize a split triple-quoted string', | ||
shouldNotTokenize('@prefix abc.: <def>.', | ||
'Syntax error: unexpected "abc.:" on line 1.')); | ||
'Unexpected "abc.:" on line 1.')); | ||
@@ -540,3 +540,3 @@ it('should tokenize @base declarations', | ||
shouldNotTokenize('_::', | ||
'Syntax error: unexpected "_::" on line 1.')); | ||
'Unexpected "_::" on line 1.')); | ||
@@ -652,3 +652,3 @@ it('should tokenize lists', | ||
it('should not tokenize an invalid document', | ||
shouldNotTokenize(' \n @!', 'Syntax error: unexpected "@!" on line 2.')); | ||
shouldNotTokenize(' \n @!', 'Unexpected "@!" on line 2.')); | ||
@@ -706,3 +706,3 @@ it('does not call setEncoding if not available', function () { | ||
(function () { lexer.tokenize('<a> bar'); }) | ||
.should.throw('Syntax error: unexpected "bar" on line 1.'); | ||
.should.throw('Unexpected "bar" on line 1.'); | ||
}); | ||
@@ -709,0 +709,0 @@ }); |
@@ -32,3 +32,3 @@ var N3StreamParser = require('../N3').StreamParser; | ||
it("doesn't parse an invalid stream", | ||
shouldNotParse(['z.'], 'Syntax error: unexpected "z." on line 1.')); | ||
shouldNotParse(['z.'], 'Unexpected "z." on line 1.')); | ||
@@ -35,0 +35,0 @@ it('emits "prefix" events', |
@@ -586,3 +586,3 @@ var N3Writer = require('../N3').Writer; | ||
}); | ||
}()); | ||
})(); | ||
}; | ||
@@ -589,0 +589,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
315765
5677