rdflib 2.3.1 → 2.3.2-2bc27df4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/515.rdflib.min.js +1 -1
- package/dist/515.rdflib.min.js.LICENSE.txt +6 -2
- package/dist/515.rdflib.min.js.map +1 -1
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -9
- package/dist/rdflib.min.js.map +1 -1
- package/esm/factories/rdflib-data-factory.js +1 -3
- package/esm/fetcher.js +9 -15
- package/esm/formula.js +2 -11
- package/esm/parse.js +1 -3
- package/esm/serializer.js +7 -9
- package/esm/store.js +1 -2
- package/esm/update-manager.js +5 -10
- package/esm/utils.js +1 -2
- package/esm/variable.js +1 -2
- package/esm/xsd.js +1 -2
- package/lib/collection.d.ts +1 -1
- package/lib/factories/rdflib-data-factory.js +1 -3
- package/lib/fetcher.js +9 -15
- package/lib/formula.js +2 -11
- package/lib/index.d.ts +1 -1
- package/lib/parse.js +1 -3
- package/lib/rdfaparser.d.ts +9 -9
- package/lib/rdfxmlparser.d.ts +1 -1
- package/lib/serializer.d.ts +10 -11
- package/lib/serializer.js +7 -9
- package/lib/store.js +1 -2
- package/lib/update-manager.js +5 -10
- package/lib/utils.js +1 -2
- package/lib/variable.js +1 -2
- package/lib/xsd-internal.d.ts +7 -7
- package/lib/xsd.d.ts +7 -7
- package/lib/xsd.js +1 -2
- package/package.json +41 -36
- package/src/jsonldparser.js +2 -2
- package/src/n3parser.js +669 -669
- package/src/serializer.js +19 -20
- package/src/xsd-internal.js +1 -1
- package/src/xsd.js +4 -4
- package/dist/789.rdflib.min.js +0 -1
package/src/n3parser.js
CHANGED
|
@@ -9,79 +9,79 @@ import { ArrayIndexOf } from './utils'
|
|
|
9
9
|
import { convertFirstRestNil } from './lists'
|
|
10
10
|
|
|
11
11
|
function hexify (str) { // also used in parser
|
|
12
|
-
return encodeURI(str)
|
|
12
|
+
return encodeURI(str)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
var Utf8 = {
|
|
16
16
|
// public method for url encoding
|
|
17
17
|
encode : function (string) {
|
|
18
|
-
string = string.replace(/\r\n/g,"\n")
|
|
19
|
-
var utftext = ""
|
|
18
|
+
string = string.replace(/\r\n/g,"\n")
|
|
19
|
+
var utftext = ""
|
|
20
20
|
|
|
21
21
|
for (var n = 0; n < string.length; n++) {
|
|
22
22
|
|
|
23
|
-
var c = string.charCodeAt(n)
|
|
23
|
+
var c = string.charCodeAt(n)
|
|
24
24
|
|
|
25
25
|
if (c < 128) {
|
|
26
|
-
utftext += String.fromCharCode(c)
|
|
26
|
+
utftext += String.fromCharCode(c)
|
|
27
27
|
}
|
|
28
28
|
else if((c > 127) && (c < 2048)) {
|
|
29
|
-
utftext += String.fromCharCode((c >> 6) | 192)
|
|
30
|
-
utftext += String.fromCharCode((c & 63) | 128)
|
|
29
|
+
utftext += String.fromCharCode((c >> 6) | 192)
|
|
30
|
+
utftext += String.fromCharCode((c & 63) | 128)
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
utftext += String.fromCharCode((c >> 12) | 224)
|
|
34
|
-
utftext += String.fromCharCode(((c >> 6) & 63) | 128)
|
|
35
|
-
utftext += String.fromCharCode((c & 63) | 128)
|
|
33
|
+
utftext += String.fromCharCode((c >> 12) | 224)
|
|
34
|
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128)
|
|
35
|
+
utftext += String.fromCharCode((c & 63) | 128)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return utftext
|
|
40
|
+
return utftext
|
|
41
41
|
},
|
|
42
42
|
// public method for url decoding
|
|
43
43
|
decode : function (utftext) {
|
|
44
|
-
var string = ""
|
|
45
|
-
var i = 0
|
|
44
|
+
var string = ""
|
|
45
|
+
var i = 0
|
|
46
46
|
|
|
47
47
|
while ( i < utftext.length ) {
|
|
48
48
|
|
|
49
|
-
var c = utftext.charCodeAt(i)
|
|
49
|
+
var c = utftext.charCodeAt(i)
|
|
50
50
|
if (c < 128) {
|
|
51
|
-
string += String.fromCharCode(c)
|
|
52
|
-
i
|
|
51
|
+
string += String.fromCharCode(c)
|
|
52
|
+
i++
|
|
53
53
|
}
|
|
54
54
|
else if((c > 191) && (c < 224)) {
|
|
55
55
|
string += String.fromCharCode(((c & 31) << 6)
|
|
56
|
-
| (utftext.charCodeAt(i+1) & 63))
|
|
57
|
-
i += 2
|
|
56
|
+
| (utftext.charCodeAt(i+1) & 63))
|
|
57
|
+
i += 2
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
string += String.fromCharCode(((c & 15) << 12)
|
|
61
61
|
| ((utftext.charCodeAt(i+1) & 63) << 6)
|
|
62
|
-
| (utftext.charCodeAt(i+2) & 63))
|
|
63
|
-
i += 3
|
|
62
|
+
| (utftext.charCodeAt(i+2) & 63))
|
|
63
|
+
i += 3
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
return string
|
|
66
|
+
return string
|
|
67
67
|
}
|
|
68
68
|
}// Things we need to define to make converted pythn code work in js
|
|
69
69
|
// environment of $rdf
|
|
70
70
|
|
|
71
|
-
var RDFSink_forSomeSym = "http://www.w3.org/2000/10/swap/log#forSome"
|
|
72
|
-
var RDFSink_forAllSym = "http://www.w3.org/2000/10/swap/log#forAll"
|
|
73
|
-
var Logic_NS = "http://www.w3.org/2000/10/swap/log#"
|
|
71
|
+
var RDFSink_forSomeSym = "http://www.w3.org/2000/10/swap/log#forSome"
|
|
72
|
+
var RDFSink_forAllSym = "http://www.w3.org/2000/10/swap/log#forAll"
|
|
73
|
+
var Logic_NS = "http://www.w3.org/2000/10/swap/log#"
|
|
74
74
|
|
|
75
75
|
// pyjs seems to reference runtime library which I didn't find
|
|
76
76
|
|
|
77
|
-
var pyjslib_Tuple = function(theList) { return theList }
|
|
77
|
+
var pyjslib_Tuple = function(theList) { return theList }
|
|
78
78
|
|
|
79
|
-
var pyjslib_List = function(theList) { return theList }
|
|
79
|
+
var pyjslib_List = function(theList) { return theList }
|
|
80
80
|
|
|
81
81
|
var pyjslib_Dict = function(listOfPairs) {
|
|
82
82
|
if (listOfPairs.length > 0)
|
|
83
|
-
throw "missing.js: oops nnonempty dict not imp"
|
|
84
|
-
return []
|
|
83
|
+
throw "missing.js: oops nnonempty dict not imp"
|
|
84
|
+
return []
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
var pyjslib_len = function(s) { return s.length }
|
|
@@ -89,20 +89,20 @@ var pyjslib_len = function(s) { return s.length }
|
|
|
89
89
|
var pyjslib_slice = function(str, i, j) {
|
|
90
90
|
if (typeof str.slice == 'undefined')
|
|
91
91
|
throw '@@ mising.js: No .slice function for '+str+' of type '+(typeof str)
|
|
92
|
-
if ((typeof j == 'undefined') || (j ==null)) return str.slice(i)
|
|
92
|
+
if ((typeof j == 'undefined') || (j ==null)) return str.slice(i)
|
|
93
93
|
return str.slice(i, j) // @ exactly the same spec?
|
|
94
94
|
}
|
|
95
|
-
var StopIteration = Error('dummy error stop iteration')
|
|
95
|
+
var StopIteration = Error('dummy error stop iteration')
|
|
96
96
|
|
|
97
97
|
var pyjslib_Iterator = function(theList) {
|
|
98
|
-
this.last = 0
|
|
99
|
-
this.li = theList
|
|
98
|
+
this.last = 0
|
|
99
|
+
this.li = theList
|
|
100
100
|
this.next = function() {
|
|
101
|
-
if (this.last == this.li.length) throw StopIteration
|
|
102
|
-
return this.li[this.last++]
|
|
101
|
+
if (this.last == this.li.length) throw StopIteration
|
|
102
|
+
return this.li[this.last++]
|
|
103
103
|
}
|
|
104
|
-
return this
|
|
105
|
-
}
|
|
104
|
+
return this
|
|
105
|
+
}
|
|
106
106
|
|
|
107
107
|
var ord = function(str) {
|
|
108
108
|
return str.charCodeAt(0)
|
|
@@ -113,25 +113,25 @@ var string_find = function(str, s) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
var assertFudge = function(condition, desc) {
|
|
116
|
-
if (condition) return
|
|
117
|
-
if (desc) throw "python Assertion failed: "+desc
|
|
118
|
-
throw "(python) Assertion failed."
|
|
116
|
+
if (condition) return
|
|
117
|
+
if (desc) throw "python Assertion failed: "+desc
|
|
118
|
+
throw "(python) Assertion failed."
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
var stringFromCharCode = function(uesc) {
|
|
123
|
-
return String.fromCharCode(uesc)
|
|
123
|
+
return String.fromCharCode(uesc)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
String.prototype.encode = function(encoding) {
|
|
128
128
|
if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8"
|
|
129
|
-
return Utf8.encode(this)
|
|
129
|
+
return Utf8.encode(this)
|
|
130
130
|
}
|
|
131
131
|
String.prototype.decode = function(encoding) {
|
|
132
132
|
if (encoding != 'utf-8') throw "UTF8_converter: can only do utf-8"
|
|
133
133
|
//return Utf8.decode(this);
|
|
134
|
-
return this
|
|
134
|
+
return this
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
|
|
@@ -140,17 +140,17 @@ var uripath_join = function(base, given) {
|
|
|
140
140
|
return Uri.join(given, base) // sad but true
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
var becauseSubexpression = null
|
|
144
|
-
var diag_tracking = 0
|
|
145
|
-
var diag_chatty_flag = 0
|
|
143
|
+
var becauseSubexpression = null // No reason needed
|
|
144
|
+
var diag_tracking = 0
|
|
145
|
+
var diag_chatty_flag = 0
|
|
146
146
|
var diag_progress = function(str) { /*$rdf.log.debug(str);*/ }
|
|
147
147
|
|
|
148
148
|
// why_BecauseOfData = function(doc, reason) { return doc };
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
|
152
|
-
var RDF_nil_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
|
|
153
|
-
var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"
|
|
151
|
+
var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
|
|
152
|
+
var RDF_nil_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
|
|
153
|
+
var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs"
|
|
154
154
|
|
|
155
155
|
/*
|
|
156
156
|
function SyntaxError(details) {
|
|
@@ -192,139 +192,139 @@ the module, including tests and test harness.
|
|
|
192
192
|
|
|
193
193
|
*/
|
|
194
194
|
|
|
195
|
-
var ADDED_HASH = "#"
|
|
196
|
-
var LOG_implies_URI = "http://www.w3.org/2000/10/swap/log#implies"
|
|
197
|
-
var INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer"
|
|
198
|
-
var FLOAT_DATATYPE = "http://www.w3.org/2001/XMLSchema#double"
|
|
199
|
-
var DECIMAL_DATATYPE = "http://www.w3.org/2001/XMLSchema#decimal"
|
|
200
|
-
var DATE_DATATYPE = "http://www.w3.org/2001/XMLSchema#date"
|
|
201
|
-
var DATETIME_DATATYPE = "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
202
|
-
var BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean"
|
|
203
|
-
var option_noregen = 0
|
|
204
|
-
var _notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"
|
|
205
|
-
var _notNameChars = ( _notQNameChars + ":" )
|
|
206
|
-
var _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
207
|
-
var N3CommentCharacter = "#"
|
|
208
|
-
var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g')
|
|
209
|
-
var eof = new RegExp("^[ \\t]*(#[^\\n]*)?$", 'g')
|
|
210
|
-
var ws = new RegExp("^[ \\t]*", 'g')
|
|
211
|
-
var signed_integer = new RegExp("^[-+]?[0-9]+", 'g')
|
|
212
|
-
var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?", 'g')
|
|
213
|
-
var datetime_syntax = new RegExp('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?')
|
|
195
|
+
var ADDED_HASH = "#"
|
|
196
|
+
var LOG_implies_URI = "http://www.w3.org/2000/10/swap/log#implies"
|
|
197
|
+
var INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer"
|
|
198
|
+
var FLOAT_DATATYPE = "http://www.w3.org/2001/XMLSchema#double"
|
|
199
|
+
var DECIMAL_DATATYPE = "http://www.w3.org/2001/XMLSchema#decimal"
|
|
200
|
+
var DATE_DATATYPE = "http://www.w3.org/2001/XMLSchema#date"
|
|
201
|
+
var DATETIME_DATATYPE = "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
202
|
+
var BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean"
|
|
203
|
+
var option_noregen = 0
|
|
204
|
+
var _notQNameChars = "\t\r\n !\"#$%&'()*.,+/;<=>?@[\\]^`{|}~"
|
|
205
|
+
var _notNameChars = ( _notQNameChars + ":" )
|
|
206
|
+
var _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
207
|
+
var N3CommentCharacter = "#"
|
|
208
|
+
var eol = new RegExp("^[ \\t]*(#[^\\n]*)?\\r?\\n", 'g')
|
|
209
|
+
var eof = new RegExp("^[ \\t]*(#[^\\n]*)?$", 'g')
|
|
210
|
+
var ws = new RegExp("^[ \\t]*", 'g')
|
|
211
|
+
var signed_integer = new RegExp("^[-+]?[0-9]+", 'g')
|
|
212
|
+
var number_syntax = new RegExp("^([-+]?[0-9]+)(\\.[0-9]+)?([eE][-+]?[0-9]+)?", 'g')
|
|
213
|
+
var datetime_syntax = new RegExp('^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](T[0-9][0-9]:[0-9][0-9](:[0-9][0-9](\\.[0-9]*)?)?)?Z?')
|
|
214
214
|
|
|
215
215
|
// Reused in tight loops to detect whitespace or comment after a dot
|
|
216
|
-
var wsOrHash = new RegExp("[\\s#]")
|
|
216
|
+
var wsOrHash = new RegExp("[\\s#]")
|
|
217
217
|
|
|
218
|
-
var digitstring = new RegExp("^[0-9]+", 'g')
|
|
219
|
-
var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g')
|
|
220
|
-
var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*", 'g')
|
|
218
|
+
var digitstring = new RegExp("^[0-9]+", 'g')
|
|
219
|
+
var interesting = new RegExp("[\\\\\\r\\n\\\"]", 'g')
|
|
220
|
+
var langcode = new RegExp("^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*", 'g')
|
|
221
221
|
|
|
222
222
|
// Returns true when a dot at position i should terminate a name,
|
|
223
223
|
// i.e., when the next character is whitespace, a comment start, or EOF
|
|
224
224
|
function dotTerminatesName(str, i) {
|
|
225
|
-
var next = str.charAt(i + 1)
|
|
226
|
-
return next === '' || wsOrHash.test(next)
|
|
225
|
+
var next = str.charAt(i + 1)
|
|
226
|
+
return next === '' || wsOrHash.test(next)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
function createSinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
|
|
230
|
-
return new SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why)
|
|
230
|
+
return new SinkParser(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why)
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
export default createSinkParser
|
|
233
|
+
export default createSinkParser
|
|
234
234
|
|
|
235
235
|
export class SinkParser {
|
|
236
236
|
constructor(store, openFormula, thisDoc, baseURI, genPrefix, metaURI, flags, why) {
|
|
237
|
-
if (typeof openFormula == 'undefined') openFormula=null
|
|
238
|
-
if (typeof thisDoc == 'undefined') thisDoc=""
|
|
239
|
-
if (typeof baseURI == 'undefined') baseURI=null
|
|
240
|
-
if (typeof genPrefix == 'undefined') genPrefix=""
|
|
241
|
-
if (typeof metaURI == 'undefined') metaURI=null
|
|
242
|
-
if (typeof flags == 'undefined') flags=""
|
|
243
|
-
if (typeof why == 'undefined') why=null
|
|
237
|
+
if (typeof openFormula == 'undefined') openFormula=null
|
|
238
|
+
if (typeof thisDoc == 'undefined') thisDoc=""
|
|
239
|
+
if (typeof baseURI == 'undefined') baseURI=null
|
|
240
|
+
if (typeof genPrefix == 'undefined') genPrefix=""
|
|
241
|
+
if (typeof metaURI == 'undefined') metaURI=null
|
|
242
|
+
if (typeof flags == 'undefined') flags=""
|
|
243
|
+
if (typeof why == 'undefined') why=null
|
|
244
244
|
/*
|
|
245
245
|
note: namespace names should *not* end in #;
|
|
246
246
|
the # will get added during qname processing */
|
|
247
247
|
|
|
248
|
-
this._bindings = new pyjslib_Dict([])
|
|
249
|
-
this._flags = flags
|
|
248
|
+
this._bindings = new pyjslib_Dict([])
|
|
249
|
+
this._flags = flags
|
|
250
250
|
if ((thisDoc != "")) {
|
|
251
|
-
assertFudge((thisDoc.indexOf(":") >= 0), ( "Document URI not absolute: " + thisDoc ) )
|
|
252
|
-
this._bindings[""] = ( ( thisDoc + "#" ) )
|
|
251
|
+
assertFudge((thisDoc.indexOf(":") >= 0), ( "Document URI not absolute: " + thisDoc ) )
|
|
252
|
+
this._bindings[""] = ( ( thisDoc + "#" ) )
|
|
253
253
|
}
|
|
254
|
-
this._store = store
|
|
254
|
+
this._store = store
|
|
255
255
|
if (genPrefix) {
|
|
256
|
-
store.setGenPrefix(genPrefix)
|
|
257
|
-
}
|
|
258
|
-
this._thisDoc = thisDoc
|
|
259
|
-
this.source = store.sym(thisDoc)
|
|
260
|
-
this.lines = 0
|
|
261
|
-
this.statementCount = 0
|
|
262
|
-
this.hasNil = false
|
|
263
|
-
this.startOfLine = 0
|
|
264
|
-
this.previousLine = 0
|
|
265
|
-
this._genPrefix = genPrefix
|
|
266
|
-
this.keywords = new pyjslib_List(["a", "this", "bind", "has", "is", "of", "true", "false"])
|
|
267
|
-
this.keywordsSet = 0
|
|
268
|
-
this._anonymousNodes = new pyjslib_Dict([])
|
|
269
|
-
this._variables = new pyjslib_Dict([])
|
|
270
|
-
this._parentVariables = new pyjslib_Dict([])
|
|
271
|
-
this._reason = why
|
|
272
|
-
this._reason2 = null
|
|
256
|
+
store.setGenPrefix(genPrefix)
|
|
257
|
+
}
|
|
258
|
+
this._thisDoc = thisDoc
|
|
259
|
+
this.source = store.sym(thisDoc)
|
|
260
|
+
this.lines = 0
|
|
261
|
+
this.statementCount = 0
|
|
262
|
+
this.hasNil = false
|
|
263
|
+
this.startOfLine = 0
|
|
264
|
+
this.previousLine = 0
|
|
265
|
+
this._genPrefix = genPrefix
|
|
266
|
+
this.keywords = new pyjslib_List(["a", "this", "bind", "has", "is", "of", "true", "false"])
|
|
267
|
+
this.keywordsSet = 0
|
|
268
|
+
this._anonymousNodes = new pyjslib_Dict([])
|
|
269
|
+
this._variables = new pyjslib_Dict([])
|
|
270
|
+
this._parentVariables = new pyjslib_Dict([])
|
|
271
|
+
this._reason = why
|
|
272
|
+
this._reason2 = null
|
|
273
273
|
if (diag_tracking) {
|
|
274
|
-
this._reason2 = why_BecauseOfData(store.sym(thisDoc), this._reason)
|
|
274
|
+
this._reason2 = why_BecauseOfData(store.sym(thisDoc), this._reason)
|
|
275
275
|
}
|
|
276
276
|
if (baseURI) {
|
|
277
|
-
this._baseURI = baseURI
|
|
277
|
+
this._baseURI = baseURI
|
|
278
278
|
}
|
|
279
279
|
else {
|
|
280
280
|
if (thisDoc) {
|
|
281
|
-
this._baseURI = thisDoc
|
|
281
|
+
this._baseURI = thisDoc
|
|
282
282
|
}
|
|
283
283
|
else {
|
|
284
|
-
this._baseURI = null
|
|
284
|
+
this._baseURI = null
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
assertFudge(!(this._baseURI) || (this._baseURI.indexOf(":") >= 0))
|
|
287
|
+
assertFudge(!(this._baseURI) || (this._baseURI.indexOf(":") >= 0))
|
|
288
288
|
if (!(this._genPrefix)) {
|
|
289
289
|
if (this._thisDoc) {
|
|
290
|
-
this._genPrefix = ( this._thisDoc + "#_g" )
|
|
290
|
+
this._genPrefix = ( this._thisDoc + "#_g" )
|
|
291
291
|
}
|
|
292
292
|
else {
|
|
293
|
-
this._genPrefix = RDFSink_uniqueURI()
|
|
293
|
+
this._genPrefix = RDFSink_uniqueURI()
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
if ((openFormula == null)) {
|
|
297
297
|
if (this._thisDoc) {
|
|
298
|
-
this._formula = store.formula( ( thisDoc + "#_formula" ) )
|
|
298
|
+
this._formula = store.formula( ( thisDoc + "#_formula" ) )
|
|
299
299
|
}
|
|
300
300
|
else {
|
|
301
|
-
this._formula = store.formula()
|
|
301
|
+
this._formula = store.formula()
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
else {
|
|
305
|
-
this._formula = openFormula
|
|
305
|
+
this._formula = openFormula
|
|
306
306
|
}
|
|
307
|
-
this._context = this._formula
|
|
308
|
-
this._parentContext = null
|
|
307
|
+
this._context = this._formula
|
|
308
|
+
this._parentContext = null
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
|
|
312
312
|
here(i) {
|
|
313
|
-
return ( ( ( ( this._genPrefix + "_L" ) + this.lines ) + "C" ) + ( ( i - this.startOfLine ) + 1 ) )
|
|
313
|
+
return ( ( ( ( this._genPrefix + "_L" ) + this.lines ) + "C" ) + ( ( i - this.startOfLine ) + 1 ) )
|
|
314
314
|
};
|
|
315
315
|
formula() {
|
|
316
|
-
return this._formula
|
|
316
|
+
return this._formula
|
|
317
317
|
};
|
|
318
318
|
loadStream(stream) {
|
|
319
|
-
return this.loadBuf(stream.read())
|
|
319
|
+
return this.loadBuf(stream.read())
|
|
320
320
|
};
|
|
321
321
|
loadBuf(buf) {
|
|
322
322
|
/*
|
|
323
323
|
Parses a buffer and returns its top level formula*/
|
|
324
324
|
|
|
325
|
-
this.startDoc()
|
|
326
|
-
this.feed(buf)
|
|
327
|
-
return this.endDoc()
|
|
325
|
+
this.startDoc()
|
|
326
|
+
this.feed(buf)
|
|
327
|
+
return this.endDoc()
|
|
328
328
|
};
|
|
329
329
|
feed(octets) {
|
|
330
330
|
/*
|
|
@@ -336,176 +336,176 @@ export class SinkParser {
|
|
|
336
336
|
So if there is more data to feed to the
|
|
337
337
|
parser, it should be straightforward to recover.*/
|
|
338
338
|
|
|
339
|
-
var str = octets.decode("utf-8")
|
|
340
|
-
var i = 0
|
|
339
|
+
var str = octets.decode("utf-8")
|
|
340
|
+
var i = 0
|
|
341
341
|
while ((i >= 0)) {
|
|
342
|
-
var j = this.skipSpace(str, i)
|
|
342
|
+
var j = this.skipSpace(str, i)
|
|
343
343
|
if ((j < 0)) {
|
|
344
|
-
return
|
|
344
|
+
return
|
|
345
345
|
}
|
|
346
|
-
var i = this.directiveOrStatement(str, j)
|
|
346
|
+
var i = this.directiveOrStatement(str, j)
|
|
347
347
|
if ((i < 0)) {
|
|
348
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement")
|
|
348
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected directive or statement")
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
directiveOrStatement(str, h) {
|
|
353
|
-
var i = this.skipSpace(str, h)
|
|
353
|
+
var i = this.skipSpace(str, h)
|
|
354
354
|
if ((i < 0)) {
|
|
355
|
-
return i
|
|
355
|
+
return i
|
|
356
356
|
}
|
|
357
|
-
var j = this.directive(str, i)
|
|
357
|
+
var j = this.directive(str, i)
|
|
358
358
|
if ((j >= 0)) {
|
|
359
|
-
return this.checkDot(str, j)
|
|
359
|
+
return this.checkDot(str, j)
|
|
360
360
|
}
|
|
361
|
-
var j = this.statement(str, i)
|
|
361
|
+
var j = this.statement(str, i)
|
|
362
362
|
if ((j >= 0)) {
|
|
363
|
-
return this.checkDot(str, j)
|
|
363
|
+
return this.checkDot(str, j)
|
|
364
364
|
}
|
|
365
|
-
return j
|
|
365
|
+
return j
|
|
366
366
|
};
|
|
367
367
|
tok(tok, str, i) {
|
|
368
368
|
/*
|
|
369
369
|
Check for keyword. Space must have been stripped on entry and
|
|
370
370
|
we must not be at end of file.*/
|
|
371
|
-
var whitespace = "\t\n\v\f\r "
|
|
371
|
+
var whitespace = "\t\n\v\f\r "
|
|
372
372
|
if ((str.slice( i, ( i + 1 ) ) == "@")) {
|
|
373
|
-
var i = ( i + 1 )
|
|
373
|
+
var i = ( i + 1 )
|
|
374
374
|
}
|
|
375
375
|
else {
|
|
376
376
|
if ((ArrayIndexOf(this.keywords,tok) < 0)) {
|
|
377
|
-
return -1
|
|
377
|
+
return -1
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
var k = ( i + pyjslib_len(tok) )
|
|
380
|
+
var k = ( i + pyjslib_len(tok) )
|
|
381
381
|
if ((str.slice( i, k) == tok) && (_notQNameChars.indexOf(str.charAt(k)) >= 0)) {
|
|
382
|
-
return k
|
|
382
|
+
return k
|
|
383
383
|
}
|
|
384
384
|
else {
|
|
385
|
-
return -1
|
|
385
|
+
return -1
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
directive(str, i) {
|
|
389
|
-
var j = this.skipSpace(str, i)
|
|
389
|
+
var j = this.skipSpace(str, i)
|
|
390
390
|
if ((j < 0)) {
|
|
391
|
-
return j
|
|
391
|
+
return j
|
|
392
392
|
}
|
|
393
|
-
var res = new pyjslib_List([])
|
|
394
|
-
var j = this.tok("bind", str, i)
|
|
393
|
+
var res = new pyjslib_List([])
|
|
394
|
+
var j = this.tok("bind", str, i)
|
|
395
395
|
if ((j > 0)) {
|
|
396
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix")
|
|
396
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "keyword bind is obsolete: use @prefix")
|
|
397
397
|
}
|
|
398
|
-
var j = this.tok("keywords", str, i)
|
|
398
|
+
var j = this.tok("keywords", str, i)
|
|
399
399
|
if ((j > 0)) {
|
|
400
|
-
var i = this.commaSeparatedList(str, j, res, false)
|
|
400
|
+
var i = this.commaSeparatedList(str, j, res, false)
|
|
401
401
|
if ((i < 0)) {
|
|
402
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words")
|
|
402
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "'@keywords' needs comma separated list of words")
|
|
403
403
|
}
|
|
404
|
-
this.setKeywords(pyjslib_slice(res, null, null))
|
|
404
|
+
this.setKeywords(pyjslib_slice(res, null, null))
|
|
405
405
|
if ((diag_chatty_flag > 80)) {
|
|
406
|
-
diag_progress("Keywords ", this.keywords)
|
|
406
|
+
diag_progress("Keywords ", this.keywords)
|
|
407
407
|
}
|
|
408
|
-
return i
|
|
408
|
+
return i
|
|
409
409
|
}
|
|
410
|
-
var j = this.tok("forAll", str, i)
|
|
410
|
+
var j = this.tok("forAll", str, i)
|
|
411
411
|
if ((j > 0)) {
|
|
412
|
-
var i = this.commaSeparatedList(str, j, res, true)
|
|
412
|
+
var i = this.commaSeparatedList(str, j, res, true)
|
|
413
413
|
if ((i < 0)) {
|
|
414
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll")
|
|
414
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forAll")
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
var __x = new pyjslib_Iterator(res)
|
|
417
|
+
var __x = new pyjslib_Iterator(res)
|
|
418
418
|
try {
|
|
419
419
|
while (true) {
|
|
420
|
-
var x = __x.next()
|
|
420
|
+
var x = __x.next()
|
|
421
421
|
|
|
422
422
|
|
|
423
423
|
if (ArrayIndexOf(this._variables,x) < 0 || (ArrayIndexOf(this._parentVariables,x) >= 0)) {
|
|
424
|
-
this._variables[x] = ( this._context.newUniversal(x))
|
|
424
|
+
this._variables[x] = ( this._context.newUniversal(x))
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
}
|
|
428
428
|
} catch (e) {
|
|
429
429
|
if (e != StopIteration) {
|
|
430
|
-
throw e
|
|
430
|
+
throw e
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
return i
|
|
434
|
+
return i
|
|
435
435
|
}
|
|
436
|
-
var j = this.tok("forSome", str, i)
|
|
436
|
+
var j = this.tok("forSome", str, i)
|
|
437
437
|
if ((j > 0)) {
|
|
438
|
-
var i = this.commaSeparatedList(str, j, res, this.uri_ref2)
|
|
438
|
+
var i = this.commaSeparatedList(str, j, res, this.uri_ref2)
|
|
439
439
|
if ((i < 0)) {
|
|
440
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome")
|
|
440
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad variable list after @forSome")
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
var __x = new pyjslib_Iterator(res)
|
|
443
|
+
var __x = new pyjslib_Iterator(res)
|
|
444
444
|
try {
|
|
445
445
|
while (true) {
|
|
446
|
-
var x = __x.next()
|
|
446
|
+
var x = __x.next()
|
|
447
447
|
|
|
448
448
|
|
|
449
|
-
this._context.declareExistential(x)
|
|
449
|
+
this._context.declareExistential(x)
|
|
450
450
|
|
|
451
451
|
}
|
|
452
452
|
} catch (e) {
|
|
453
453
|
if (e != StopIteration) {
|
|
454
|
-
throw e
|
|
454
|
+
throw e
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
return i
|
|
458
|
+
return i
|
|
459
459
|
}
|
|
460
|
-
var j = this.tok("prefix", str, i)
|
|
460
|
+
var j = this.tok("prefix", str, i)
|
|
461
461
|
if ((j >= 0)) {
|
|
462
|
-
var t = new pyjslib_List([])
|
|
463
|
-
var i = this.qname(str, j, t)
|
|
462
|
+
var t = new pyjslib_List([])
|
|
463
|
+
var i = this.qname(str, j, t)
|
|
464
464
|
if ((i < 0)) {
|
|
465
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix")
|
|
465
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected qname after @prefix")
|
|
466
466
|
}
|
|
467
|
-
var j = this.uri_ref2(str, i, t)
|
|
467
|
+
var j = this.uri_ref2(str, i, t)
|
|
468
468
|
if ((j < 0)) {
|
|
469
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected <uriref> after @prefix _qname_")
|
|
469
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected <uriref> after @prefix _qname_")
|
|
470
470
|
}
|
|
471
|
-
var ns = t[1].uri
|
|
471
|
+
var ns = t[1].uri
|
|
472
472
|
if (this._baseURI) {
|
|
473
|
-
var ns = uripath_join(this._baseURI, ns)
|
|
473
|
+
var ns = uripath_join(this._baseURI, ns)
|
|
474
474
|
}
|
|
475
475
|
else {
|
|
476
|
-
assertFudge((ns.indexOf(":") >= 0), "With no base URI, cannot handle relative URI for NS")
|
|
476
|
+
assertFudge((ns.indexOf(":") >= 0), "With no base URI, cannot handle relative URI for NS")
|
|
477
477
|
}
|
|
478
|
-
assertFudge((ns.indexOf(":") >= 0))
|
|
479
|
-
this._bindings[t[0][0]] = ( ns)
|
|
478
|
+
assertFudge((ns.indexOf(":") >= 0))
|
|
479
|
+
this._bindings[t[0][0]] = ( ns)
|
|
480
480
|
|
|
481
|
-
this.bind(t[0][0], hexify(ns))
|
|
482
|
-
return j
|
|
481
|
+
this.bind(t[0][0], hexify(ns))
|
|
482
|
+
return j
|
|
483
483
|
}
|
|
484
|
-
var j = this.tok("base", str, i)
|
|
484
|
+
var j = this.tok("base", str, i)
|
|
485
485
|
if ((j >= 0)) {
|
|
486
|
-
var t = new pyjslib_List([])
|
|
487
|
-
var i = this.uri_ref2(str, j, t)
|
|
486
|
+
var t = new pyjslib_List([])
|
|
487
|
+
var i = this.uri_ref2(str, j, t)
|
|
488
488
|
if ((i < 0)) {
|
|
489
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <uri> after @base ")
|
|
489
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <uri> after @base ")
|
|
490
490
|
}
|
|
491
|
-
var ns = t[0].uri
|
|
491
|
+
var ns = t[0].uri
|
|
492
492
|
if (this._baseURI) {
|
|
493
|
-
var ns = uripath_join(this._baseURI, ns)
|
|
493
|
+
var ns = uripath_join(this._baseURI, ns)
|
|
494
494
|
}
|
|
495
495
|
else {
|
|
496
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "With no previous base URI, cannot use relative URI in @base <" + ns ) + ">" ) )
|
|
496
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "With no previous base URI, cannot use relative URI in @base <" + ns ) + ">" ) )
|
|
497
497
|
}
|
|
498
|
-
assertFudge((ns.indexOf(":") >= 0))
|
|
499
|
-
this._baseURI = ns
|
|
500
|
-
return i
|
|
498
|
+
assertFudge((ns.indexOf(":") >= 0))
|
|
499
|
+
this._baseURI = ns
|
|
500
|
+
return i
|
|
501
501
|
}
|
|
502
|
-
return -1
|
|
502
|
+
return -1
|
|
503
503
|
};
|
|
504
504
|
bind(qn, uri) {
|
|
505
505
|
if ((qn == "")) {
|
|
506
506
|
}
|
|
507
507
|
else {
|
|
508
|
-
this._store.setPrefixForURI(qn, uri)
|
|
508
|
+
this._store.setPrefixForURI(qn, uri)
|
|
509
509
|
}
|
|
510
510
|
};
|
|
511
511
|
setKeywords(k) {
|
|
@@ -513,11 +513,11 @@ export class SinkParser {
|
|
|
513
513
|
Takes a list of strings*/
|
|
514
514
|
|
|
515
515
|
if ((k == null)) {
|
|
516
|
-
this.keywordsSet = 0
|
|
516
|
+
this.keywordsSet = 0
|
|
517
517
|
}
|
|
518
518
|
else {
|
|
519
|
-
this.keywords = k
|
|
520
|
-
this.keywordsSet = 1
|
|
519
|
+
this.keywords = k
|
|
520
|
+
this.keywordsSet = 1
|
|
521
521
|
}
|
|
522
522
|
};
|
|
523
523
|
startDoc() {
|
|
@@ -528,30 +528,30 @@ export class SinkParser {
|
|
|
528
528
|
if (this.hasNil && this._store.rdfFactory.supports["COLLECTIONS"]) {
|
|
529
529
|
convertFirstRestNil(this._store, this.source)
|
|
530
530
|
}
|
|
531
|
-
return this._formula
|
|
531
|
+
return this._formula
|
|
532
532
|
};
|
|
533
533
|
makeStatement(quad) {
|
|
534
|
-
quad[0].add(quad[2], quad[1], quad[3], this.source)
|
|
534
|
+
quad[0].add(quad[2], quad[1], quad[3], this.source)
|
|
535
535
|
if ((quad[2].uri && quad[2].uri === RDF_nil_URI)
|
|
536
536
|
|| (quad[3].uri && quad[3].uri === RDF_nil_URI)) {
|
|
537
537
|
this.hasNil = true
|
|
538
538
|
}
|
|
539
|
-
this.statementCount += 1
|
|
539
|
+
this.statementCount += 1
|
|
540
540
|
};
|
|
541
541
|
statement(str, i) {
|
|
542
|
-
var r = new pyjslib_List([])
|
|
543
|
-
var i = this.object(str, i, r)
|
|
542
|
+
var r = new pyjslib_List([])
|
|
543
|
+
var i = this.object(str, i, r)
|
|
544
544
|
if ((i < 0)) {
|
|
545
|
-
return i
|
|
545
|
+
return i
|
|
546
546
|
}
|
|
547
|
-
var j = this.property_list(str, i, r[0])
|
|
547
|
+
var j = this.property_list(str, i, r[0])
|
|
548
548
|
if ((j < 0)) {
|
|
549
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist")
|
|
549
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected propertylist")
|
|
550
550
|
}
|
|
551
|
-
return j
|
|
551
|
+
return j
|
|
552
552
|
};
|
|
553
553
|
subject(str, i, res) {
|
|
554
|
-
return this.item(str, i, res)
|
|
554
|
+
return this.item(str, i, res)
|
|
555
555
|
};
|
|
556
556
|
verb(str, i, res) {
|
|
557
557
|
/*
|
|
@@ -564,189 +564,189 @@ export class SinkParser {
|
|
|
564
564
|
<- prop -<
|
|
565
565
|
_operator_*/
|
|
566
566
|
|
|
567
|
-
var j = this.skipSpace(str, i)
|
|
567
|
+
var j = this.skipSpace(str, i)
|
|
568
568
|
if ((j < 0)) {
|
|
569
|
-
return j
|
|
569
|
+
return j
|
|
570
570
|
}
|
|
571
|
-
var r = new pyjslib_List([])
|
|
572
|
-
var j = this.tok("has", str, i)
|
|
571
|
+
var r = new pyjslib_List([])
|
|
572
|
+
var j = this.tok("has", str, i)
|
|
573
573
|
if ((j >= 0)) {
|
|
574
|
-
var i = this.prop(str, j, r)
|
|
574
|
+
var i = this.prop(str, j, r)
|
|
575
575
|
if ((i < 0)) {
|
|
576
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'")
|
|
576
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected property after 'has'")
|
|
577
577
|
}
|
|
578
|
-
res.push(new pyjslib_Tuple(["->", r[0]]))
|
|
579
|
-
return i
|
|
578
|
+
res.push(new pyjslib_Tuple(["->", r[0]]))
|
|
579
|
+
return i
|
|
580
580
|
}
|
|
581
|
-
var j = this.tok("is", str, i)
|
|
581
|
+
var j = this.tok("is", str, i)
|
|
582
582
|
if ((j >= 0)) {
|
|
583
|
-
var i = this.prop(str, j, r)
|
|
583
|
+
var i = this.prop(str, j, r)
|
|
584
584
|
if ((i < 0)) {
|
|
585
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <property> after 'is'")
|
|
585
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected <property> after 'is'")
|
|
586
586
|
}
|
|
587
|
-
var j = this.skipSpace(str, i)
|
|
587
|
+
var j = this.skipSpace(str, i)
|
|
588
588
|
if ((j < 0)) {
|
|
589
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'")
|
|
590
|
-
return j
|
|
589
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "End of file found, expected property after 'is'")
|
|
590
|
+
return j
|
|
591
591
|
}
|
|
592
|
-
var i = j
|
|
593
|
-
var j = this.tok("of", str, i)
|
|
592
|
+
var i = j
|
|
593
|
+
var j = this.tok("of", str, i)
|
|
594
594
|
if ((j < 0)) {
|
|
595
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' <prop>")
|
|
595
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected 'of' after 'is' <prop>")
|
|
596
596
|
}
|
|
597
|
-
res.push(new pyjslib_Tuple(["<-", r[0]]))
|
|
598
|
-
return j
|
|
597
|
+
res.push(new pyjslib_Tuple(["<-", r[0]]))
|
|
598
|
+
return j
|
|
599
599
|
}
|
|
600
|
-
var j = this.tok("a", str, i)
|
|
600
|
+
var j = this.tok("a", str, i)
|
|
601
601
|
if ((j >= 0)) {
|
|
602
|
-
res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)]))
|
|
603
|
-
return j
|
|
602
|
+
res.push(new pyjslib_Tuple(["->", this._store.sym(RDF_type_URI)]))
|
|
603
|
+
return j
|
|
604
604
|
}
|
|
605
605
|
if ((str.slice( i, ( i + 2 ) ) == "<=")) {
|
|
606
|
-
res.push(new pyjslib_Tuple(["<-", this._store.sym( ( Logic_NS + "implies" ) )]))
|
|
607
|
-
return ( i + 2 )
|
|
606
|
+
res.push(new pyjslib_Tuple(["<-", this._store.sym( ( Logic_NS + "implies" ) )]))
|
|
607
|
+
return ( i + 2 )
|
|
608
608
|
}
|
|
609
609
|
if ((str.slice( i, ( i + 1 ) ) == "=")) {
|
|
610
610
|
if ((str.slice( ( i + 1 ) , ( i + 2 ) ) == ">")) {
|
|
611
|
-
res.push(new pyjslib_Tuple(["->", this._store.sym( ( Logic_NS + "implies" ) )]))
|
|
612
|
-
return ( i + 2 )
|
|
611
|
+
res.push(new pyjslib_Tuple(["->", this._store.sym( ( Logic_NS + "implies" ) )]))
|
|
612
|
+
return ( i + 2 )
|
|
613
613
|
}
|
|
614
|
-
res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)]))
|
|
615
|
-
return ( i + 1 )
|
|
614
|
+
res.push(new pyjslib_Tuple(["->", this._store.sym(DAML_sameAs_URI)]))
|
|
615
|
+
return ( i + 1 )
|
|
616
616
|
}
|
|
617
617
|
if ((str.slice( i, ( i + 2 ) ) == ":=")) {
|
|
618
|
-
res.push(new pyjslib_Tuple(["->", ( Logic_NS + "becomes" ) ]))
|
|
619
|
-
return ( i + 2 )
|
|
618
|
+
res.push(new pyjslib_Tuple(["->", ( Logic_NS + "becomes" ) ]))
|
|
619
|
+
return ( i + 2 )
|
|
620
620
|
}
|
|
621
|
-
var j = this.prop(str, i, r)
|
|
621
|
+
var j = this.prop(str, i, r)
|
|
622
622
|
if ((j >= 0)) {
|
|
623
|
-
res.push(new pyjslib_Tuple(["->", r[0]]))
|
|
624
|
-
return j
|
|
623
|
+
res.push(new pyjslib_Tuple(["->", r[0]]))
|
|
624
|
+
return j
|
|
625
625
|
}
|
|
626
626
|
if ((str.slice( i, ( i + 2 ) ) == ">-") || (str.slice( i, ( i + 2 ) ) == "<-")) {
|
|
627
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete.")
|
|
627
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ">- ... -> syntax is obsolete.")
|
|
628
628
|
}
|
|
629
|
-
return -1
|
|
629
|
+
return -1
|
|
630
630
|
};
|
|
631
631
|
prop(str, i, res) {
|
|
632
|
-
return this.item(str, i, res)
|
|
632
|
+
return this.item(str, i, res)
|
|
633
633
|
};
|
|
634
634
|
item(str, i, res) {
|
|
635
|
-
return this.path(str, i, res)
|
|
635
|
+
return this.path(str, i, res)
|
|
636
636
|
};
|
|
637
637
|
blankNode(uri) {
|
|
638
|
-
return this._context.bnode(uri, this._reason2)
|
|
638
|
+
return this._context.bnode(uri, this._reason2)
|
|
639
639
|
};
|
|
640
640
|
path(str, i, res) {
|
|
641
641
|
/*
|
|
642
642
|
Parse the path production.
|
|
643
643
|
*/
|
|
644
644
|
|
|
645
|
-
var j = this.nodeOrLiteral(str, i, res)
|
|
645
|
+
var j = this.nodeOrLiteral(str, i, res)
|
|
646
646
|
if ((j < 0)) {
|
|
647
|
-
return j
|
|
647
|
+
return j
|
|
648
648
|
}
|
|
649
649
|
while (("!^.".indexOf(str.slice( j, ( j + 1 ) )) >= 0)) {
|
|
650
|
-
var ch = str.slice( j, ( j + 1 ) )
|
|
650
|
+
var ch = str.slice( j, ( j + 1 ) )
|
|
651
651
|
if ((ch == ".")) {
|
|
652
|
-
var ahead = str.slice( ( j + 1 ) , ( j + 2 ) )
|
|
652
|
+
var ahead = str.slice( ( j + 1 ) , ( j + 2 ) )
|
|
653
653
|
if (!(ahead) || (_notNameChars.indexOf(ahead) >= 0) && (":?<[{(".indexOf(ahead) < 0)) {
|
|
654
|
-
break
|
|
654
|
+
break
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
var subj = res.pop()
|
|
658
|
-
var obj = this.blankNode(this.here(j))
|
|
659
|
-
var j = this.node(str, ( j + 1 ) , res)
|
|
657
|
+
var subj = res.pop()
|
|
658
|
+
var obj = this.blankNode(this.here(j))
|
|
659
|
+
var j = this.node(str, ( j + 1 ) , res)
|
|
660
660
|
if ((j < 0)) {
|
|
661
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax")
|
|
661
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax")
|
|
662
662
|
}
|
|
663
|
-
var pred = res.pop()
|
|
663
|
+
var pred = res.pop()
|
|
664
664
|
if ((ch == "^")) {
|
|
665
|
-
this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]))
|
|
665
|
+
this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]))
|
|
666
666
|
}
|
|
667
667
|
else {
|
|
668
|
-
this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]))
|
|
668
|
+
this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]))
|
|
669
669
|
}
|
|
670
|
-
res.push(obj)
|
|
670
|
+
res.push(obj)
|
|
671
671
|
}
|
|
672
|
-
return j
|
|
672
|
+
return j
|
|
673
673
|
};
|
|
674
674
|
anonymousNode(ln) {
|
|
675
675
|
/*
|
|
676
676
|
Remember or generate a term for one of these _: anonymous nodes*/
|
|
677
677
|
|
|
678
|
-
var term = this._anonymousNodes[ln]
|
|
678
|
+
var term = this._anonymousNodes[ln]
|
|
679
679
|
if (term) {
|
|
680
|
-
return term
|
|
680
|
+
return term
|
|
681
681
|
}
|
|
682
|
-
var term = this._store.bnode(ln)
|
|
682
|
+
var term = this._store.bnode(ln)
|
|
683
683
|
// var term = this._store.bnode(this._context, this._reason2); eh?
|
|
684
|
-
this._anonymousNodes[ln] = ( term)
|
|
685
|
-
return term
|
|
684
|
+
this._anonymousNodes[ln] = ( term)
|
|
685
|
+
return term
|
|
686
686
|
};
|
|
687
687
|
node(str, i, res, subjectAlready) {
|
|
688
|
-
if (typeof subjectAlready == 'undefined') subjectAlready=null
|
|
688
|
+
if (typeof subjectAlready == 'undefined') subjectAlready=null
|
|
689
689
|
/*
|
|
690
690
|
Parse the <node> production.
|
|
691
691
|
Space is now skipped once at the beginning
|
|
692
692
|
instead of in multipe calls to self.skipSpace().
|
|
693
693
|
*/
|
|
694
694
|
|
|
695
|
-
var subj = subjectAlready
|
|
696
|
-
var j = this.skipSpace(str, i)
|
|
695
|
+
var subj = subjectAlready
|
|
696
|
+
var j = this.skipSpace(str, i)
|
|
697
697
|
if ((j < 0)) {
|
|
698
|
-
return j
|
|
698
|
+
return j
|
|
699
699
|
}
|
|
700
|
-
var i = j
|
|
701
|
-
var ch = str.slice( i, ( i + 1 ) )
|
|
700
|
+
var i = j
|
|
701
|
+
var ch = str.slice( i, ( i + 1 ) )
|
|
702
702
|
if ((ch == "[")) {
|
|
703
|
-
var bnodeID = this.here(i)
|
|
704
|
-
var j = this.skipSpace(str, ( i + 1 ) )
|
|
703
|
+
var bnodeID = this.here(i)
|
|
704
|
+
var j = this.skipSpace(str, ( i + 1 ) )
|
|
705
705
|
if ((j < 0)) {
|
|
706
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['")
|
|
706
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['")
|
|
707
707
|
}
|
|
708
708
|
if ((str.slice( j, ( j + 1 ) ) == "=")) {
|
|
709
|
-
var i = ( j + 1 )
|
|
710
|
-
var objs = new pyjslib_List([])
|
|
711
|
-
var j = this.objectList(str, i, objs)
|
|
709
|
+
var i = ( j + 1 )
|
|
710
|
+
var objs = new pyjslib_List([])
|
|
711
|
+
var j = this.objectList(str, i, objs)
|
|
712
712
|
|
|
713
713
|
if ((j >= 0)) {
|
|
714
|
-
var subj = objs[0]
|
|
714
|
+
var subj = objs[0]
|
|
715
715
|
if ((pyjslib_len(objs) > 1)) {
|
|
716
|
-
var __obj = new pyjslib_Iterator(objs)
|
|
716
|
+
var __obj = new pyjslib_Iterator(objs)
|
|
717
717
|
try {
|
|
718
718
|
while (true) {
|
|
719
|
-
var obj = __obj.next()
|
|
720
|
-
this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]))
|
|
719
|
+
var obj = __obj.next()
|
|
720
|
+
this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]))
|
|
721
721
|
}
|
|
722
722
|
} catch (e) {
|
|
723
723
|
if (e != StopIteration) {
|
|
724
|
-
throw e
|
|
724
|
+
throw e
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
var j = this.skipSpace(str, j)
|
|
728
|
+
var j = this.skipSpace(str, j)
|
|
729
729
|
if ((j < 0)) {
|
|
730
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ")
|
|
730
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ")
|
|
731
731
|
}
|
|
732
732
|
if ((str.slice( j, ( j + 1 ) ) == ";")) {
|
|
733
|
-
var j = ( j + 1 )
|
|
733
|
+
var j = ( j + 1 )
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
else {
|
|
737
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ")
|
|
737
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ")
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
if ((subj == null)) {
|
|
741
|
-
var subj = this.blankNode(bnodeID)
|
|
741
|
+
var subj = this.blankNode(bnodeID)
|
|
742
742
|
}
|
|
743
|
-
var i = this.property_list(str, j, subj)
|
|
743
|
+
var i = this.property_list(str, j, subj)
|
|
744
744
|
if ((i < 0)) {
|
|
745
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected")
|
|
745
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected")
|
|
746
746
|
}
|
|
747
|
-
var j = this.skipSpace(str, i)
|
|
747
|
+
var j = this.skipSpace(str, i)
|
|
748
748
|
if ((j < 0)) {
|
|
749
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>")
|
|
749
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>")
|
|
750
750
|
}
|
|
751
751
|
if ((str.slice( j, ( j + 1 ) ) == ".")) {
|
|
752
752
|
// If a dot is found after a blank node, treat it as a statement terminator.
|
|
@@ -755,142 +755,142 @@ export class SinkParser {
|
|
|
755
755
|
// locally would bypass that unified logic and could cause inconsistencies.
|
|
756
756
|
// We do consume ']' below because it is a structural closer of the blank node,
|
|
757
757
|
// not a statement terminator.
|
|
758
|
-
res.push(subj)
|
|
759
|
-
return j
|
|
758
|
+
res.push(subj)
|
|
759
|
+
return j // leave '.' for checkDot()
|
|
760
760
|
}
|
|
761
761
|
if ((str.slice( j, ( j + 1 ) ) != "]")) {
|
|
762
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected")
|
|
762
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected")
|
|
763
763
|
}
|
|
764
|
-
res.push(subj)
|
|
765
|
-
return ( j + 1 )
|
|
764
|
+
res.push(subj)
|
|
765
|
+
return ( j + 1 )
|
|
766
766
|
}
|
|
767
767
|
if ((ch == "{")) {
|
|
768
|
-
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
768
|
+
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
769
769
|
if ((ch2 == "$")) {
|
|
770
|
-
i += 1
|
|
771
|
-
var j = ( i + 1 )
|
|
772
|
-
var mylist = new pyjslib_List([])
|
|
773
|
-
var first_run = true
|
|
770
|
+
i += 1
|
|
771
|
+
var j = ( i + 1 )
|
|
772
|
+
var mylist = new pyjslib_List([])
|
|
773
|
+
var first_run = true
|
|
774
774
|
while (1) {
|
|
775
|
-
var i = this.skipSpace(str, j)
|
|
775
|
+
var i = this.skipSpace(str, j)
|
|
776
776
|
if ((i < 0)) {
|
|
777
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.")
|
|
777
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.")
|
|
778
778
|
}
|
|
779
779
|
if ((str.slice( i, ( i + 2 ) ) == "$}")) {
|
|
780
|
-
var j = ( i + 2 )
|
|
781
|
-
break
|
|
780
|
+
var j = ( i + 2 )
|
|
781
|
+
break
|
|
782
782
|
}
|
|
783
783
|
if (!(first_run)) {
|
|
784
784
|
if ((str.slice( i, ( i + 1 ) ) == ",")) {
|
|
785
|
-
i += 1
|
|
785
|
+
i += 1
|
|
786
786
|
}
|
|
787
787
|
else {
|
|
788
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','")
|
|
788
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','")
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
791
|
else {
|
|
792
|
-
var first_run = false
|
|
792
|
+
var first_run = false
|
|
793
793
|
}
|
|
794
|
-
var item = new pyjslib_List([])
|
|
795
|
-
var j = this.item(str, i, item)
|
|
794
|
+
var item = new pyjslib_List([])
|
|
795
|
+
var j = this.item(str, i, item)
|
|
796
796
|
if ((j < 0)) {
|
|
797
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'")
|
|
797
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'")
|
|
798
798
|
}
|
|
799
|
-
mylist.push(item[0])
|
|
799
|
+
mylist.push(item[0])
|
|
800
800
|
}
|
|
801
|
-
res.push(this._store.newSet(mylist, this._context))
|
|
802
|
-
return j
|
|
801
|
+
res.push(this._store.newSet(mylist, this._context))
|
|
802
|
+
return j
|
|
803
803
|
}
|
|
804
804
|
else {
|
|
805
|
-
var j = ( i + 1 )
|
|
806
|
-
var oldParentContext = this._parentContext
|
|
807
|
-
this._parentContext = this._context
|
|
808
|
-
var parentAnonymousNodes = this._anonymousNodes
|
|
809
|
-
var grandParentVariables = this._parentVariables
|
|
810
|
-
this._parentVariables = this._variables
|
|
811
|
-
this._anonymousNodes = new pyjslib_Dict([])
|
|
812
|
-
this._variables = this._variables.slice()
|
|
813
|
-
var reason2 = this._reason2
|
|
814
|
-
this._reason2 = becauseSubexpression
|
|
805
|
+
var j = ( i + 1 )
|
|
806
|
+
var oldParentContext = this._parentContext
|
|
807
|
+
this._parentContext = this._context
|
|
808
|
+
var parentAnonymousNodes = this._anonymousNodes
|
|
809
|
+
var grandParentVariables = this._parentVariables
|
|
810
|
+
this._parentVariables = this._variables
|
|
811
|
+
this._anonymousNodes = new pyjslib_Dict([])
|
|
812
|
+
this._variables = this._variables.slice()
|
|
813
|
+
var reason2 = this._reason2
|
|
814
|
+
this._reason2 = becauseSubexpression
|
|
815
815
|
if ((subj == null)) {
|
|
816
|
-
var subj = this._store.formula()
|
|
816
|
+
var subj = this._store.formula()
|
|
817
817
|
}
|
|
818
|
-
this._context = subj
|
|
818
|
+
this._context = subj
|
|
819
819
|
while (1) {
|
|
820
|
-
var i = this.skipSpace(str, j)
|
|
820
|
+
var i = this.skipSpace(str, j)
|
|
821
821
|
if ((i < 0)) {
|
|
822
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.")
|
|
822
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.")
|
|
823
823
|
}
|
|
824
824
|
if ((str.slice( i, ( i + 1 ) ) == "}")) {
|
|
825
|
-
var j = ( i + 1 )
|
|
826
|
-
break
|
|
825
|
+
var j = ( i + 1 )
|
|
826
|
+
break
|
|
827
827
|
}
|
|
828
|
-
var j = this.directiveOrStatement(str, i)
|
|
828
|
+
var j = this.directiveOrStatement(str, i)
|
|
829
829
|
if ((j < 0)) {
|
|
830
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'")
|
|
830
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'")
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
this._anonymousNodes = parentAnonymousNodes
|
|
834
|
-
this._variables = this._parentVariables
|
|
835
|
-
this._parentVariables = grandParentVariables
|
|
836
|
-
this._context = this._parentContext
|
|
837
|
-
this._reason2 = reason2
|
|
838
|
-
this._parentContext = oldParentContext
|
|
839
|
-
res.push(subj.close())
|
|
840
|
-
return j
|
|
833
|
+
this._anonymousNodes = parentAnonymousNodes
|
|
834
|
+
this._variables = this._parentVariables
|
|
835
|
+
this._parentVariables = grandParentVariables
|
|
836
|
+
this._context = this._parentContext
|
|
837
|
+
this._reason2 = reason2
|
|
838
|
+
this._parentContext = oldParentContext
|
|
839
|
+
res.push(subj.close())
|
|
840
|
+
return j
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
843
|
if ((ch == "(")) {
|
|
844
|
-
var thing_type = this._store.list
|
|
845
|
-
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
844
|
+
var thing_type = this._store.list
|
|
845
|
+
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
846
846
|
if ((ch2 == "$")) {
|
|
847
|
-
var thing_type = this._store.newSet
|
|
848
|
-
i += 1
|
|
847
|
+
var thing_type = this._store.newSet
|
|
848
|
+
i += 1
|
|
849
849
|
}
|
|
850
|
-
var j = ( i + 1 )
|
|
851
|
-
var mylist = new pyjslib_List([])
|
|
850
|
+
var j = ( i + 1 )
|
|
851
|
+
var mylist = new pyjslib_List([])
|
|
852
852
|
while (1) {
|
|
853
|
-
var i = this.skipSpace(str, j)
|
|
853
|
+
var i = this.skipSpace(str, j)
|
|
854
854
|
if ((i < 0)) {
|
|
855
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.")
|
|
855
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.")
|
|
856
856
|
}
|
|
857
857
|
if ((str.slice( i, ( i + 1 ) ) == ")")) {
|
|
858
|
-
var j = ( i + 1 )
|
|
859
|
-
break
|
|
858
|
+
var j = ( i + 1 )
|
|
859
|
+
break
|
|
860
860
|
}
|
|
861
|
-
var item = new pyjslib_List([])
|
|
862
|
-
var j = this.item(str, i, item)
|
|
861
|
+
var item = new pyjslib_List([])
|
|
862
|
+
var j = this.item(str, i, item)
|
|
863
863
|
if ((j < 0)) {
|
|
864
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'")
|
|
864
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'")
|
|
865
865
|
}
|
|
866
|
-
mylist.push(item[0])
|
|
866
|
+
mylist.push(item[0])
|
|
867
867
|
}
|
|
868
|
-
res.push(thing_type(mylist, this._context))
|
|
869
|
-
return j
|
|
868
|
+
res.push(thing_type(mylist, this._context))
|
|
869
|
+
return j
|
|
870
870
|
}
|
|
871
|
-
var j = this.tok("this", str, i)
|
|
871
|
+
var j = this.tok("this", str, i)
|
|
872
872
|
if ((j >= 0)) {
|
|
873
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.")
|
|
874
|
-
res.push(this._context)
|
|
875
|
-
return j
|
|
873
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.")
|
|
874
|
+
res.push(this._context)
|
|
875
|
+
return j
|
|
876
876
|
}
|
|
877
|
-
var j = this.tok("true", str, i)
|
|
877
|
+
var j = this.tok("true", str, i)
|
|
878
878
|
if ((j >= 0)) {
|
|
879
|
-
res.push(true)
|
|
880
|
-
return j
|
|
879
|
+
res.push(true)
|
|
880
|
+
return j
|
|
881
881
|
}
|
|
882
|
-
var j = this.tok("false", str, i)
|
|
882
|
+
var j = this.tok("false", str, i)
|
|
883
883
|
if ((j >= 0)) {
|
|
884
|
-
res.push(false)
|
|
885
|
-
return j
|
|
884
|
+
res.push(false)
|
|
885
|
+
return j
|
|
886
886
|
}
|
|
887
887
|
if ((subj == null)) {
|
|
888
|
-
var j = this.uri_ref2(str, i, res)
|
|
888
|
+
var j = this.uri_ref2(str, i, res)
|
|
889
889
|
if ((j >= 0)) {
|
|
890
|
-
return j
|
|
890
|
+
return j
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
-
return -1
|
|
893
|
+
return -1
|
|
894
894
|
};
|
|
895
895
|
property_list(str, i, subj) {
|
|
896
896
|
/*
|
|
@@ -899,65 +899,65 @@ export class SinkParser {
|
|
|
899
899
|
*/
|
|
900
900
|
|
|
901
901
|
while (1) {
|
|
902
|
-
var j = this.skipSpace(str, i)
|
|
902
|
+
var j = this.skipSpace(str, i)
|
|
903
903
|
if ((j < 0)) {
|
|
904
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list")
|
|
905
|
-
return j
|
|
904
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list")
|
|
905
|
+
return j
|
|
906
906
|
}
|
|
907
907
|
if ((str.slice( j, ( j + 2 ) ) == ":-")) {
|
|
908
|
-
var i = ( j + 2 )
|
|
909
|
-
var res = new pyjslib_List([])
|
|
910
|
-
var j = this.node(str, i, res, subj)
|
|
908
|
+
var i = ( j + 2 )
|
|
909
|
+
var res = new pyjslib_List([])
|
|
910
|
+
var j = this.node(str, i, res, subj)
|
|
911
911
|
if ((j < 0)) {
|
|
912
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ")
|
|
912
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ")
|
|
913
913
|
}
|
|
914
|
-
var i = j
|
|
915
|
-
continue
|
|
914
|
+
var i = j
|
|
915
|
+
continue
|
|
916
916
|
}
|
|
917
|
-
var i = j
|
|
918
|
-
var v = new pyjslib_List([])
|
|
919
|
-
var j = this.verb(str, i, v)
|
|
917
|
+
var i = j
|
|
918
|
+
var v = new pyjslib_List([])
|
|
919
|
+
var j = this.verb(str, i, v)
|
|
920
920
|
if ((j <= 0)) {
|
|
921
|
-
return i
|
|
921
|
+
return i
|
|
922
922
|
}
|
|
923
|
-
var objs = new pyjslib_List([])
|
|
924
|
-
var i = this.objectList(str, j, objs)
|
|
923
|
+
var objs = new pyjslib_List([])
|
|
924
|
+
var i = this.objectList(str, j, objs)
|
|
925
925
|
if ((i < 0)) {
|
|
926
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected")
|
|
926
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected")
|
|
927
927
|
}
|
|
928
928
|
|
|
929
|
-
var __obj = new pyjslib_Iterator(objs)
|
|
929
|
+
var __obj = new pyjslib_Iterator(objs)
|
|
930
930
|
try {
|
|
931
931
|
while (true) {
|
|
932
|
-
var obj = __obj.next()
|
|
932
|
+
var obj = __obj.next()
|
|
933
933
|
|
|
934
934
|
|
|
935
|
-
var pairFudge = v[0]
|
|
936
|
-
var dir = pairFudge[0]
|
|
937
|
-
var sym = pairFudge[1]
|
|
935
|
+
var pairFudge = v[0]
|
|
936
|
+
var dir = pairFudge[0]
|
|
937
|
+
var sym = pairFudge[1]
|
|
938
938
|
if ((dir == "->")) {
|
|
939
|
-
this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]))
|
|
939
|
+
this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]))
|
|
940
940
|
}
|
|
941
941
|
else {
|
|
942
|
-
this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]))
|
|
942
|
+
this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]))
|
|
943
943
|
}
|
|
944
944
|
|
|
945
945
|
}
|
|
946
946
|
} catch (e) {
|
|
947
947
|
if (e != StopIteration) {
|
|
948
|
-
throw e
|
|
948
|
+
throw e
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
|
|
952
|
-
var j = this.skipSpace(str, i)
|
|
952
|
+
var j = this.skipSpace(str, i)
|
|
953
953
|
if ((j < 0)) {
|
|
954
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects")
|
|
955
|
-
return j
|
|
954
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects")
|
|
955
|
+
return j
|
|
956
956
|
}
|
|
957
957
|
if ((str.slice( i, ( i + 1 ) ) != ";")) {
|
|
958
|
-
return i
|
|
958
|
+
return i
|
|
959
959
|
}
|
|
960
|
-
var i = ( i + 1 )
|
|
960
|
+
var i = ( i + 1 )
|
|
961
961
|
}
|
|
962
962
|
};
|
|
963
963
|
commaSeparatedList(str, j, res, ofUris) {
|
|
@@ -969,83 +969,83 @@ export class SinkParser {
|
|
|
969
969
|
but passing the function didn't work fo js converion pyjs
|
|
970
970
|
*/
|
|
971
971
|
|
|
972
|
-
var i = this.skipSpace(str, j)
|
|
972
|
+
var i = this.skipSpace(str, j)
|
|
973
973
|
if ((i < 0)) {
|
|
974
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list")
|
|
975
|
-
return i
|
|
974
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list")
|
|
975
|
+
return i
|
|
976
976
|
}
|
|
977
977
|
if ((str.charAt(i) == ".")) {
|
|
978
|
-
return j
|
|
978
|
+
return j
|
|
979
979
|
}
|
|
980
980
|
if (ofUris) {
|
|
981
|
-
var i = this.uri_ref2(str, i, res)
|
|
981
|
+
var i = this.uri_ref2(str, i, res)
|
|
982
982
|
}
|
|
983
983
|
else {
|
|
984
|
-
var i = this.bareWord(str, i, res)
|
|
984
|
+
var i = this.bareWord(str, i, res)
|
|
985
985
|
}
|
|
986
986
|
if ((i < 0)) {
|
|
987
|
-
return -1
|
|
987
|
+
return -1
|
|
988
988
|
}
|
|
989
989
|
while (1) {
|
|
990
|
-
var j = this.skipSpace(str, i)
|
|
990
|
+
var j = this.skipSpace(str, i)
|
|
991
991
|
if ((j < 0)) {
|
|
992
|
-
return j
|
|
992
|
+
return j
|
|
993
993
|
}
|
|
994
|
-
var ch = str.slice( j, ( j + 1 ) )
|
|
994
|
+
var ch = str.slice( j, ( j + 1 ) )
|
|
995
995
|
if ((ch != ",")) {
|
|
996
996
|
if ((ch != ".")) {
|
|
997
|
-
return -1
|
|
997
|
+
return -1
|
|
998
998
|
}
|
|
999
|
-
return j
|
|
999
|
+
return j
|
|
1000
1000
|
}
|
|
1001
1001
|
if (ofUris) {
|
|
1002
|
-
var i = this.uri_ref2(str, ( j + 1 ) , res)
|
|
1002
|
+
var i = this.uri_ref2(str, ( j + 1 ) , res)
|
|
1003
1003
|
}
|
|
1004
1004
|
else {
|
|
1005
|
-
var i = this.bareWord(str, ( j + 1 ) , res)
|
|
1005
|
+
var i = this.bareWord(str, ( j + 1 ) , res)
|
|
1006
1006
|
}
|
|
1007
1007
|
if ((i < 0)) {
|
|
1008
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content")
|
|
1009
|
-
return i
|
|
1008
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content")
|
|
1009
|
+
return i
|
|
1010
1010
|
}
|
|
1011
1011
|
}
|
|
1012
1012
|
};
|
|
1013
1013
|
objectList(str, i, res) {
|
|
1014
|
-
var i = this.object(str, i, res)
|
|
1014
|
+
var i = this.object(str, i, res)
|
|
1015
1015
|
if ((i < 0)) {
|
|
1016
|
-
return -1
|
|
1016
|
+
return -1
|
|
1017
1017
|
}
|
|
1018
1018
|
while (1) {
|
|
1019
|
-
var j = this.skipSpace(str, i)
|
|
1019
|
+
var j = this.skipSpace(str, i)
|
|
1020
1020
|
if ((j < 0)) {
|
|
1021
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object")
|
|
1022
|
-
return j
|
|
1021
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object")
|
|
1022
|
+
return j
|
|
1023
1023
|
}
|
|
1024
1024
|
if ((str.slice( j, ( j + 1 ) ) != ",")) {
|
|
1025
|
-
return j
|
|
1025
|
+
return j
|
|
1026
1026
|
}
|
|
1027
|
-
var i = this.object(str, ( j + 1 ) , res)
|
|
1027
|
+
var i = this.object(str, ( j + 1 ) , res)
|
|
1028
1028
|
if ((i < 0)) {
|
|
1029
|
-
return i
|
|
1029
|
+
return i
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
|
1032
1032
|
};
|
|
1033
1033
|
checkDot(str, i) {
|
|
1034
|
-
var j = this.skipSpace(str, i)
|
|
1034
|
+
var j = this.skipSpace(str, i)
|
|
1035
1035
|
if ((j < 0)) {
|
|
1036
|
-
return j
|
|
1036
|
+
return j
|
|
1037
1037
|
}
|
|
1038
1038
|
if ((str.slice( j, ( j + 1 ) ) == ".")) {
|
|
1039
|
-
return ( j + 1 )
|
|
1039
|
+
return ( j + 1 )
|
|
1040
1040
|
}
|
|
1041
1041
|
if ((str.slice( j, ( j + 1 ) ) == "}")) {
|
|
1042
|
-
return j
|
|
1042
|
+
return j
|
|
1043
1043
|
}
|
|
1044
1044
|
if ((str.slice( j, ( j + 1 ) ) == "]")) {
|
|
1045
|
-
return j
|
|
1045
|
+
return j
|
|
1046
1046
|
}
|
|
1047
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement")
|
|
1048
|
-
return i
|
|
1047
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement")
|
|
1048
|
+
return i
|
|
1049
1049
|
};
|
|
1050
1050
|
uri_ref2(str, i, res) {
|
|
1051
1051
|
/*
|
|
@@ -1056,90 +1056,90 @@ export class SinkParser {
|
|
|
1056
1056
|
to make the namesapces look more like what XML folks expect.
|
|
1057
1057
|
*/
|
|
1058
1058
|
|
|
1059
|
-
var qn = new pyjslib_List([])
|
|
1060
|
-
var j = this.qname(str, i, qn)
|
|
1059
|
+
var qn = new pyjslib_List([])
|
|
1060
|
+
var j = this.qname(str, i, qn)
|
|
1061
1061
|
if ((j >= 0)) {
|
|
1062
|
-
var pairFudge = qn[0]
|
|
1063
|
-
var pfx = pairFudge[0]
|
|
1064
|
-
var ln = pairFudge[1]
|
|
1062
|
+
var pairFudge = qn[0]
|
|
1063
|
+
var pfx = pairFudge[0]
|
|
1064
|
+
var ln = pairFudge[1]
|
|
1065
1065
|
if ((pfx == null)) {
|
|
1066
|
-
assertFudge(0, "not used?")
|
|
1067
|
-
var ns = ( this._baseURI + ADDED_HASH )
|
|
1066
|
+
assertFudge(0, "not used?")
|
|
1067
|
+
var ns = ( this._baseURI + ADDED_HASH )
|
|
1068
1068
|
}
|
|
1069
1069
|
else {
|
|
1070
|
-
var ns = this._bindings[pfx]
|
|
1070
|
+
var ns = this._bindings[pfx]
|
|
1071
1071
|
if (!(ns)) {
|
|
1072
1072
|
if ((pfx == "_")) {
|
|
1073
|
-
res.push(this.anonymousNode(ln))
|
|
1074
|
-
return j
|
|
1073
|
+
res.push(this.anonymousNode(ln))
|
|
1074
|
+
return j
|
|
1075
1075
|
}
|
|
1076
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Prefix " + pfx ) + " not bound." ) )
|
|
1076
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Prefix " + pfx ) + " not bound." ) )
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
|
-
var symb = this._store.sym( ( ns + ln ) )
|
|
1079
|
+
var symb = this._store.sym( ( ns + ln ) )
|
|
1080
1080
|
if ((ArrayIndexOf(this._variables, symb) >= 0)) {
|
|
1081
|
-
res.push(this._variables[symb])
|
|
1081
|
+
res.push(this._variables[symb])
|
|
1082
1082
|
}
|
|
1083
1083
|
else {
|
|
1084
|
-
res.push(symb)
|
|
1084
|
+
res.push(symb)
|
|
1085
1085
|
}
|
|
1086
|
-
return j
|
|
1086
|
+
return j
|
|
1087
1087
|
}
|
|
1088
|
-
var i = this.skipSpace(str, i)
|
|
1088
|
+
var i = this.skipSpace(str, i)
|
|
1089
1089
|
if ((i < 0)) {
|
|
1090
|
-
return -1
|
|
1090
|
+
return -1
|
|
1091
1091
|
}
|
|
1092
1092
|
if ((str.charAt(i) == "?")) {
|
|
1093
|
-
var v = new pyjslib_List([])
|
|
1094
|
-
var j = this.variable(str, i, v)
|
|
1093
|
+
var v = new pyjslib_List([])
|
|
1094
|
+
var j = this.variable(str, i, v)
|
|
1095
1095
|
if ((j > 0)) {
|
|
1096
|
-
res.push(v[0])
|
|
1097
|
-
return j
|
|
1096
|
+
res.push(v[0])
|
|
1097
|
+
return j
|
|
1098
1098
|
}
|
|
1099
|
-
return -1
|
|
1099
|
+
return -1
|
|
1100
1100
|
}
|
|
1101
1101
|
else if ((str.charAt(i) == "<")) {
|
|
1102
|
-
var i = ( i + 1 )
|
|
1103
|
-
var st = i
|
|
1102
|
+
var i = ( i + 1 )
|
|
1103
|
+
var st = i
|
|
1104
1104
|
while ((i < pyjslib_len(str))) {
|
|
1105
1105
|
if ((str.charAt(i) == ">")) {
|
|
1106
|
-
var uref = str.slice( st, i)
|
|
1106
|
+
var uref = str.slice( st, i)
|
|
1107
1107
|
if (this._baseURI) {
|
|
1108
|
-
var uref = uripath_join(this._baseURI, uref)
|
|
1108
|
+
var uref = uripath_join(this._baseURI, uref)
|
|
1109
1109
|
}
|
|
1110
1110
|
else {
|
|
1111
|
-
assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs")
|
|
1111
|
+
assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs")
|
|
1112
1112
|
}
|
|
1113
1113
|
if ((str.slice( ( i - 1 ) , i) == "#") && !((pyjslib_slice(uref, -1, null) == "#"))) {
|
|
1114
|
-
var uref = ( uref + "#" )
|
|
1114
|
+
var uref = ( uref + "#" )
|
|
1115
1115
|
}
|
|
1116
|
-
var symb = this._store.sym(uref)
|
|
1116
|
+
var symb = this._store.sym(uref)
|
|
1117
1117
|
if ((ArrayIndexOf(this._variables,symb) >= 0)) {
|
|
1118
|
-
res.push(this._variables[symb])
|
|
1118
|
+
res.push(this._variables[symb])
|
|
1119
1119
|
}
|
|
1120
1120
|
else {
|
|
1121
|
-
res.push(symb)
|
|
1121
|
+
res.push(symb)
|
|
1122
1122
|
}
|
|
1123
|
-
return ( i + 1 )
|
|
1123
|
+
return ( i + 1 )
|
|
1124
1124
|
}
|
|
1125
|
-
var i = ( i + 1 )
|
|
1125
|
+
var i = ( i + 1 )
|
|
1126
1126
|
}
|
|
1127
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference")
|
|
1127
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference")
|
|
1128
1128
|
}
|
|
1129
1129
|
else if (this.keywordsSet) {
|
|
1130
|
-
var v = new pyjslib_List([])
|
|
1131
|
-
var j = this.bareWord(str, i, v)
|
|
1130
|
+
var v = new pyjslib_List([])
|
|
1131
|
+
var j = this.bareWord(str, i, v)
|
|
1132
1132
|
if ((j < 0)) {
|
|
1133
|
-
return -1
|
|
1133
|
+
return -1
|
|
1134
1134
|
}
|
|
1135
1135
|
if ((ArrayIndexOf(this.keywords, v[0]) >= 0)) {
|
|
1136
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) )
|
|
1136
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) )
|
|
1137
1137
|
}
|
|
1138
|
-
res.push(this._store.sym( ( this._bindings[""] + v[0] ) ))
|
|
1139
|
-
return j
|
|
1138
|
+
res.push(this._store.sym( ( this._bindings[""] + v[0] ) ))
|
|
1139
|
+
return j
|
|
1140
1140
|
}
|
|
1141
1141
|
else {
|
|
1142
|
-
return -1
|
|
1142
|
+
return -1
|
|
1143
1143
|
}
|
|
1144
1144
|
};
|
|
1145
1145
|
skipSpace(str, i) {
|
|
@@ -1147,9 +1147,9 @@ export class SinkParser {
|
|
|
1147
1147
|
Skip white space, newlines and comments.
|
|
1148
1148
|
return -1 if EOF, else position of first non-ws character*/
|
|
1149
1149
|
|
|
1150
|
-
var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'
|
|
1150
|
+
var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'
|
|
1151
1151
|
for (var j = (i ? i : 0); j < str.length; j++) {
|
|
1152
|
-
var ch = str.charAt(j)
|
|
1152
|
+
var ch = str.charAt(j)
|
|
1153
1153
|
// console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
|
|
1154
1154
|
// console.log(" skipspace ch <" + ch + ">");
|
|
1155
1155
|
if (whitespace.indexOf(ch) < 0 ) { //not ws
|
|
@@ -1158,11 +1158,11 @@ export class SinkParser {
|
|
|
1158
1158
|
for (;; j++) {
|
|
1159
1159
|
// console.log(" skipspace2 j= "+j + " i= " + i + " n= " + str.length);
|
|
1160
1160
|
if (j === str.length) {
|
|
1161
|
-
return -1
|
|
1161
|
+
return -1 // EOF
|
|
1162
1162
|
}
|
|
1163
1163
|
if (str.charAt(j) === '\n') {
|
|
1164
|
-
this.lines = this.lines + 1
|
|
1165
|
-
break
|
|
1164
|
+
this.lines = this.lines + 1
|
|
1165
|
+
break
|
|
1166
1166
|
}
|
|
1167
1167
|
};
|
|
1168
1168
|
} else { // Not hash - something interesting
|
|
@@ -1172,11 +1172,11 @@ export class SinkParser {
|
|
|
1172
1172
|
} else { // Whitespace
|
|
1173
1173
|
// console.log(" skipspace 5 ch <" + ch + ">");
|
|
1174
1174
|
if (str.charAt(j) === '\n') {
|
|
1175
|
-
this.lines = this.lines + 1
|
|
1175
|
+
this.lines = this.lines + 1
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
1178
|
} // next j
|
|
1179
|
-
return -1
|
|
1179
|
+
return -1 // EOF
|
|
1180
1180
|
};
|
|
1181
1181
|
|
|
1182
1182
|
variable(str, i, res) {
|
|
@@ -1184,60 +1184,60 @@ export class SinkParser {
|
|
|
1184
1184
|
?abc -> variable(:abc)
|
|
1185
1185
|
*/
|
|
1186
1186
|
|
|
1187
|
-
var j = this.skipSpace(str, i)
|
|
1187
|
+
var j = this.skipSpace(str, i)
|
|
1188
1188
|
if ((j < 0)) {
|
|
1189
|
-
return -1
|
|
1189
|
+
return -1
|
|
1190
1190
|
}
|
|
1191
1191
|
if ((str.slice( j, ( j + 1 ) ) != "?")) {
|
|
1192
|
-
return -1
|
|
1192
|
+
return -1
|
|
1193
1193
|
}
|
|
1194
|
-
var j = ( j + 1 )
|
|
1195
|
-
var i = j
|
|
1194
|
+
var j = ( j + 1 )
|
|
1195
|
+
var i = j
|
|
1196
1196
|
if (("0123456789-".indexOf(str.charAt(j)) >= 0)) {
|
|
1197
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str.charAt(j) ) + "s'" ) )
|
|
1198
|
-
return -1
|
|
1197
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str.charAt(j) ) + "s'" ) )
|
|
1198
|
+
return -1
|
|
1199
1199
|
}
|
|
1200
1200
|
while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) {
|
|
1201
|
-
var i = ( i + 1 )
|
|
1201
|
+
var i = ( i + 1 )
|
|
1202
1202
|
}
|
|
1203
1203
|
if ((this._parentContext == null)) {
|
|
1204
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, ( "Can't use ?xxx syntax for variable in outermost level: " + str.slice( ( j - 1 ) , i) ) )
|
|
1204
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ( "Can't use ?xxx syntax for variable in outermost level: " + str.slice( ( j - 1 ) , i) ) )
|
|
1205
1205
|
}
|
|
1206
|
-
res.push(this._store.variable(str.slice( j, i)))
|
|
1207
|
-
return i
|
|
1206
|
+
res.push(this._store.variable(str.slice( j, i)))
|
|
1207
|
+
return i
|
|
1208
1208
|
};
|
|
1209
1209
|
bareWord(str, i, res) {
|
|
1210
1210
|
/*
|
|
1211
1211
|
abc -> :abc
|
|
1212
1212
|
*/
|
|
1213
1213
|
|
|
1214
|
-
var j = this.skipSpace(str, i)
|
|
1214
|
+
var j = this.skipSpace(str, i)
|
|
1215
1215
|
if ((j < 0)) {
|
|
1216
|
-
return -1
|
|
1216
|
+
return -1
|
|
1217
1217
|
}
|
|
1218
|
-
var ch = str.charAt(j)
|
|
1218
|
+
var ch = str.charAt(j)
|
|
1219
1219
|
if (("0123456789-".indexOf(ch) >= 0)) {
|
|
1220
|
-
return -1
|
|
1220
|
+
return -1
|
|
1221
1221
|
}
|
|
1222
1222
|
if ((_notNameChars.indexOf(ch) >= 0)) {
|
|
1223
|
-
return -1
|
|
1223
|
+
return -1
|
|
1224
1224
|
}
|
|
1225
|
-
var i = j
|
|
1225
|
+
var i = j
|
|
1226
1226
|
while ((i < pyjslib_len(str))) {
|
|
1227
|
-
var c = str.charAt(i)
|
|
1227
|
+
var c = str.charAt(i)
|
|
1228
1228
|
if (c === '.') {
|
|
1229
1229
|
if (dotTerminatesName(str, i)) {
|
|
1230
|
-
break
|
|
1230
|
+
break // treat as statement terminator, not part of name
|
|
1231
1231
|
}
|
|
1232
1232
|
// else: accept '.' as part of name
|
|
1233
1233
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1234
1234
|
// Other invalid characters terminate the name
|
|
1235
|
-
break
|
|
1235
|
+
break
|
|
1236
1236
|
}
|
|
1237
|
-
var i = ( i + 1 )
|
|
1237
|
+
var i = ( i + 1 )
|
|
1238
1238
|
}
|
|
1239
|
-
res.push(str.slice( j, i))
|
|
1240
|
-
return i
|
|
1239
|
+
res.push(str.slice( j, i))
|
|
1240
|
+
return i
|
|
1241
1241
|
};
|
|
1242
1242
|
qname(str, i, res) {
|
|
1243
1243
|
/*
|
|
@@ -1247,178 +1247,178 @@ export class SinkParser {
|
|
|
1247
1247
|
:def -> ('', 'def')
|
|
1248
1248
|
*/
|
|
1249
1249
|
|
|
1250
|
-
var i = this.skipSpace(str, i)
|
|
1250
|
+
var i = this.skipSpace(str, i)
|
|
1251
1251
|
if ((i < 0)) {
|
|
1252
|
-
return -1
|
|
1252
|
+
return -1
|
|
1253
1253
|
}
|
|
1254
|
-
var c = str.charAt(i)
|
|
1254
|
+
var c = str.charAt(i)
|
|
1255
1255
|
if (("0123456789-+".indexOf(c) >= 0)) {
|
|
1256
|
-
return -1
|
|
1256
|
+
return -1
|
|
1257
1257
|
}
|
|
1258
1258
|
if ((_notNameChars.indexOf(c) < 0)) {
|
|
1259
|
-
var ln = c
|
|
1260
|
-
var i = ( i + 1 )
|
|
1259
|
+
var ln = c
|
|
1260
|
+
var i = ( i + 1 )
|
|
1261
1261
|
while ((i < pyjslib_len(str))) {
|
|
1262
|
-
var c = str.charAt(i)
|
|
1262
|
+
var c = str.charAt(i)
|
|
1263
1263
|
if (c === '.') {
|
|
1264
1264
|
if (dotTerminatesName(str, i)) {
|
|
1265
|
-
break
|
|
1265
|
+
break // dot ends the name here
|
|
1266
1266
|
}
|
|
1267
1267
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1268
|
-
break
|
|
1268
|
+
break
|
|
1269
1269
|
}
|
|
1270
|
-
var ln = ( ln + c )
|
|
1271
|
-
var i = ( i + 1 )
|
|
1270
|
+
var ln = ( ln + c )
|
|
1271
|
+
var i = ( i + 1 )
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
else {
|
|
1275
|
-
var ln = ""
|
|
1275
|
+
var ln = ""
|
|
1276
1276
|
}
|
|
1277
1277
|
if ((i < pyjslib_len(str)) && (str.charAt(i) == ":")) {
|
|
1278
|
-
var pfx = ln
|
|
1279
|
-
var i = ( i + 1 )
|
|
1280
|
-
var ln = ""
|
|
1278
|
+
var pfx = ln
|
|
1279
|
+
var i = ( i + 1 )
|
|
1280
|
+
var ln = ""
|
|
1281
1281
|
while ((i < pyjslib_len(str))) {
|
|
1282
|
-
var c = str.charAt(i)
|
|
1282
|
+
var c = str.charAt(i)
|
|
1283
1283
|
if (c === '.') {
|
|
1284
1284
|
if (dotTerminatesName(str, i)) {
|
|
1285
|
-
break
|
|
1285
|
+
break // dot ends the name here
|
|
1286
1286
|
}
|
|
1287
1287
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1288
|
-
break
|
|
1288
|
+
break
|
|
1289
1289
|
}
|
|
1290
|
-
var ln = ( ln + c )
|
|
1291
|
-
var i = ( i + 1 )
|
|
1290
|
+
var ln = ( ln + c )
|
|
1291
|
+
var i = ( i + 1 )
|
|
1292
1292
|
}
|
|
1293
|
-
res.push(new pyjslib_Tuple([pfx, ln]))
|
|
1294
|
-
return i
|
|
1293
|
+
res.push(new pyjslib_Tuple([pfx, ln]))
|
|
1294
|
+
return i
|
|
1295
1295
|
}
|
|
1296
1296
|
else {
|
|
1297
1297
|
if (ln && this.keywordsSet && (ArrayIndexOf(this.keywords, ln) < 0)) {
|
|
1298
|
-
res.push(new pyjslib_Tuple(["", ln]))
|
|
1299
|
-
return i
|
|
1298
|
+
res.push(new pyjslib_Tuple(["", ln]))
|
|
1299
|
+
return i
|
|
1300
1300
|
}
|
|
1301
|
-
return -1
|
|
1301
|
+
return -1
|
|
1302
1302
|
}
|
|
1303
1303
|
};
|
|
1304
1304
|
object(str, i, res) {
|
|
1305
|
-
var j = this.subject(str, i, res)
|
|
1305
|
+
var j = this.subject(str, i, res)
|
|
1306
1306
|
if ((j >= 0)) {
|
|
1307
|
-
return j
|
|
1307
|
+
return j
|
|
1308
1308
|
}
|
|
1309
1309
|
else {
|
|
1310
|
-
var j = this.skipSpace(str, i)
|
|
1310
|
+
var j = this.skipSpace(str, i)
|
|
1311
1311
|
if ((j < 0)) {
|
|
1312
|
-
return -1
|
|
1312
|
+
return -1
|
|
1313
1313
|
}
|
|
1314
1314
|
else {
|
|
1315
|
-
var i = j
|
|
1315
|
+
var i = j
|
|
1316
1316
|
}
|
|
1317
1317
|
var delim = null
|
|
1318
1318
|
let ch = str.charAt(i)
|
|
1319
1319
|
if ((ch == "\"" || ch == "'")) {
|
|
1320
1320
|
if (str.slice(i, ( i + 3 ) == ch + ch)) {
|
|
1321
|
-
delim = ch + ch + ch
|
|
1321
|
+
delim = ch + ch + ch
|
|
1322
1322
|
}
|
|
1323
1323
|
else {
|
|
1324
|
-
delim = ch
|
|
1324
|
+
delim = ch
|
|
1325
1325
|
}
|
|
1326
|
-
var i = ( i + pyjslib_len(delim) )
|
|
1327
|
-
var pairFudge = this.strconst(str, i, delim)
|
|
1328
|
-
var j = pairFudge[0]
|
|
1329
|
-
var s = pairFudge[1]
|
|
1330
|
-
res.push(this._store.literal(s))
|
|
1331
|
-
diag_progress("New string const ", s, j)
|
|
1332
|
-
return j
|
|
1326
|
+
var i = ( i + pyjslib_len(delim) )
|
|
1327
|
+
var pairFudge = this.strconst(str, i, delim)
|
|
1328
|
+
var j = pairFudge[0]
|
|
1329
|
+
var s = pairFudge[1]
|
|
1330
|
+
res.push(this._store.literal(s))
|
|
1331
|
+
diag_progress("New string const ", s, j)
|
|
1332
|
+
return j
|
|
1333
1333
|
}
|
|
1334
1334
|
else {
|
|
1335
|
-
return -1
|
|
1335
|
+
return -1
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
};
|
|
1339
1339
|
nodeOrLiteral(str, i, res) {
|
|
1340
|
-
var j = this.node(str, i, res)
|
|
1340
|
+
var j = this.node(str, i, res)
|
|
1341
1341
|
if ((j >= 0)) {
|
|
1342
|
-
return j
|
|
1342
|
+
return j
|
|
1343
1343
|
}
|
|
1344
1344
|
else {
|
|
1345
|
-
var j = this.skipSpace(str, i)
|
|
1345
|
+
var j = this.skipSpace(str, i)
|
|
1346
1346
|
if ((j < 0)) {
|
|
1347
|
-
return -1
|
|
1347
|
+
return -1
|
|
1348
1348
|
}
|
|
1349
1349
|
else {
|
|
1350
|
-
var i = j
|
|
1350
|
+
var i = j
|
|
1351
1351
|
}
|
|
1352
|
-
var ch = str.charAt(i)
|
|
1352
|
+
var ch = str.charAt(i)
|
|
1353
1353
|
if (("-+0987654321".indexOf(ch) >= 0)) {
|
|
1354
1354
|
|
|
1355
|
-
datetime_syntax.lastIndex = 0
|
|
1356
|
-
var m = datetime_syntax.exec(str.slice(i))
|
|
1355
|
+
datetime_syntax.lastIndex = 0
|
|
1356
|
+
var m = datetime_syntax.exec(str.slice(i))
|
|
1357
1357
|
if ((m != null)) {
|
|
1358
1358
|
// j = ( i + datetime_syntax.lastIndex ) ;
|
|
1359
|
-
var val = m[0]
|
|
1360
|
-
j = i + val.length
|
|
1359
|
+
var val = m[0]
|
|
1360
|
+
j = i + val.length
|
|
1361
1361
|
if ((val.indexOf("T") >= 0)) {
|
|
1362
|
-
res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)))
|
|
1362
|
+
res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)))
|
|
1363
1363
|
} else {
|
|
1364
|
-
res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)))
|
|
1364
|
+
res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)))
|
|
1365
1365
|
}
|
|
1366
1366
|
|
|
1367
1367
|
} else {
|
|
1368
|
-
number_syntax.lastIndex = 0
|
|
1369
|
-
var m = number_syntax.exec(str.slice(i))
|
|
1368
|
+
number_syntax.lastIndex = 0
|
|
1369
|
+
var m = number_syntax.exec(str.slice(i))
|
|
1370
1370
|
if ((m == null)) {
|
|
1371
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax")
|
|
1371
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax")
|
|
1372
1372
|
}
|
|
1373
|
-
j = ( i + number_syntax.lastIndex )
|
|
1374
|
-
var val = str.slice( i, j)
|
|
1373
|
+
j = ( i + number_syntax.lastIndex )
|
|
1374
|
+
var val = str.slice( i, j)
|
|
1375
1375
|
if ((val.indexOf("e") >= 0)) {
|
|
1376
|
-
res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)))
|
|
1376
|
+
res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)))
|
|
1377
1377
|
}
|
|
1378
1378
|
else if ((str.slice( i, j).indexOf(".") >= 0)) {
|
|
1379
|
-
res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)))
|
|
1379
|
+
res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)))
|
|
1380
1380
|
}
|
|
1381
1381
|
else {
|
|
1382
|
-
res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)))
|
|
1382
|
+
res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)))
|
|
1383
1383
|
}
|
|
1384
1384
|
};
|
|
1385
|
-
return j
|
|
1385
|
+
return j // Where we have got up to
|
|
1386
1386
|
}
|
|
1387
1387
|
if ((str.charAt(i) == "\"")) {
|
|
1388
1388
|
if ((str.slice( i, ( i + 3 ) ) == "\"\"\"")) {
|
|
1389
|
-
var delim = "\"\"\""
|
|
1389
|
+
var delim = "\"\"\""
|
|
1390
1390
|
}
|
|
1391
1391
|
else {
|
|
1392
|
-
var delim = "\""
|
|
1392
|
+
var delim = "\""
|
|
1393
1393
|
}
|
|
1394
|
-
var i = ( i + pyjslib_len(delim) )
|
|
1395
|
-
var dt = null
|
|
1396
|
-
var pairFudge = this.strconst(str, i, delim)
|
|
1397
|
-
var j = pairFudge[0]
|
|
1398
|
-
var s = pairFudge[1]
|
|
1399
|
-
var lang = null
|
|
1394
|
+
var i = ( i + pyjslib_len(delim) )
|
|
1395
|
+
var dt = null
|
|
1396
|
+
var pairFudge = this.strconst(str, i, delim)
|
|
1397
|
+
var j = pairFudge[0]
|
|
1398
|
+
var s = pairFudge[1]
|
|
1399
|
+
var lang = null
|
|
1400
1400
|
if ((str.slice( j, ( j + 1 ) ) == "@")) {
|
|
1401
|
-
langcode.lastIndex = 0
|
|
1401
|
+
langcode.lastIndex = 0
|
|
1402
1402
|
|
|
1403
|
-
var m = langcode.exec(str.slice( ( j + 1 ) ))
|
|
1403
|
+
var m = langcode.exec(str.slice( ( j + 1 ) ))
|
|
1404
1404
|
if ((m == null)) {
|
|
1405
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @")
|
|
1405
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @")
|
|
1406
1406
|
}
|
|
1407
|
-
var i = ( ( langcode.lastIndex + j ) + 1 )
|
|
1407
|
+
var i = ( ( langcode.lastIndex + j ) + 1 )
|
|
1408
1408
|
|
|
1409
|
-
var lang = str.slice( ( j + 1 ) , i)
|
|
1410
|
-
var j = i
|
|
1409
|
+
var lang = str.slice( ( j + 1 ) , i)
|
|
1410
|
+
var j = i
|
|
1411
1411
|
}
|
|
1412
1412
|
if ((str.slice( j, ( j + 2 ) ) == "^^")) {
|
|
1413
|
-
var res2 = new pyjslib_List([])
|
|
1414
|
-
var j = this.uri_ref2(str, ( j + 2 ) , res2)
|
|
1415
|
-
var dt = res2[0]
|
|
1413
|
+
var res2 = new pyjslib_List([])
|
|
1414
|
+
var j = this.uri_ref2(str, ( j + 2 ) , res2)
|
|
1415
|
+
var dt = res2[0]
|
|
1416
1416
|
}
|
|
1417
|
-
res.push(this._store.literal(s, lang || dt))
|
|
1418
|
-
return j
|
|
1417
|
+
res.push(this._store.literal(s, lang || dt))
|
|
1418
|
+
return j
|
|
1419
1419
|
}
|
|
1420
1420
|
else {
|
|
1421
|
-
return -1
|
|
1421
|
+
return -1
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
@@ -1428,154 +1428,154 @@ export class SinkParser {
|
|
|
1428
1428
|
return index, val
|
|
1429
1429
|
*/
|
|
1430
1430
|
|
|
1431
|
-
var j = i
|
|
1432
|
-
var ustr = ""
|
|
1433
|
-
var startline = this.lines
|
|
1431
|
+
var j = i
|
|
1432
|
+
var ustr = ""
|
|
1433
|
+
var startline = this.lines
|
|
1434
1434
|
while ((j < pyjslib_len(str))) {
|
|
1435
|
-
var i = ( j + pyjslib_len(delim) )
|
|
1435
|
+
var i = ( j + pyjslib_len(delim) )
|
|
1436
1436
|
if ((str.slice( j, i) == delim)) {
|
|
1437
|
-
return new pyjslib_Tuple([i, ustr])
|
|
1437
|
+
return new pyjslib_Tuple([i, ustr])
|
|
1438
1438
|
}
|
|
1439
1439
|
if ((str.charAt(j) == "\"")) {
|
|
1440
|
-
var ustr = ( ustr + "\"" )
|
|
1441
|
-
var j = ( j + 1 )
|
|
1442
|
-
continue
|
|
1440
|
+
var ustr = ( ustr + "\"" )
|
|
1441
|
+
var j = ( j + 1 )
|
|
1442
|
+
continue
|
|
1443
1443
|
}
|
|
1444
|
-
interesting.lastIndex = 0
|
|
1445
|
-
var m = interesting.exec(str.slice(j))
|
|
1444
|
+
interesting.lastIndex = 0
|
|
1445
|
+
var m = interesting.exec(str.slice(j))
|
|
1446
1446
|
if (!(m)) {
|
|
1447
|
-
throw BadSyntax(this._thisDoc, startline, str, j, ( ( ( "Closing quote missing in string at ^ in " + str.slice( ( j - 20 ) , j) ) + "^" ) + str.slice( j, ( j + 20 ) ) ) )
|
|
1447
|
+
throw BadSyntax(this._thisDoc, startline, str, j, ( ( ( "Closing quote missing in string at ^ in " + str.slice( ( j - 20 ) , j) ) + "^" ) + str.slice( j, ( j + 20 ) ) ) )
|
|
1448
1448
|
}
|
|
1449
|
-
var i = ( ( j + interesting.lastIndex ) - 1 )
|
|
1450
|
-
var ustr = ( ustr + str.slice( j, i) )
|
|
1451
|
-
var ch = str.charAt(i)
|
|
1449
|
+
var i = ( ( j + interesting.lastIndex ) - 1 )
|
|
1450
|
+
var ustr = ( ustr + str.slice( j, i) )
|
|
1451
|
+
var ch = str.charAt(i)
|
|
1452
1452
|
if ((ch == "\"")) {
|
|
1453
|
-
var j = i
|
|
1454
|
-
continue
|
|
1453
|
+
var j = i
|
|
1454
|
+
continue
|
|
1455
1455
|
}
|
|
1456
1456
|
else if ((ch == "\r")) {
|
|
1457
|
-
var j = ( i + 1 )
|
|
1458
|
-
continue
|
|
1457
|
+
var j = ( i + 1 )
|
|
1458
|
+
continue
|
|
1459
1459
|
}
|
|
1460
1460
|
else if ((ch == "\n")) {
|
|
1461
1461
|
if ((delim == "\"")) {
|
|
1462
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal")
|
|
1462
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal")
|
|
1463
1463
|
}
|
|
1464
|
-
this.lines = ( this.lines + 1 )
|
|
1465
|
-
var ustr = ( ustr + ch )
|
|
1466
|
-
var j = ( i + 1 )
|
|
1467
|
-
this.previousLine = this.startOfLine
|
|
1468
|
-
this.startOfLine = j
|
|
1464
|
+
this.lines = ( this.lines + 1 )
|
|
1465
|
+
var ustr = ( ustr + ch )
|
|
1466
|
+
var j = ( i + 1 )
|
|
1467
|
+
this.previousLine = this.startOfLine
|
|
1468
|
+
this.startOfLine = j
|
|
1469
1469
|
}
|
|
1470
1470
|
else if ((ch == "\\")) {
|
|
1471
|
-
var j = ( i + 1 )
|
|
1472
|
-
var ch = str.slice( j, ( j + 1 ) )
|
|
1471
|
+
var j = ( i + 1 )
|
|
1472
|
+
var ch = str.slice( j, ( j + 1 ) )
|
|
1473
1473
|
if (!(ch)) {
|
|
1474
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)")
|
|
1474
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)")
|
|
1475
1475
|
}
|
|
1476
|
-
var k = string_find("abfrtvn\\\"", ch)
|
|
1476
|
+
var k = string_find("abfrtvn\\\"", ch)
|
|
1477
1477
|
if ((k >= 0)) {
|
|
1478
|
-
var uch = "\a\b\f\r\t\v\n\\\"".charAt(k)
|
|
1479
|
-
var ustr = ( ustr + uch )
|
|
1480
|
-
var j = ( j + 1 )
|
|
1478
|
+
var uch = "\a\b\f\r\t\v\n\\\"".charAt(k)
|
|
1479
|
+
var ustr = ( ustr + uch )
|
|
1480
|
+
var j = ( j + 1 )
|
|
1481
1481
|
}
|
|
1482
1482
|
else if ((ch == "u")) {
|
|
1483
|
-
var pairFudge = this.uEscape(str, ( j + 1 ) , startline)
|
|
1484
|
-
var j = pairFudge[0]
|
|
1485
|
-
var ch = pairFudge[1]
|
|
1486
|
-
var ustr = ( ustr + ch )
|
|
1483
|
+
var pairFudge = this.uEscape(str, ( j + 1 ) , startline)
|
|
1484
|
+
var j = pairFudge[0]
|
|
1485
|
+
var ch = pairFudge[1]
|
|
1486
|
+
var ustr = ( ustr + ch )
|
|
1487
1487
|
}
|
|
1488
1488
|
else if ((ch == "U")) {
|
|
1489
|
-
var pairFudge = this.UEscape(str, ( j + 1 ) , startline)
|
|
1490
|
-
var j = pairFudge[0]
|
|
1491
|
-
var ch = pairFudge[1]
|
|
1492
|
-
var ustr = ( ustr + ch )
|
|
1489
|
+
var pairFudge = this.UEscape(str, ( j + 1 ) , startline)
|
|
1490
|
+
var j = pairFudge[0]
|
|
1491
|
+
var ch = pairFudge[1]
|
|
1492
|
+
var ustr = ( ustr + ch )
|
|
1493
1493
|
}
|
|
1494
1494
|
else {
|
|
1495
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape")
|
|
1495
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape")
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal")
|
|
1499
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal")
|
|
1500
1500
|
};
|
|
1501
1501
|
uEscape(str, i, startline) {
|
|
1502
|
-
var j = i
|
|
1503
|
-
var count = 0
|
|
1504
|
-
var value = 0
|
|
1502
|
+
var j = i
|
|
1503
|
+
var count = 0
|
|
1504
|
+
var value = 0
|
|
1505
1505
|
while ((count < 4)) {
|
|
1506
|
-
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1507
|
-
var ch = chFudge.toLowerCase()
|
|
1508
|
-
var j = ( j + 1 )
|
|
1506
|
+
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1507
|
+
var ch = chFudge.toLowerCase()
|
|
1508
|
+
var j = ( j + 1 )
|
|
1509
1509
|
if ((ch == "")) {
|
|
1510
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1510
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1511
1511
|
}
|
|
1512
|
-
var k = string_find("0123456789abcdef", ch)
|
|
1512
|
+
var k = string_find("0123456789abcdef", ch)
|
|
1513
1513
|
if ((k < 0)) {
|
|
1514
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1514
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1515
1515
|
}
|
|
1516
|
-
var value = ( ( value * 16 ) + k )
|
|
1517
|
-
var count = ( count + 1 )
|
|
1516
|
+
var value = ( ( value * 16 ) + k )
|
|
1517
|
+
var count = ( count + 1 )
|
|
1518
1518
|
}
|
|
1519
|
-
var uch = String.fromCharCode(value)
|
|
1520
|
-
return new pyjslib_Tuple([j, uch])
|
|
1519
|
+
var uch = String.fromCharCode(value)
|
|
1520
|
+
return new pyjslib_Tuple([j, uch])
|
|
1521
1521
|
};
|
|
1522
1522
|
UEscape(str, i, startline) {
|
|
1523
|
-
var j = i
|
|
1524
|
-
var count = 0
|
|
1525
|
-
var value = "\\U"
|
|
1523
|
+
var j = i
|
|
1524
|
+
var count = 0
|
|
1525
|
+
var value = "\\U"
|
|
1526
1526
|
while ((count < 8)) {
|
|
1527
|
-
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1528
|
-
var ch = chFudge.toLowerCase()
|
|
1529
|
-
var j = ( j + 1 )
|
|
1527
|
+
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1528
|
+
var ch = chFudge.toLowerCase()
|
|
1529
|
+
var j = ( j + 1 )
|
|
1530
1530
|
if ((ch == "")) {
|
|
1531
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1531
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1532
1532
|
}
|
|
1533
|
-
var k = string_find("0123456789abcdef", ch)
|
|
1533
|
+
var k = string_find("0123456789abcdef", ch)
|
|
1534
1534
|
if ((k < 0)) {
|
|
1535
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1535
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1536
1536
|
}
|
|
1537
|
-
var value = ( value + ch )
|
|
1538
|
-
var count = ( count + 1 )
|
|
1537
|
+
var value = ( value + ch )
|
|
1538
|
+
var count = ( count + 1 )
|
|
1539
1539
|
}
|
|
1540
|
-
var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) )
|
|
1541
|
-
return new pyjslib_Tuple([j, uch])
|
|
1540
|
+
var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) )
|
|
1541
|
+
return new pyjslib_Tuple([j, uch])
|
|
1542
1542
|
};
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
1545
1545
|
function OLD_BadSyntax(uri, lines, str, i, why) {
|
|
1546
|
-
return new __OLD_BadSyntax(uri, lines, str, i, why)
|
|
1546
|
+
return new __OLD_BadSyntax(uri, lines, str, i, why)
|
|
1547
1547
|
}
|
|
1548
1548
|
function __OLD_BadSyntax(uri, lines, str, i, why) {
|
|
1549
|
-
this._str = str.encode("utf-8")
|
|
1550
|
-
this._str = str
|
|
1551
|
-
this._i = i
|
|
1552
|
-
this._why = why
|
|
1553
|
-
this.lines = lines
|
|
1554
|
-
this._uri = uri
|
|
1549
|
+
this._str = str.encode("utf-8")
|
|
1550
|
+
this._str = str
|
|
1551
|
+
this._i = i
|
|
1552
|
+
this._why = why
|
|
1553
|
+
this.lines = lines
|
|
1554
|
+
this._uri = uri
|
|
1555
1555
|
}
|
|
1556
1556
|
__OLD_BadSyntax.prototype.toString = function() {
|
|
1557
|
-
var str = this._str
|
|
1558
|
-
var i = this._i
|
|
1559
|
-
var st = 0
|
|
1557
|
+
var str = this._str
|
|
1558
|
+
var i = this._i
|
|
1559
|
+
var st = 0
|
|
1560
1560
|
if ((i > 60)) {
|
|
1561
|
-
var pre = "..."
|
|
1562
|
-
var st = ( i - 60 )
|
|
1561
|
+
var pre = "..."
|
|
1562
|
+
var st = ( i - 60 )
|
|
1563
1563
|
}
|
|
1564
1564
|
else {
|
|
1565
|
-
var pre = ""
|
|
1565
|
+
var pre = ""
|
|
1566
1566
|
}
|
|
1567
1567
|
if (( ( pyjslib_len(str) - i ) > 60)) {
|
|
1568
|
-
var post = "..."
|
|
1568
|
+
var post = "..."
|
|
1569
1569
|
}
|
|
1570
1570
|
else {
|
|
1571
|
-
var post = ""
|
|
1571
|
+
var post = ""
|
|
1572
1572
|
}
|
|
1573
|
-
return "Line %i of <%s>: Bad syntax (%s) at ^ in:\n\"%s%s^%s%s\"" % new pyjslib_Tuple([ ( this.lines + 1 ) , this._uri, this._why, pre, str.slice( st, i), str.slice( i, ( i + 60 ) ), post])
|
|
1573
|
+
return "Line %i of <%s>: Bad syntax (%s) at ^ in:\n\"%s%s^%s%s\"" % new pyjslib_Tuple([ ( this.lines + 1 ) , this._uri, this._why, pre, str.slice( st, i), str.slice( i, ( i + 60 ) ), post])
|
|
1574
1574
|
}
|
|
1575
1575
|
|
|
1576
1576
|
function BadSyntax(uri, lines, str, i, why) {
|
|
1577
1577
|
let lineNo = lines + 1
|
|
1578
|
-
let msg = ( ( ( ( ( ( ( ( "Line " + ( lineNo ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + str.slice( i, ( i + 30 ) ) ) + "\"" )
|
|
1578
|
+
let msg = ( ( ( ( ( ( ( ( "Line " + ( lineNo ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + str.slice( i, ( i + 30 ) ) ) + "\"" )
|
|
1579
1579
|
let e = new SyntaxError(msg, uri , lineNo)
|
|
1580
1580
|
e.lineNo = lineNo
|
|
1581
1581
|
e.characterInFile = i
|
|
@@ -1584,26 +1584,26 @@ function BadSyntax(uri, lines, str, i, why) {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
|
|
1586
1586
|
function stripCR(str) {
|
|
1587
|
-
var res = ""
|
|
1587
|
+
var res = ""
|
|
1588
1588
|
|
|
1589
|
-
var __ch = new pyjslib_Iterator(str)
|
|
1589
|
+
var __ch = new pyjslib_Iterator(str)
|
|
1590
1590
|
try {
|
|
1591
1591
|
while (true) {
|
|
1592
|
-
var ch = __ch.next()
|
|
1592
|
+
var ch = __ch.next()
|
|
1593
1593
|
|
|
1594
1594
|
|
|
1595
1595
|
if ((ch != "\r")) {
|
|
1596
|
-
var res = ( res + ch )
|
|
1596
|
+
var res = ( res + ch )
|
|
1597
1597
|
}
|
|
1598
1598
|
|
|
1599
1599
|
}
|
|
1600
1600
|
} catch (e) {
|
|
1601
1601
|
if (e != StopIteration) {
|
|
1602
|
-
throw e
|
|
1602
|
+
throw e
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
1605
|
|
|
1606
|
-
return res
|
|
1606
|
+
return res
|
|
1607
1607
|
}
|
|
1608
1608
|
|
|
1609
1609
|
|