rdflib 2.3.1-c71dde13 → 2.3.2-075b5109
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.map +1 -1
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -7
- package/dist/rdflib.min.js.map +1 -1
- package/esm/fetcher.js +11 -2
- package/esm/n3parser.js +1 -2
- package/lib/collection.d.ts +1 -1
- package/lib/fetcher.js +11 -2
- package/lib/index.d.ts +1 -1
- package/lib/n3parser.js +1 -2
- package/lib/rdfaparser.d.ts +9 -9
- package/lib/rdfxmlparser.d.ts +1 -1
- package/lib/serializer.d.ts +3 -3
- package/lib/xsd-internal.d.ts +7 -7
- package/lib/xsd.d.ts +7 -7
- package/package.json +21 -18
- package/src/fetcher.ts +11 -2
- package/src/jsonldparser.js +2 -2
- package/src/n3parser.js +669 -670
- package/src/serializer.js +6 -6
- package/src/xsd-internal.js +1 -1
- package/src/xsd.js +4 -4
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,188 @@ 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
|
-
|
|
653
|
-
|
|
654
|
-
break;
|
|
652
|
+
if (dotTerminatesName(str, j)) {
|
|
653
|
+
break
|
|
655
654
|
}
|
|
656
655
|
}
|
|
657
|
-
var subj = res.pop()
|
|
658
|
-
var obj = this.blankNode(this.here(j))
|
|
659
|
-
var j = this.node(str, ( j + 1 ) , res)
|
|
656
|
+
var subj = res.pop()
|
|
657
|
+
var obj = this.blankNode(this.here(j))
|
|
658
|
+
var j = this.node(str, ( j + 1 ) , res)
|
|
660
659
|
if ((j < 0)) {
|
|
661
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax")
|
|
660
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in middle of path syntax")
|
|
662
661
|
}
|
|
663
|
-
var pred = res.pop()
|
|
662
|
+
var pred = res.pop()
|
|
664
663
|
if ((ch == "^")) {
|
|
665
|
-
this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]))
|
|
664
|
+
this.makeStatement(new pyjslib_Tuple([this._context, pred, obj, subj]))
|
|
666
665
|
}
|
|
667
666
|
else {
|
|
668
|
-
this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]))
|
|
667
|
+
this.makeStatement(new pyjslib_Tuple([this._context, pred, subj, obj]))
|
|
669
668
|
}
|
|
670
|
-
res.push(obj)
|
|
669
|
+
res.push(obj)
|
|
671
670
|
}
|
|
672
|
-
return j
|
|
671
|
+
return j
|
|
673
672
|
};
|
|
674
673
|
anonymousNode(ln) {
|
|
675
674
|
/*
|
|
676
675
|
Remember or generate a term for one of these _: anonymous nodes*/
|
|
677
676
|
|
|
678
|
-
var term = this._anonymousNodes[ln]
|
|
677
|
+
var term = this._anonymousNodes[ln]
|
|
679
678
|
if (term) {
|
|
680
|
-
return term
|
|
679
|
+
return term
|
|
681
680
|
}
|
|
682
|
-
var term = this._store.bnode(ln)
|
|
681
|
+
var term = this._store.bnode(ln)
|
|
683
682
|
// var term = this._store.bnode(this._context, this._reason2); eh?
|
|
684
|
-
this._anonymousNodes[ln] = ( term)
|
|
685
|
-
return term
|
|
683
|
+
this._anonymousNodes[ln] = ( term)
|
|
684
|
+
return term
|
|
686
685
|
};
|
|
687
686
|
node(str, i, res, subjectAlready) {
|
|
688
|
-
if (typeof subjectAlready == 'undefined') subjectAlready=null
|
|
687
|
+
if (typeof subjectAlready == 'undefined') subjectAlready=null
|
|
689
688
|
/*
|
|
690
689
|
Parse the <node> production.
|
|
691
690
|
Space is now skipped once at the beginning
|
|
692
691
|
instead of in multipe calls to self.skipSpace().
|
|
693
692
|
*/
|
|
694
693
|
|
|
695
|
-
var subj = subjectAlready
|
|
696
|
-
var j = this.skipSpace(str, i)
|
|
694
|
+
var subj = subjectAlready
|
|
695
|
+
var j = this.skipSpace(str, i)
|
|
697
696
|
if ((j < 0)) {
|
|
698
|
-
return j
|
|
697
|
+
return j
|
|
699
698
|
}
|
|
700
|
-
var i = j
|
|
701
|
-
var ch = str.slice( i, ( i + 1 ) )
|
|
699
|
+
var i = j
|
|
700
|
+
var ch = str.slice( i, ( i + 1 ) )
|
|
702
701
|
if ((ch == "[")) {
|
|
703
|
-
var bnodeID = this.here(i)
|
|
704
|
-
var j = this.skipSpace(str, ( i + 1 ) )
|
|
702
|
+
var bnodeID = this.here(i)
|
|
703
|
+
var j = this.skipSpace(str, ( i + 1 ) )
|
|
705
704
|
if ((j < 0)) {
|
|
706
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['")
|
|
705
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF after '['")
|
|
707
706
|
}
|
|
708
707
|
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)
|
|
708
|
+
var i = ( j + 1 )
|
|
709
|
+
var objs = new pyjslib_List([])
|
|
710
|
+
var j = this.objectList(str, i, objs)
|
|
712
711
|
|
|
713
712
|
if ((j >= 0)) {
|
|
714
|
-
var subj = objs[0]
|
|
713
|
+
var subj = objs[0]
|
|
715
714
|
if ((pyjslib_len(objs) > 1)) {
|
|
716
|
-
var __obj = new pyjslib_Iterator(objs)
|
|
715
|
+
var __obj = new pyjslib_Iterator(objs)
|
|
717
716
|
try {
|
|
718
717
|
while (true) {
|
|
719
|
-
var obj = __obj.next()
|
|
720
|
-
this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]))
|
|
718
|
+
var obj = __obj.next()
|
|
719
|
+
this.makeStatement(new pyjslib_Tuple([this._context, this._store.sym(DAML_sameAs_URI), subj, obj]))
|
|
721
720
|
}
|
|
722
721
|
} catch (e) {
|
|
723
722
|
if (e != StopIteration) {
|
|
724
|
-
throw e
|
|
723
|
+
throw e
|
|
725
724
|
}
|
|
726
725
|
}
|
|
727
726
|
}
|
|
728
|
-
var j = this.skipSpace(str, j)
|
|
727
|
+
var j = this.skipSpace(str, j)
|
|
729
728
|
if ((j < 0)) {
|
|
730
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ")
|
|
729
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when objectList expected after [ = ")
|
|
731
730
|
}
|
|
732
731
|
if ((str.slice( j, ( j + 1 ) ) == ";")) {
|
|
733
|
-
var j = ( j + 1 )
|
|
732
|
+
var j = ( j + 1 )
|
|
734
733
|
}
|
|
735
734
|
}
|
|
736
735
|
else {
|
|
737
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ")
|
|
736
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "objectList expected after [= ")
|
|
738
737
|
}
|
|
739
738
|
}
|
|
740
739
|
if ((subj == null)) {
|
|
741
|
-
var subj = this.blankNode(bnodeID)
|
|
740
|
+
var subj = this.blankNode(bnodeID)
|
|
742
741
|
}
|
|
743
|
-
var i = this.property_list(str, j, subj)
|
|
742
|
+
var i = this.property_list(str, j, subj)
|
|
744
743
|
if ((i < 0)) {
|
|
745
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected")
|
|
744
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "property_list expected")
|
|
746
745
|
}
|
|
747
|
-
var j = this.skipSpace(str, i)
|
|
746
|
+
var j = this.skipSpace(str, i)
|
|
748
747
|
if ((j < 0)) {
|
|
749
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>")
|
|
748
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF when ']' expected after [ <propertyList>")
|
|
750
749
|
}
|
|
751
750
|
if ((str.slice( j, ( j + 1 ) ) == ".")) {
|
|
752
751
|
// If a dot is found after a blank node, treat it as a statement terminator.
|
|
@@ -755,142 +754,142 @@ export class SinkParser {
|
|
|
755
754
|
// locally would bypass that unified logic and could cause inconsistencies.
|
|
756
755
|
// We do consume ']' below because it is a structural closer of the blank node,
|
|
757
756
|
// not a statement terminator.
|
|
758
|
-
res.push(subj)
|
|
759
|
-
return j
|
|
757
|
+
res.push(subj)
|
|
758
|
+
return j // leave '.' for checkDot()
|
|
760
759
|
}
|
|
761
760
|
if ((str.slice( j, ( j + 1 ) ) != "]")) {
|
|
762
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected")
|
|
761
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "']' expected")
|
|
763
762
|
}
|
|
764
|
-
res.push(subj)
|
|
765
|
-
return ( j + 1 )
|
|
763
|
+
res.push(subj)
|
|
764
|
+
return ( j + 1 )
|
|
766
765
|
}
|
|
767
766
|
if ((ch == "{")) {
|
|
768
|
-
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
767
|
+
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
769
768
|
if ((ch2 == "$")) {
|
|
770
|
-
i += 1
|
|
771
|
-
var j = ( i + 1 )
|
|
772
|
-
var mylist = new pyjslib_List([])
|
|
773
|
-
var first_run = true
|
|
769
|
+
i += 1
|
|
770
|
+
var j = ( i + 1 )
|
|
771
|
+
var mylist = new pyjslib_List([])
|
|
772
|
+
var first_run = true
|
|
774
773
|
while (1) {
|
|
775
|
-
var i = this.skipSpace(str, j)
|
|
774
|
+
var i = this.skipSpace(str, j)
|
|
776
775
|
if ((i < 0)) {
|
|
777
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.")
|
|
776
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '$}', found end.")
|
|
778
777
|
}
|
|
779
778
|
if ((str.slice( i, ( i + 2 ) ) == "$}")) {
|
|
780
|
-
var j = ( i + 2 )
|
|
781
|
-
break
|
|
779
|
+
var j = ( i + 2 )
|
|
780
|
+
break
|
|
782
781
|
}
|
|
783
782
|
if (!(first_run)) {
|
|
784
783
|
if ((str.slice( i, ( i + 1 ) ) == ",")) {
|
|
785
|
-
i += 1
|
|
784
|
+
i += 1
|
|
786
785
|
}
|
|
787
786
|
else {
|
|
788
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','")
|
|
787
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected: ','")
|
|
789
788
|
}
|
|
790
789
|
}
|
|
791
790
|
else {
|
|
792
|
-
var first_run = false
|
|
791
|
+
var first_run = false
|
|
793
792
|
}
|
|
794
|
-
var item = new pyjslib_List([])
|
|
795
|
-
var j = this.item(str, i, item)
|
|
793
|
+
var item = new pyjslib_List([])
|
|
794
|
+
var j = this.item(str, i, item)
|
|
796
795
|
if ((j < 0)) {
|
|
797
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'")
|
|
796
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in set or '$}'")
|
|
798
797
|
}
|
|
799
|
-
mylist.push(item[0])
|
|
798
|
+
mylist.push(item[0])
|
|
800
799
|
}
|
|
801
|
-
res.push(this._store.newSet(mylist, this._context))
|
|
802
|
-
return j
|
|
800
|
+
res.push(this._store.newSet(mylist, this._context))
|
|
801
|
+
return j
|
|
803
802
|
}
|
|
804
803
|
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
|
|
804
|
+
var j = ( i + 1 )
|
|
805
|
+
var oldParentContext = this._parentContext
|
|
806
|
+
this._parentContext = this._context
|
|
807
|
+
var parentAnonymousNodes = this._anonymousNodes
|
|
808
|
+
var grandParentVariables = this._parentVariables
|
|
809
|
+
this._parentVariables = this._variables
|
|
810
|
+
this._anonymousNodes = new pyjslib_Dict([])
|
|
811
|
+
this._variables = this._variables.slice()
|
|
812
|
+
var reason2 = this._reason2
|
|
813
|
+
this._reason2 = becauseSubexpression
|
|
815
814
|
if ((subj == null)) {
|
|
816
|
-
var subj = this._store.formula()
|
|
815
|
+
var subj = this._store.formula()
|
|
817
816
|
}
|
|
818
|
-
this._context = subj
|
|
817
|
+
this._context = subj
|
|
819
818
|
while (1) {
|
|
820
|
-
var i = this.skipSpace(str, j)
|
|
819
|
+
var i = this.skipSpace(str, j)
|
|
821
820
|
if ((i < 0)) {
|
|
822
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.")
|
|
821
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed '}', found end.")
|
|
823
822
|
}
|
|
824
823
|
if ((str.slice( i, ( i + 1 ) ) == "}")) {
|
|
825
|
-
var j = ( i + 1 )
|
|
826
|
-
break
|
|
824
|
+
var j = ( i + 1 )
|
|
825
|
+
break
|
|
827
826
|
}
|
|
828
|
-
var j = this.directiveOrStatement(str, i)
|
|
827
|
+
var j = this.directiveOrStatement(str, i)
|
|
829
828
|
if ((j < 0)) {
|
|
830
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'")
|
|
829
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected statement or '}'")
|
|
831
830
|
}
|
|
832
831
|
}
|
|
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
|
|
832
|
+
this._anonymousNodes = parentAnonymousNodes
|
|
833
|
+
this._variables = this._parentVariables
|
|
834
|
+
this._parentVariables = grandParentVariables
|
|
835
|
+
this._context = this._parentContext
|
|
836
|
+
this._reason2 = reason2
|
|
837
|
+
this._parentContext = oldParentContext
|
|
838
|
+
res.push(subj.close())
|
|
839
|
+
return j
|
|
841
840
|
}
|
|
842
841
|
}
|
|
843
842
|
if ((ch == "(")) {
|
|
844
|
-
var thing_type = this._store.list
|
|
845
|
-
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
843
|
+
var thing_type = this._store.list
|
|
844
|
+
var ch2 = str.slice( ( i + 1 ) , ( i + 2 ) )
|
|
846
845
|
if ((ch2 == "$")) {
|
|
847
|
-
var thing_type = this._store.newSet
|
|
848
|
-
i += 1
|
|
846
|
+
var thing_type = this._store.newSet
|
|
847
|
+
i += 1
|
|
849
848
|
}
|
|
850
|
-
var j = ( i + 1 )
|
|
851
|
-
var mylist = new pyjslib_List([])
|
|
849
|
+
var j = ( i + 1 )
|
|
850
|
+
var mylist = new pyjslib_List([])
|
|
852
851
|
while (1) {
|
|
853
|
-
var i = this.skipSpace(str, j)
|
|
852
|
+
var i = this.skipSpace(str, j)
|
|
854
853
|
if ((i < 0)) {
|
|
855
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.")
|
|
854
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "needed ')', found end.")
|
|
856
855
|
}
|
|
857
856
|
if ((str.slice( i, ( i + 1 ) ) == ")")) {
|
|
858
|
-
var j = ( i + 1 )
|
|
859
|
-
break
|
|
857
|
+
var j = ( i + 1 )
|
|
858
|
+
break
|
|
860
859
|
}
|
|
861
|
-
var item = new pyjslib_List([])
|
|
862
|
-
var j = this.item(str, i, item)
|
|
860
|
+
var item = new pyjslib_List([])
|
|
861
|
+
var j = this.item(str, i, item)
|
|
863
862
|
if ((j < 0)) {
|
|
864
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'")
|
|
863
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "expected item in list or ')'")
|
|
865
864
|
}
|
|
866
|
-
mylist.push(item[0])
|
|
865
|
+
mylist.push(item[0])
|
|
867
866
|
}
|
|
868
|
-
res.push(thing_type(mylist, this._context))
|
|
869
|
-
return j
|
|
867
|
+
res.push(thing_type(mylist, this._context))
|
|
868
|
+
return j
|
|
870
869
|
}
|
|
871
|
-
var j = this.tok("this", str, i)
|
|
870
|
+
var j = this.tok("this", str, i)
|
|
872
871
|
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
|
|
872
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Keyword 'this' was ancient N3. Now use @forSome and @forAll keywords.")
|
|
873
|
+
res.push(this._context)
|
|
874
|
+
return j
|
|
876
875
|
}
|
|
877
|
-
var j = this.tok("true", str, i)
|
|
876
|
+
var j = this.tok("true", str, i)
|
|
878
877
|
if ((j >= 0)) {
|
|
879
|
-
res.push(true)
|
|
880
|
-
return j
|
|
878
|
+
res.push(true)
|
|
879
|
+
return j
|
|
881
880
|
}
|
|
882
|
-
var j = this.tok("false", str, i)
|
|
881
|
+
var j = this.tok("false", str, i)
|
|
883
882
|
if ((j >= 0)) {
|
|
884
|
-
res.push(false)
|
|
885
|
-
return j
|
|
883
|
+
res.push(false)
|
|
884
|
+
return j
|
|
886
885
|
}
|
|
887
886
|
if ((subj == null)) {
|
|
888
|
-
var j = this.uri_ref2(str, i, res)
|
|
887
|
+
var j = this.uri_ref2(str, i, res)
|
|
889
888
|
if ((j >= 0)) {
|
|
890
|
-
return j
|
|
889
|
+
return j
|
|
891
890
|
}
|
|
892
891
|
}
|
|
893
|
-
return -1
|
|
892
|
+
return -1
|
|
894
893
|
};
|
|
895
894
|
property_list(str, i, subj) {
|
|
896
895
|
/*
|
|
@@ -899,65 +898,65 @@ export class SinkParser {
|
|
|
899
898
|
*/
|
|
900
899
|
|
|
901
900
|
while (1) {
|
|
902
|
-
var j = this.skipSpace(str, i)
|
|
901
|
+
var j = this.skipSpace(str, i)
|
|
903
902
|
if ((j < 0)) {
|
|
904
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list")
|
|
905
|
-
return j
|
|
903
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found when expected verb in property list")
|
|
904
|
+
return j
|
|
906
905
|
}
|
|
907
906
|
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)
|
|
907
|
+
var i = ( j + 2 )
|
|
908
|
+
var res = new pyjslib_List([])
|
|
909
|
+
var j = this.node(str, i, res, subj)
|
|
911
910
|
if ((j < 0)) {
|
|
912
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ")
|
|
911
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad {} or () or [] node after :- ")
|
|
913
912
|
}
|
|
914
|
-
var i = j
|
|
915
|
-
continue
|
|
913
|
+
var i = j
|
|
914
|
+
continue
|
|
916
915
|
}
|
|
917
|
-
var i = j
|
|
918
|
-
var v = new pyjslib_List([])
|
|
919
|
-
var j = this.verb(str, i, v)
|
|
916
|
+
var i = j
|
|
917
|
+
var v = new pyjslib_List([])
|
|
918
|
+
var j = this.verb(str, i, v)
|
|
920
919
|
if ((j <= 0)) {
|
|
921
|
-
return i
|
|
920
|
+
return i
|
|
922
921
|
}
|
|
923
|
-
var objs = new pyjslib_List([])
|
|
924
|
-
var i = this.objectList(str, j, objs)
|
|
922
|
+
var objs = new pyjslib_List([])
|
|
923
|
+
var i = this.objectList(str, j, objs)
|
|
925
924
|
if ((i < 0)) {
|
|
926
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected")
|
|
925
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "objectList expected")
|
|
927
926
|
}
|
|
928
927
|
|
|
929
|
-
var __obj = new pyjslib_Iterator(objs)
|
|
928
|
+
var __obj = new pyjslib_Iterator(objs)
|
|
930
929
|
try {
|
|
931
930
|
while (true) {
|
|
932
|
-
var obj = __obj.next()
|
|
931
|
+
var obj = __obj.next()
|
|
933
932
|
|
|
934
933
|
|
|
935
|
-
var pairFudge = v[0]
|
|
936
|
-
var dir = pairFudge[0]
|
|
937
|
-
var sym = pairFudge[1]
|
|
934
|
+
var pairFudge = v[0]
|
|
935
|
+
var dir = pairFudge[0]
|
|
936
|
+
var sym = pairFudge[1]
|
|
938
937
|
if ((dir == "->")) {
|
|
939
|
-
this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]))
|
|
938
|
+
this.makeStatement(new pyjslib_Tuple([this._context, sym, subj, obj]))
|
|
940
939
|
}
|
|
941
940
|
else {
|
|
942
|
-
this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]))
|
|
941
|
+
this.makeStatement(new pyjslib_Tuple([this._context, sym, obj, subj]))
|
|
943
942
|
}
|
|
944
943
|
|
|
945
944
|
}
|
|
946
945
|
} catch (e) {
|
|
947
946
|
if (e != StopIteration) {
|
|
948
|
-
throw e
|
|
947
|
+
throw e
|
|
949
948
|
}
|
|
950
949
|
}
|
|
951
950
|
|
|
952
|
-
var j = this.skipSpace(str, i)
|
|
951
|
+
var j = this.skipSpace(str, i)
|
|
953
952
|
if ((j < 0)) {
|
|
954
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects")
|
|
955
|
-
return j
|
|
953
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found in list of objects")
|
|
954
|
+
return j
|
|
956
955
|
}
|
|
957
956
|
if ((str.slice( i, ( i + 1 ) ) != ";")) {
|
|
958
|
-
return i
|
|
957
|
+
return i
|
|
959
958
|
}
|
|
960
|
-
var i = ( i + 1 )
|
|
959
|
+
var i = ( i + 1 )
|
|
961
960
|
}
|
|
962
961
|
};
|
|
963
962
|
commaSeparatedList(str, j, res, ofUris) {
|
|
@@ -969,83 +968,83 @@ export class SinkParser {
|
|
|
969
968
|
but passing the function didn't work fo js converion pyjs
|
|
970
969
|
*/
|
|
971
970
|
|
|
972
|
-
var i = this.skipSpace(str, j)
|
|
971
|
+
var i = this.skipSpace(str, j)
|
|
973
972
|
if ((i < 0)) {
|
|
974
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list")
|
|
975
|
-
return i
|
|
973
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "EOF found expecting comma sep list")
|
|
974
|
+
return i
|
|
976
975
|
}
|
|
977
976
|
if ((str.charAt(i) == ".")) {
|
|
978
|
-
return j
|
|
977
|
+
return j
|
|
979
978
|
}
|
|
980
979
|
if (ofUris) {
|
|
981
|
-
var i = this.uri_ref2(str, i, res)
|
|
980
|
+
var i = this.uri_ref2(str, i, res)
|
|
982
981
|
}
|
|
983
982
|
else {
|
|
984
|
-
var i = this.bareWord(str, i, res)
|
|
983
|
+
var i = this.bareWord(str, i, res)
|
|
985
984
|
}
|
|
986
985
|
if ((i < 0)) {
|
|
987
|
-
return -1
|
|
986
|
+
return -1
|
|
988
987
|
}
|
|
989
988
|
while (1) {
|
|
990
|
-
var j = this.skipSpace(str, i)
|
|
989
|
+
var j = this.skipSpace(str, i)
|
|
991
990
|
if ((j < 0)) {
|
|
992
|
-
return j
|
|
991
|
+
return j
|
|
993
992
|
}
|
|
994
|
-
var ch = str.slice( j, ( j + 1 ) )
|
|
993
|
+
var ch = str.slice( j, ( j + 1 ) )
|
|
995
994
|
if ((ch != ",")) {
|
|
996
995
|
if ((ch != ".")) {
|
|
997
|
-
return -1
|
|
996
|
+
return -1
|
|
998
997
|
}
|
|
999
|
-
return j
|
|
998
|
+
return j
|
|
1000
999
|
}
|
|
1001
1000
|
if (ofUris) {
|
|
1002
|
-
var i = this.uri_ref2(str, ( j + 1 ) , res)
|
|
1001
|
+
var i = this.uri_ref2(str, ( j + 1 ) , res)
|
|
1003
1002
|
}
|
|
1004
1003
|
else {
|
|
1005
|
-
var i = this.bareWord(str, ( j + 1 ) , res)
|
|
1004
|
+
var i = this.bareWord(str, ( j + 1 ) , res)
|
|
1006
1005
|
}
|
|
1007
1006
|
if ((i < 0)) {
|
|
1008
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content")
|
|
1009
|
-
return i
|
|
1007
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad list content")
|
|
1008
|
+
return i
|
|
1010
1009
|
}
|
|
1011
1010
|
}
|
|
1012
1011
|
};
|
|
1013
1012
|
objectList(str, i, res) {
|
|
1014
|
-
var i = this.object(str, i, res)
|
|
1013
|
+
var i = this.object(str, i, res)
|
|
1015
1014
|
if ((i < 0)) {
|
|
1016
|
-
return -1
|
|
1015
|
+
return -1
|
|
1017
1016
|
}
|
|
1018
1017
|
while (1) {
|
|
1019
|
-
var j = this.skipSpace(str, i)
|
|
1018
|
+
var j = this.skipSpace(str, i)
|
|
1020
1019
|
if ((j < 0)) {
|
|
1021
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object")
|
|
1022
|
-
return j
|
|
1020
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "EOF found after object")
|
|
1021
|
+
return j
|
|
1023
1022
|
}
|
|
1024
1023
|
if ((str.slice( j, ( j + 1 ) ) != ",")) {
|
|
1025
|
-
return j
|
|
1024
|
+
return j
|
|
1026
1025
|
}
|
|
1027
|
-
var i = this.object(str, ( j + 1 ) , res)
|
|
1026
|
+
var i = this.object(str, ( j + 1 ) , res)
|
|
1028
1027
|
if ((i < 0)) {
|
|
1029
|
-
return i
|
|
1028
|
+
return i
|
|
1030
1029
|
}
|
|
1031
1030
|
}
|
|
1032
1031
|
};
|
|
1033
1032
|
checkDot(str, i) {
|
|
1034
|
-
var j = this.skipSpace(str, i)
|
|
1033
|
+
var j = this.skipSpace(str, i)
|
|
1035
1034
|
if ((j < 0)) {
|
|
1036
|
-
return j
|
|
1035
|
+
return j
|
|
1037
1036
|
}
|
|
1038
1037
|
if ((str.slice( j, ( j + 1 ) ) == ".")) {
|
|
1039
|
-
return ( j + 1 )
|
|
1038
|
+
return ( j + 1 )
|
|
1040
1039
|
}
|
|
1041
1040
|
if ((str.slice( j, ( j + 1 ) ) == "}")) {
|
|
1042
|
-
return j
|
|
1041
|
+
return j
|
|
1043
1042
|
}
|
|
1044
1043
|
if ((str.slice( j, ( j + 1 ) ) == "]")) {
|
|
1045
|
-
return j
|
|
1044
|
+
return j
|
|
1046
1045
|
}
|
|
1047
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement")
|
|
1048
|
-
return i
|
|
1046
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "expected '.' or '}' or ']' at end of statement")
|
|
1047
|
+
return i
|
|
1049
1048
|
};
|
|
1050
1049
|
uri_ref2(str, i, res) {
|
|
1051
1050
|
/*
|
|
@@ -1056,90 +1055,90 @@ export class SinkParser {
|
|
|
1056
1055
|
to make the namesapces look more like what XML folks expect.
|
|
1057
1056
|
*/
|
|
1058
1057
|
|
|
1059
|
-
var qn = new pyjslib_List([])
|
|
1060
|
-
var j = this.qname(str, i, qn)
|
|
1058
|
+
var qn = new pyjslib_List([])
|
|
1059
|
+
var j = this.qname(str, i, qn)
|
|
1061
1060
|
if ((j >= 0)) {
|
|
1062
|
-
var pairFudge = qn[0]
|
|
1063
|
-
var pfx = pairFudge[0]
|
|
1064
|
-
var ln = pairFudge[1]
|
|
1061
|
+
var pairFudge = qn[0]
|
|
1062
|
+
var pfx = pairFudge[0]
|
|
1063
|
+
var ln = pairFudge[1]
|
|
1065
1064
|
if ((pfx == null)) {
|
|
1066
|
-
assertFudge(0, "not used?")
|
|
1067
|
-
var ns = ( this._baseURI + ADDED_HASH )
|
|
1065
|
+
assertFudge(0, "not used?")
|
|
1066
|
+
var ns = ( this._baseURI + ADDED_HASH )
|
|
1068
1067
|
}
|
|
1069
1068
|
else {
|
|
1070
|
-
var ns = this._bindings[pfx]
|
|
1069
|
+
var ns = this._bindings[pfx]
|
|
1071
1070
|
if (!(ns)) {
|
|
1072
1071
|
if ((pfx == "_")) {
|
|
1073
|
-
res.push(this.anonymousNode(ln))
|
|
1074
|
-
return j
|
|
1072
|
+
res.push(this.anonymousNode(ln))
|
|
1073
|
+
return j
|
|
1075
1074
|
}
|
|
1076
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Prefix " + pfx ) + " not bound." ) )
|
|
1075
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Prefix " + pfx ) + " not bound." ) )
|
|
1077
1076
|
}
|
|
1078
1077
|
}
|
|
1079
|
-
var symb = this._store.sym( ( ns + ln ) )
|
|
1078
|
+
var symb = this._store.sym( ( ns + ln ) )
|
|
1080
1079
|
if ((ArrayIndexOf(this._variables, symb) >= 0)) {
|
|
1081
|
-
res.push(this._variables[symb])
|
|
1080
|
+
res.push(this._variables[symb])
|
|
1082
1081
|
}
|
|
1083
1082
|
else {
|
|
1084
|
-
res.push(symb)
|
|
1083
|
+
res.push(symb)
|
|
1085
1084
|
}
|
|
1086
|
-
return j
|
|
1085
|
+
return j
|
|
1087
1086
|
}
|
|
1088
|
-
var i = this.skipSpace(str, i)
|
|
1087
|
+
var i = this.skipSpace(str, i)
|
|
1089
1088
|
if ((i < 0)) {
|
|
1090
|
-
return -1
|
|
1089
|
+
return -1
|
|
1091
1090
|
}
|
|
1092
1091
|
if ((str.charAt(i) == "?")) {
|
|
1093
|
-
var v = new pyjslib_List([])
|
|
1094
|
-
var j = this.variable(str, i, v)
|
|
1092
|
+
var v = new pyjslib_List([])
|
|
1093
|
+
var j = this.variable(str, i, v)
|
|
1095
1094
|
if ((j > 0)) {
|
|
1096
|
-
res.push(v[0])
|
|
1097
|
-
return j
|
|
1095
|
+
res.push(v[0])
|
|
1096
|
+
return j
|
|
1098
1097
|
}
|
|
1099
|
-
return -1
|
|
1098
|
+
return -1
|
|
1100
1099
|
}
|
|
1101
1100
|
else if ((str.charAt(i) == "<")) {
|
|
1102
|
-
var i = ( i + 1 )
|
|
1103
|
-
var st = i
|
|
1101
|
+
var i = ( i + 1 )
|
|
1102
|
+
var st = i
|
|
1104
1103
|
while ((i < pyjslib_len(str))) {
|
|
1105
1104
|
if ((str.charAt(i) == ">")) {
|
|
1106
|
-
var uref = str.slice( st, i)
|
|
1105
|
+
var uref = str.slice( st, i)
|
|
1107
1106
|
if (this._baseURI) {
|
|
1108
|
-
var uref = uripath_join(this._baseURI, uref)
|
|
1107
|
+
var uref = uripath_join(this._baseURI, uref)
|
|
1109
1108
|
}
|
|
1110
1109
|
else {
|
|
1111
|
-
assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs")
|
|
1110
|
+
assertFudge((uref.indexOf(":") >= 0), "With no base URI, cannot deal with relative URIs")
|
|
1112
1111
|
}
|
|
1113
1112
|
if ((str.slice( ( i - 1 ) , i) == "#") && !((pyjslib_slice(uref, -1, null) == "#"))) {
|
|
1114
|
-
var uref = ( uref + "#" )
|
|
1113
|
+
var uref = ( uref + "#" )
|
|
1115
1114
|
}
|
|
1116
|
-
var symb = this._store.sym(uref)
|
|
1115
|
+
var symb = this._store.sym(uref)
|
|
1117
1116
|
if ((ArrayIndexOf(this._variables,symb) >= 0)) {
|
|
1118
|
-
res.push(this._variables[symb])
|
|
1117
|
+
res.push(this._variables[symb])
|
|
1119
1118
|
}
|
|
1120
1119
|
else {
|
|
1121
|
-
res.push(symb)
|
|
1120
|
+
res.push(symb)
|
|
1122
1121
|
}
|
|
1123
|
-
return ( i + 1 )
|
|
1122
|
+
return ( i + 1 )
|
|
1124
1123
|
}
|
|
1125
|
-
var i = ( i + 1 )
|
|
1124
|
+
var i = ( i + 1 )
|
|
1126
1125
|
}
|
|
1127
|
-
throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference")
|
|
1126
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, "unterminated URI reference")
|
|
1128
1127
|
}
|
|
1129
1128
|
else if (this.keywordsSet) {
|
|
1130
|
-
var v = new pyjslib_List([])
|
|
1131
|
-
var j = this.bareWord(str, i, v)
|
|
1129
|
+
var v = new pyjslib_List([])
|
|
1130
|
+
var j = this.bareWord(str, i, v)
|
|
1132
1131
|
if ((j < 0)) {
|
|
1133
|
-
return -1
|
|
1132
|
+
return -1
|
|
1134
1133
|
}
|
|
1135
1134
|
if ((ArrayIndexOf(this.keywords, v[0]) >= 0)) {
|
|
1136
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) )
|
|
1135
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, ( ( "Keyword \"" + v[0] ) + "\" not allowed here." ) )
|
|
1137
1136
|
}
|
|
1138
|
-
res.push(this._store.sym( ( this._bindings[""] + v[0] ) ))
|
|
1139
|
-
return j
|
|
1137
|
+
res.push(this._store.sym( ( this._bindings[""] + v[0] ) ))
|
|
1138
|
+
return j
|
|
1140
1139
|
}
|
|
1141
1140
|
else {
|
|
1142
|
-
return -1
|
|
1141
|
+
return -1
|
|
1143
1142
|
}
|
|
1144
1143
|
};
|
|
1145
1144
|
skipSpace(str, i) {
|
|
@@ -1147,9 +1146,9 @@ export class SinkParser {
|
|
|
1147
1146
|
Skip white space, newlines and comments.
|
|
1148
1147
|
return -1 if EOF, else position of first non-ws character*/
|
|
1149
1148
|
|
|
1150
|
-
var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'
|
|
1149
|
+
var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000'
|
|
1151
1150
|
for (var j = (i ? i : 0); j < str.length; j++) {
|
|
1152
|
-
var ch = str.charAt(j)
|
|
1151
|
+
var ch = str.charAt(j)
|
|
1153
1152
|
// console.log(" skipspace j= "+j + " i= " + i + " n= " + str.length);
|
|
1154
1153
|
// console.log(" skipspace ch <" + ch + ">");
|
|
1155
1154
|
if (whitespace.indexOf(ch) < 0 ) { //not ws
|
|
@@ -1158,11 +1157,11 @@ export class SinkParser {
|
|
|
1158
1157
|
for (;; j++) {
|
|
1159
1158
|
// console.log(" skipspace2 j= "+j + " i= " + i + " n= " + str.length);
|
|
1160
1159
|
if (j === str.length) {
|
|
1161
|
-
return -1
|
|
1160
|
+
return -1 // EOF
|
|
1162
1161
|
}
|
|
1163
1162
|
if (str.charAt(j) === '\n') {
|
|
1164
|
-
this.lines = this.lines + 1
|
|
1165
|
-
break
|
|
1163
|
+
this.lines = this.lines + 1
|
|
1164
|
+
break
|
|
1166
1165
|
}
|
|
1167
1166
|
};
|
|
1168
1167
|
} else { // Not hash - something interesting
|
|
@@ -1172,11 +1171,11 @@ export class SinkParser {
|
|
|
1172
1171
|
} else { // Whitespace
|
|
1173
1172
|
// console.log(" skipspace 5 ch <" + ch + ">");
|
|
1174
1173
|
if (str.charAt(j) === '\n') {
|
|
1175
|
-
this.lines = this.lines + 1
|
|
1174
|
+
this.lines = this.lines + 1
|
|
1176
1175
|
}
|
|
1177
1176
|
}
|
|
1178
1177
|
} // next j
|
|
1179
|
-
return -1
|
|
1178
|
+
return -1 // EOF
|
|
1180
1179
|
};
|
|
1181
1180
|
|
|
1182
1181
|
variable(str, i, res) {
|
|
@@ -1184,60 +1183,60 @@ export class SinkParser {
|
|
|
1184
1183
|
?abc -> variable(:abc)
|
|
1185
1184
|
*/
|
|
1186
1185
|
|
|
1187
|
-
var j = this.skipSpace(str, i)
|
|
1186
|
+
var j = this.skipSpace(str, i)
|
|
1188
1187
|
if ((j < 0)) {
|
|
1189
|
-
return -1
|
|
1188
|
+
return -1
|
|
1190
1189
|
}
|
|
1191
1190
|
if ((str.slice( j, ( j + 1 ) ) != "?")) {
|
|
1192
|
-
return -1
|
|
1191
|
+
return -1
|
|
1193
1192
|
}
|
|
1194
|
-
var j = ( j + 1 )
|
|
1195
|
-
var i = j
|
|
1193
|
+
var j = ( j + 1 )
|
|
1194
|
+
var i = j
|
|
1196
1195
|
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
|
|
1196
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ( ( "Varible name can't start with '" + str.charAt(j) ) + "s'" ) )
|
|
1197
|
+
return -1
|
|
1199
1198
|
}
|
|
1200
1199
|
while ((i < pyjslib_len(str)) && (_notNameChars.indexOf(str.charAt(i)) < 0)) {
|
|
1201
|
-
var i = ( i + 1 )
|
|
1200
|
+
var i = ( i + 1 )
|
|
1202
1201
|
}
|
|
1203
1202
|
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) ) )
|
|
1203
|
+
throw BadSyntax(this._thisDoc, this.lines, str, j, ( "Can't use ?xxx syntax for variable in outermost level: " + str.slice( ( j - 1 ) , i) ) )
|
|
1205
1204
|
}
|
|
1206
|
-
res.push(this._store.variable(str.slice( j, i)))
|
|
1207
|
-
return i
|
|
1205
|
+
res.push(this._store.variable(str.slice( j, i)))
|
|
1206
|
+
return i
|
|
1208
1207
|
};
|
|
1209
1208
|
bareWord(str, i, res) {
|
|
1210
1209
|
/*
|
|
1211
1210
|
abc -> :abc
|
|
1212
1211
|
*/
|
|
1213
1212
|
|
|
1214
|
-
var j = this.skipSpace(str, i)
|
|
1213
|
+
var j = this.skipSpace(str, i)
|
|
1215
1214
|
if ((j < 0)) {
|
|
1216
|
-
return -1
|
|
1215
|
+
return -1
|
|
1217
1216
|
}
|
|
1218
|
-
var ch = str.charAt(j)
|
|
1217
|
+
var ch = str.charAt(j)
|
|
1219
1218
|
if (("0123456789-".indexOf(ch) >= 0)) {
|
|
1220
|
-
return -1
|
|
1219
|
+
return -1
|
|
1221
1220
|
}
|
|
1222
1221
|
if ((_notNameChars.indexOf(ch) >= 0)) {
|
|
1223
|
-
return -1
|
|
1222
|
+
return -1
|
|
1224
1223
|
}
|
|
1225
|
-
var i = j
|
|
1224
|
+
var i = j
|
|
1226
1225
|
while ((i < pyjslib_len(str))) {
|
|
1227
|
-
var c = str.charAt(i)
|
|
1226
|
+
var c = str.charAt(i)
|
|
1228
1227
|
if (c === '.') {
|
|
1229
1228
|
if (dotTerminatesName(str, i)) {
|
|
1230
|
-
break
|
|
1229
|
+
break // treat as statement terminator, not part of name
|
|
1231
1230
|
}
|
|
1232
1231
|
// else: accept '.' as part of name
|
|
1233
1232
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1234
1233
|
// Other invalid characters terminate the name
|
|
1235
|
-
break
|
|
1234
|
+
break
|
|
1236
1235
|
}
|
|
1237
|
-
var i = ( i + 1 )
|
|
1236
|
+
var i = ( i + 1 )
|
|
1238
1237
|
}
|
|
1239
|
-
res.push(str.slice( j, i))
|
|
1240
|
-
return i
|
|
1238
|
+
res.push(str.slice( j, i))
|
|
1239
|
+
return i
|
|
1241
1240
|
};
|
|
1242
1241
|
qname(str, i, res) {
|
|
1243
1242
|
/*
|
|
@@ -1247,178 +1246,178 @@ export class SinkParser {
|
|
|
1247
1246
|
:def -> ('', 'def')
|
|
1248
1247
|
*/
|
|
1249
1248
|
|
|
1250
|
-
var i = this.skipSpace(str, i)
|
|
1249
|
+
var i = this.skipSpace(str, i)
|
|
1251
1250
|
if ((i < 0)) {
|
|
1252
|
-
return -1
|
|
1251
|
+
return -1
|
|
1253
1252
|
}
|
|
1254
|
-
var c = str.charAt(i)
|
|
1253
|
+
var c = str.charAt(i)
|
|
1255
1254
|
if (("0123456789-+".indexOf(c) >= 0)) {
|
|
1256
|
-
return -1
|
|
1255
|
+
return -1
|
|
1257
1256
|
}
|
|
1258
1257
|
if ((_notNameChars.indexOf(c) < 0)) {
|
|
1259
|
-
var ln = c
|
|
1260
|
-
var i = ( i + 1 )
|
|
1258
|
+
var ln = c
|
|
1259
|
+
var i = ( i + 1 )
|
|
1261
1260
|
while ((i < pyjslib_len(str))) {
|
|
1262
|
-
var c = str.charAt(i)
|
|
1261
|
+
var c = str.charAt(i)
|
|
1263
1262
|
if (c === '.') {
|
|
1264
1263
|
if (dotTerminatesName(str, i)) {
|
|
1265
|
-
break
|
|
1264
|
+
break // dot ends the name here
|
|
1266
1265
|
}
|
|
1267
1266
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1268
|
-
break
|
|
1267
|
+
break
|
|
1269
1268
|
}
|
|
1270
|
-
var ln = ( ln + c )
|
|
1271
|
-
var i = ( i + 1 )
|
|
1269
|
+
var ln = ( ln + c )
|
|
1270
|
+
var i = ( i + 1 )
|
|
1272
1271
|
}
|
|
1273
1272
|
}
|
|
1274
1273
|
else {
|
|
1275
|
-
var ln = ""
|
|
1274
|
+
var ln = ""
|
|
1276
1275
|
}
|
|
1277
1276
|
if ((i < pyjslib_len(str)) && (str.charAt(i) == ":")) {
|
|
1278
|
-
var pfx = ln
|
|
1279
|
-
var i = ( i + 1 )
|
|
1280
|
-
var ln = ""
|
|
1277
|
+
var pfx = ln
|
|
1278
|
+
var i = ( i + 1 )
|
|
1279
|
+
var ln = ""
|
|
1281
1280
|
while ((i < pyjslib_len(str))) {
|
|
1282
|
-
var c = str.charAt(i)
|
|
1281
|
+
var c = str.charAt(i)
|
|
1283
1282
|
if (c === '.') {
|
|
1284
1283
|
if (dotTerminatesName(str, i)) {
|
|
1285
|
-
break
|
|
1284
|
+
break // dot ends the name here
|
|
1286
1285
|
}
|
|
1287
1286
|
} else if (_notNameChars.indexOf(c) >= 0) {
|
|
1288
|
-
break
|
|
1287
|
+
break
|
|
1289
1288
|
}
|
|
1290
|
-
var ln = ( ln + c )
|
|
1291
|
-
var i = ( i + 1 )
|
|
1289
|
+
var ln = ( ln + c )
|
|
1290
|
+
var i = ( i + 1 )
|
|
1292
1291
|
}
|
|
1293
|
-
res.push(new pyjslib_Tuple([pfx, ln]))
|
|
1294
|
-
return i
|
|
1292
|
+
res.push(new pyjslib_Tuple([pfx, ln]))
|
|
1293
|
+
return i
|
|
1295
1294
|
}
|
|
1296
1295
|
else {
|
|
1297
1296
|
if (ln && this.keywordsSet && (ArrayIndexOf(this.keywords, ln) < 0)) {
|
|
1298
|
-
res.push(new pyjslib_Tuple(["", ln]))
|
|
1299
|
-
return i
|
|
1297
|
+
res.push(new pyjslib_Tuple(["", ln]))
|
|
1298
|
+
return i
|
|
1300
1299
|
}
|
|
1301
|
-
return -1
|
|
1300
|
+
return -1
|
|
1302
1301
|
}
|
|
1303
1302
|
};
|
|
1304
1303
|
object(str, i, res) {
|
|
1305
|
-
var j = this.subject(str, i, res)
|
|
1304
|
+
var j = this.subject(str, i, res)
|
|
1306
1305
|
if ((j >= 0)) {
|
|
1307
|
-
return j
|
|
1306
|
+
return j
|
|
1308
1307
|
}
|
|
1309
1308
|
else {
|
|
1310
|
-
var j = this.skipSpace(str, i)
|
|
1309
|
+
var j = this.skipSpace(str, i)
|
|
1311
1310
|
if ((j < 0)) {
|
|
1312
|
-
return -1
|
|
1311
|
+
return -1
|
|
1313
1312
|
}
|
|
1314
1313
|
else {
|
|
1315
|
-
var i = j
|
|
1314
|
+
var i = j
|
|
1316
1315
|
}
|
|
1317
1316
|
var delim = null
|
|
1318
1317
|
let ch = str.charAt(i)
|
|
1319
1318
|
if ((ch == "\"" || ch == "'")) {
|
|
1320
1319
|
if (str.slice(i, ( i + 3 ) == ch + ch)) {
|
|
1321
|
-
delim = ch + ch + ch
|
|
1320
|
+
delim = ch + ch + ch
|
|
1322
1321
|
}
|
|
1323
1322
|
else {
|
|
1324
|
-
delim = ch
|
|
1323
|
+
delim = ch
|
|
1325
1324
|
}
|
|
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
|
|
1325
|
+
var i = ( i + pyjslib_len(delim) )
|
|
1326
|
+
var pairFudge = this.strconst(str, i, delim)
|
|
1327
|
+
var j = pairFudge[0]
|
|
1328
|
+
var s = pairFudge[1]
|
|
1329
|
+
res.push(this._store.literal(s))
|
|
1330
|
+
diag_progress("New string const ", s, j)
|
|
1331
|
+
return j
|
|
1333
1332
|
}
|
|
1334
1333
|
else {
|
|
1335
|
-
return -1
|
|
1334
|
+
return -1
|
|
1336
1335
|
}
|
|
1337
1336
|
}
|
|
1338
1337
|
};
|
|
1339
1338
|
nodeOrLiteral(str, i, res) {
|
|
1340
|
-
var j = this.node(str, i, res)
|
|
1339
|
+
var j = this.node(str, i, res)
|
|
1341
1340
|
if ((j >= 0)) {
|
|
1342
|
-
return j
|
|
1341
|
+
return j
|
|
1343
1342
|
}
|
|
1344
1343
|
else {
|
|
1345
|
-
var j = this.skipSpace(str, i)
|
|
1344
|
+
var j = this.skipSpace(str, i)
|
|
1346
1345
|
if ((j < 0)) {
|
|
1347
|
-
return -1
|
|
1346
|
+
return -1
|
|
1348
1347
|
}
|
|
1349
1348
|
else {
|
|
1350
|
-
var i = j
|
|
1349
|
+
var i = j
|
|
1351
1350
|
}
|
|
1352
|
-
var ch = str.charAt(i)
|
|
1351
|
+
var ch = str.charAt(i)
|
|
1353
1352
|
if (("-+0987654321".indexOf(ch) >= 0)) {
|
|
1354
1353
|
|
|
1355
|
-
datetime_syntax.lastIndex = 0
|
|
1356
|
-
var m = datetime_syntax.exec(str.slice(i))
|
|
1354
|
+
datetime_syntax.lastIndex = 0
|
|
1355
|
+
var m = datetime_syntax.exec(str.slice(i))
|
|
1357
1356
|
if ((m != null)) {
|
|
1358
1357
|
// j = ( i + datetime_syntax.lastIndex ) ;
|
|
1359
|
-
var val = m[0]
|
|
1360
|
-
j = i + val.length
|
|
1358
|
+
var val = m[0]
|
|
1359
|
+
j = i + val.length
|
|
1361
1360
|
if ((val.indexOf("T") >= 0)) {
|
|
1362
|
-
res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)))
|
|
1361
|
+
res.push(this._store.literal(val, this._store.sym(DATETIME_DATATYPE)))
|
|
1363
1362
|
} else {
|
|
1364
|
-
res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)))
|
|
1363
|
+
res.push(this._store.literal(val, this._store.sym(DATE_DATATYPE)))
|
|
1365
1364
|
}
|
|
1366
1365
|
|
|
1367
1366
|
} else {
|
|
1368
|
-
number_syntax.lastIndex = 0
|
|
1369
|
-
var m = number_syntax.exec(str.slice(i))
|
|
1367
|
+
number_syntax.lastIndex = 0
|
|
1368
|
+
var m = number_syntax.exec(str.slice(i))
|
|
1370
1369
|
if ((m == null)) {
|
|
1371
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax")
|
|
1370
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "Bad number or date syntax")
|
|
1372
1371
|
}
|
|
1373
|
-
j = ( i + number_syntax.lastIndex )
|
|
1374
|
-
var val = str.slice( i, j)
|
|
1372
|
+
j = ( i + number_syntax.lastIndex )
|
|
1373
|
+
var val = str.slice( i, j)
|
|
1375
1374
|
if ((val.indexOf("e") >= 0)) {
|
|
1376
|
-
res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)))
|
|
1375
|
+
res.push(this._store.literal(parseFloat(val), this._store.sym(FLOAT_DATATYPE)))
|
|
1377
1376
|
}
|
|
1378
1377
|
else if ((str.slice( i, j).indexOf(".") >= 0)) {
|
|
1379
|
-
res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)))
|
|
1378
|
+
res.push(this._store.literal(parseFloat(val), this._store.sym(DECIMAL_DATATYPE)))
|
|
1380
1379
|
}
|
|
1381
1380
|
else {
|
|
1382
|
-
res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)))
|
|
1381
|
+
res.push(this._store.literal(parseInt(val), this._store.sym(INTEGER_DATATYPE)))
|
|
1383
1382
|
}
|
|
1384
1383
|
};
|
|
1385
|
-
return j
|
|
1384
|
+
return j // Where we have got up to
|
|
1386
1385
|
}
|
|
1387
1386
|
if ((str.charAt(i) == "\"")) {
|
|
1388
1387
|
if ((str.slice( i, ( i + 3 ) ) == "\"\"\"")) {
|
|
1389
|
-
var delim = "\"\"\""
|
|
1388
|
+
var delim = "\"\"\""
|
|
1390
1389
|
}
|
|
1391
1390
|
else {
|
|
1392
|
-
var delim = "\""
|
|
1391
|
+
var delim = "\""
|
|
1393
1392
|
}
|
|
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
|
|
1393
|
+
var i = ( i + pyjslib_len(delim) )
|
|
1394
|
+
var dt = null
|
|
1395
|
+
var pairFudge = this.strconst(str, i, delim)
|
|
1396
|
+
var j = pairFudge[0]
|
|
1397
|
+
var s = pairFudge[1]
|
|
1398
|
+
var lang = null
|
|
1400
1399
|
if ((str.slice( j, ( j + 1 ) ) == "@")) {
|
|
1401
|
-
langcode.lastIndex = 0
|
|
1400
|
+
langcode.lastIndex = 0
|
|
1402
1401
|
|
|
1403
|
-
var m = langcode.exec(str.slice( ( j + 1 ) ))
|
|
1402
|
+
var m = langcode.exec(str.slice( ( j + 1 ) ))
|
|
1404
1403
|
if ((m == null)) {
|
|
1405
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @")
|
|
1404
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "Bad language code syntax on string literal, after @")
|
|
1406
1405
|
}
|
|
1407
|
-
var i = ( ( langcode.lastIndex + j ) + 1 )
|
|
1406
|
+
var i = ( ( langcode.lastIndex + j ) + 1 )
|
|
1408
1407
|
|
|
1409
|
-
var lang = str.slice( ( j + 1 ) , i)
|
|
1410
|
-
var j = i
|
|
1408
|
+
var lang = str.slice( ( j + 1 ) , i)
|
|
1409
|
+
var j = i
|
|
1411
1410
|
}
|
|
1412
1411
|
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]
|
|
1412
|
+
var res2 = new pyjslib_List([])
|
|
1413
|
+
var j = this.uri_ref2(str, ( j + 2 ) , res2)
|
|
1414
|
+
var dt = res2[0]
|
|
1416
1415
|
}
|
|
1417
|
-
res.push(this._store.literal(s, lang || dt))
|
|
1418
|
-
return j
|
|
1416
|
+
res.push(this._store.literal(s, lang || dt))
|
|
1417
|
+
return j
|
|
1419
1418
|
}
|
|
1420
1419
|
else {
|
|
1421
|
-
return -1
|
|
1420
|
+
return -1
|
|
1422
1421
|
}
|
|
1423
1422
|
}
|
|
1424
1423
|
};
|
|
@@ -1428,154 +1427,154 @@ export class SinkParser {
|
|
|
1428
1427
|
return index, val
|
|
1429
1428
|
*/
|
|
1430
1429
|
|
|
1431
|
-
var j = i
|
|
1432
|
-
var ustr = ""
|
|
1433
|
-
var startline = this.lines
|
|
1430
|
+
var j = i
|
|
1431
|
+
var ustr = ""
|
|
1432
|
+
var startline = this.lines
|
|
1434
1433
|
while ((j < pyjslib_len(str))) {
|
|
1435
|
-
var i = ( j + pyjslib_len(delim) )
|
|
1434
|
+
var i = ( j + pyjslib_len(delim) )
|
|
1436
1435
|
if ((str.slice( j, i) == delim)) {
|
|
1437
|
-
return new pyjslib_Tuple([i, ustr])
|
|
1436
|
+
return new pyjslib_Tuple([i, ustr])
|
|
1438
1437
|
}
|
|
1439
1438
|
if ((str.charAt(j) == "\"")) {
|
|
1440
|
-
var ustr = ( ustr + "\"" )
|
|
1441
|
-
var j = ( j + 1 )
|
|
1442
|
-
continue
|
|
1439
|
+
var ustr = ( ustr + "\"" )
|
|
1440
|
+
var j = ( j + 1 )
|
|
1441
|
+
continue
|
|
1443
1442
|
}
|
|
1444
|
-
interesting.lastIndex = 0
|
|
1445
|
-
var m = interesting.exec(str.slice(j))
|
|
1443
|
+
interesting.lastIndex = 0
|
|
1444
|
+
var m = interesting.exec(str.slice(j))
|
|
1446
1445
|
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 ) ) ) )
|
|
1446
|
+
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
1447
|
}
|
|
1449
|
-
var i = ( ( j + interesting.lastIndex ) - 1 )
|
|
1450
|
-
var ustr = ( ustr + str.slice( j, i) )
|
|
1451
|
-
var ch = str.charAt(i)
|
|
1448
|
+
var i = ( ( j + interesting.lastIndex ) - 1 )
|
|
1449
|
+
var ustr = ( ustr + str.slice( j, i) )
|
|
1450
|
+
var ch = str.charAt(i)
|
|
1452
1451
|
if ((ch == "\"")) {
|
|
1453
|
-
var j = i
|
|
1454
|
-
continue
|
|
1452
|
+
var j = i
|
|
1453
|
+
continue
|
|
1455
1454
|
}
|
|
1456
1455
|
else if ((ch == "\r")) {
|
|
1457
|
-
var j = ( i + 1 )
|
|
1458
|
-
continue
|
|
1456
|
+
var j = ( i + 1 )
|
|
1457
|
+
continue
|
|
1459
1458
|
}
|
|
1460
1459
|
else if ((ch == "\n")) {
|
|
1461
1460
|
if ((delim == "\"")) {
|
|
1462
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal")
|
|
1461
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "newline found in string literal")
|
|
1463
1462
|
}
|
|
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
|
|
1463
|
+
this.lines = ( this.lines + 1 )
|
|
1464
|
+
var ustr = ( ustr + ch )
|
|
1465
|
+
var j = ( i + 1 )
|
|
1466
|
+
this.previousLine = this.startOfLine
|
|
1467
|
+
this.startOfLine = j
|
|
1469
1468
|
}
|
|
1470
1469
|
else if ((ch == "\\")) {
|
|
1471
|
-
var j = ( i + 1 )
|
|
1472
|
-
var ch = str.slice( j, ( j + 1 ) )
|
|
1470
|
+
var j = ( i + 1 )
|
|
1471
|
+
var ch = str.slice( j, ( j + 1 ) )
|
|
1473
1472
|
if (!(ch)) {
|
|
1474
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)")
|
|
1473
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal (2)")
|
|
1475
1474
|
}
|
|
1476
|
-
var k = string_find("abfrtvn\\\"", ch)
|
|
1475
|
+
var k = string_find("abfrtvn\\\"", ch)
|
|
1477
1476
|
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 )
|
|
1477
|
+
var uch = "\a\b\f\r\t\v\n\\\"".charAt(k)
|
|
1478
|
+
var ustr = ( ustr + uch )
|
|
1479
|
+
var j = ( j + 1 )
|
|
1481
1480
|
}
|
|
1482
1481
|
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 )
|
|
1482
|
+
var pairFudge = this.uEscape(str, ( j + 1 ) , startline)
|
|
1483
|
+
var j = pairFudge[0]
|
|
1484
|
+
var ch = pairFudge[1]
|
|
1485
|
+
var ustr = ( ustr + ch )
|
|
1487
1486
|
}
|
|
1488
1487
|
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 )
|
|
1488
|
+
var pairFudge = this.UEscape(str, ( j + 1 ) , startline)
|
|
1489
|
+
var j = pairFudge[0]
|
|
1490
|
+
var ch = pairFudge[1]
|
|
1491
|
+
var ustr = ( ustr + ch )
|
|
1493
1492
|
}
|
|
1494
1493
|
else {
|
|
1495
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape")
|
|
1494
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "bad escape")
|
|
1496
1495
|
}
|
|
1497
1496
|
}
|
|
1498
1497
|
}
|
|
1499
|
-
throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal")
|
|
1498
|
+
throw BadSyntax(this._thisDoc, this.lines, str, i, "unterminated string literal")
|
|
1500
1499
|
};
|
|
1501
1500
|
uEscape(str, i, startline) {
|
|
1502
|
-
var j = i
|
|
1503
|
-
var count = 0
|
|
1504
|
-
var value = 0
|
|
1501
|
+
var j = i
|
|
1502
|
+
var count = 0
|
|
1503
|
+
var value = 0
|
|
1505
1504
|
while ((count < 4)) {
|
|
1506
|
-
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1507
|
-
var ch = chFudge.toLowerCase()
|
|
1508
|
-
var j = ( j + 1 )
|
|
1505
|
+
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1506
|
+
var ch = chFudge.toLowerCase()
|
|
1507
|
+
var j = ( j + 1 )
|
|
1509
1508
|
if ((ch == "")) {
|
|
1510
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1509
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1511
1510
|
}
|
|
1512
|
-
var k = string_find("0123456789abcdef", ch)
|
|
1511
|
+
var k = string_find("0123456789abcdef", ch)
|
|
1513
1512
|
if ((k < 0)) {
|
|
1514
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1513
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1515
1514
|
}
|
|
1516
|
-
var value = ( ( value * 16 ) + k )
|
|
1517
|
-
var count = ( count + 1 )
|
|
1515
|
+
var value = ( ( value * 16 ) + k )
|
|
1516
|
+
var count = ( count + 1 )
|
|
1518
1517
|
}
|
|
1519
|
-
var uch = String.fromCharCode(value)
|
|
1520
|
-
return new pyjslib_Tuple([j, uch])
|
|
1518
|
+
var uch = String.fromCharCode(value)
|
|
1519
|
+
return new pyjslib_Tuple([j, uch])
|
|
1521
1520
|
};
|
|
1522
1521
|
UEscape(str, i, startline) {
|
|
1523
|
-
var j = i
|
|
1524
|
-
var count = 0
|
|
1525
|
-
var value = "\\U"
|
|
1522
|
+
var j = i
|
|
1523
|
+
var count = 0
|
|
1524
|
+
var value = "\\U"
|
|
1526
1525
|
while ((count < 8)) {
|
|
1527
|
-
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1528
|
-
var ch = chFudge.toLowerCase()
|
|
1529
|
-
var j = ( j + 1 )
|
|
1526
|
+
var chFudge = str.slice( j, ( j + 1 ) )
|
|
1527
|
+
var ch = chFudge.toLowerCase()
|
|
1528
|
+
var j = ( j + 1 )
|
|
1530
1529
|
if ((ch == "")) {
|
|
1531
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1530
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "unterminated string literal(3)")
|
|
1532
1531
|
}
|
|
1533
|
-
var k = string_find("0123456789abcdef", ch)
|
|
1532
|
+
var k = string_find("0123456789abcdef", ch)
|
|
1534
1533
|
if ((k < 0)) {
|
|
1535
|
-
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1534
|
+
throw BadSyntax(this._thisDoc, startline, str, i, "bad string literal hex escape")
|
|
1536
1535
|
}
|
|
1537
|
-
var value = ( value + ch )
|
|
1538
|
-
var count = ( count + 1 )
|
|
1536
|
+
var value = ( value + ch )
|
|
1537
|
+
var count = ( count + 1 )
|
|
1539
1538
|
}
|
|
1540
|
-
var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) )
|
|
1541
|
-
return new pyjslib_Tuple([j, uch])
|
|
1539
|
+
var uch = stringFromCharCode( ( ( "0x" + pyjslib_slice(value, 2, 10) ) - 0 ) )
|
|
1540
|
+
return new pyjslib_Tuple([j, uch])
|
|
1542
1541
|
};
|
|
1543
1542
|
}
|
|
1544
1543
|
|
|
1545
1544
|
function OLD_BadSyntax(uri, lines, str, i, why) {
|
|
1546
|
-
return new __OLD_BadSyntax(uri, lines, str, i, why)
|
|
1545
|
+
return new __OLD_BadSyntax(uri, lines, str, i, why)
|
|
1547
1546
|
}
|
|
1548
1547
|
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
|
|
1548
|
+
this._str = str.encode("utf-8")
|
|
1549
|
+
this._str = str
|
|
1550
|
+
this._i = i
|
|
1551
|
+
this._why = why
|
|
1552
|
+
this.lines = lines
|
|
1553
|
+
this._uri = uri
|
|
1555
1554
|
}
|
|
1556
1555
|
__OLD_BadSyntax.prototype.toString = function() {
|
|
1557
|
-
var str = this._str
|
|
1558
|
-
var i = this._i
|
|
1559
|
-
var st = 0
|
|
1556
|
+
var str = this._str
|
|
1557
|
+
var i = this._i
|
|
1558
|
+
var st = 0
|
|
1560
1559
|
if ((i > 60)) {
|
|
1561
|
-
var pre = "..."
|
|
1562
|
-
var st = ( i - 60 )
|
|
1560
|
+
var pre = "..."
|
|
1561
|
+
var st = ( i - 60 )
|
|
1563
1562
|
}
|
|
1564
1563
|
else {
|
|
1565
|
-
var pre = ""
|
|
1564
|
+
var pre = ""
|
|
1566
1565
|
}
|
|
1567
1566
|
if (( ( pyjslib_len(str) - i ) > 60)) {
|
|
1568
|
-
var post = "..."
|
|
1567
|
+
var post = "..."
|
|
1569
1568
|
}
|
|
1570
1569
|
else {
|
|
1571
|
-
var post = ""
|
|
1570
|
+
var post = ""
|
|
1572
1571
|
}
|
|
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])
|
|
1572
|
+
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
1573
|
}
|
|
1575
1574
|
|
|
1576
1575
|
function BadSyntax(uri, lines, str, i, why) {
|
|
1577
1576
|
let lineNo = lines + 1
|
|
1578
|
-
let msg = ( ( ( ( ( ( ( ( "Line " + ( lineNo ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + str.slice( i, ( i + 30 ) ) ) + "\"" )
|
|
1577
|
+
let msg = ( ( ( ( ( ( ( ( "Line " + ( lineNo ) ) + " of <" ) + uri ) + ">: Bad syntax: " ) + why ) + "\nat: \"" ) + str.slice( i, ( i + 30 ) ) ) + "\"" )
|
|
1579
1578
|
let e = new SyntaxError(msg, uri , lineNo)
|
|
1580
1579
|
e.lineNo = lineNo
|
|
1581
1580
|
e.characterInFile = i
|
|
@@ -1584,26 +1583,26 @@ function BadSyntax(uri, lines, str, i, why) {
|
|
|
1584
1583
|
}
|
|
1585
1584
|
|
|
1586
1585
|
function stripCR(str) {
|
|
1587
|
-
var res = ""
|
|
1586
|
+
var res = ""
|
|
1588
1587
|
|
|
1589
|
-
var __ch = new pyjslib_Iterator(str)
|
|
1588
|
+
var __ch = new pyjslib_Iterator(str)
|
|
1590
1589
|
try {
|
|
1591
1590
|
while (true) {
|
|
1592
|
-
var ch = __ch.next()
|
|
1591
|
+
var ch = __ch.next()
|
|
1593
1592
|
|
|
1594
1593
|
|
|
1595
1594
|
if ((ch != "\r")) {
|
|
1596
|
-
var res = ( res + ch )
|
|
1595
|
+
var res = ( res + ch )
|
|
1597
1596
|
}
|
|
1598
1597
|
|
|
1599
1598
|
}
|
|
1600
1599
|
} catch (e) {
|
|
1601
1600
|
if (e != StopIteration) {
|
|
1602
|
-
throw e
|
|
1601
|
+
throw e
|
|
1603
1602
|
}
|
|
1604
1603
|
}
|
|
1605
1604
|
|
|
1606
|
-
return res
|
|
1605
|
+
return res
|
|
1607
1606
|
}
|
|
1608
1607
|
|
|
1609
1608
|
|