terminus 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +25 -19
- data/bin/terminus +1 -1
- data/lib/capybara/driver/terminus.rb +28 -17
- data/lib/terminus.rb +29 -15
- data/lib/terminus/application.rb +5 -11
- data/lib/terminus/browser.rb +97 -44
- data/lib/terminus/client.rb +43 -0
- data/lib/terminus/client/browser.rb +30 -0
- data/lib/terminus/client/phantom.js +6 -0
- data/lib/terminus/client/phantomjs.rb +20 -0
- data/lib/terminus/connector.rb +9 -0
- data/lib/terminus/connector/server.rb +142 -0
- data/lib/terminus/connector/socket_handler.rb +72 -0
- data/lib/terminus/controller.rb +22 -5
- data/lib/terminus/host.rb +7 -2
- data/lib/terminus/node.rb +11 -5
- data/lib/terminus/proxy.rb +35 -1
- data/lib/terminus/proxy/driver_body.rb +26 -6
- data/lib/terminus/proxy/external.rb +9 -0
- data/lib/terminus/proxy/rewrite.rb +4 -2
- data/lib/terminus/public/compiled/terminus-min.js +3 -0
- data/lib/terminus/public/compiled/terminus.js +5270 -0
- data/lib/terminus/public/loader.js +1 -1
- data/lib/terminus/public/pathology.js +3174 -0
- data/lib/terminus/public/syn/browsers.js +2 -2
- data/lib/terminus/public/syn/drag/drag.js +3 -4
- data/lib/terminus/public/syn/key.js +130 -111
- data/lib/terminus/public/syn/mouse.js +2 -2
- data/lib/terminus/public/syn/synthetic.js +45 -34
- data/lib/terminus/public/terminus.js +183 -70
- data/lib/terminus/server.rb +6 -0
- data/lib/terminus/timeouts.rb +4 -2
- data/lib/terminus/views/bootstrap.erb +12 -27
- data/lib/terminus/views/index.erb +1 -1
- data/spec/reports/android.txt +875 -0
- data/spec/reports/chrome.txt +137 -8
- data/spec/reports/firefox.txt +137 -9
- data/spec/reports/opera.txt +142 -13
- data/spec/reports/phantomjs.txt +871 -0
- data/spec/reports/safari.txt +137 -8
- data/spec/spec_helper.rb +19 -17
- data/spec/terminus_driver_spec.rb +8 -6
- data/spec/terminus_session_spec.rb +4 -4
- metadata +209 -117
@@ -1 +1 @@
|
|
1
|
-
(function(){var a=(typeof this.global==='object')?this.global:this;a.JS=a.JS||{};JS.ENV=a})();JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._5(this);this._0=a;this._2=new b();this._6=new b();this.
|
1
|
+
(function(){var a=(typeof this.global==='object')?this.global:this;a.JS=a.JS||{};JS.ENV=a})();JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._5(this);this._0=a;this._2=new b();this._6=new b();this._d=new b();this._e=new b();this._3={};this._7={}};(function(d){d.displayName='Package';d.toString=function(){return d.displayName};d.log=function(a){if(typeof window==='undefined')return;if(typeof window.runtime==='object')window.runtime.trace(a);if(window.console&&console.info)console.info(a)};var p=d.OrderedSet=function(a){this._f=this.list=[];this._5={};if(!a)return;for(var b=0,c=a.length;b<c;b++)this.push(a[b])};p.prototype.push=function(a){var b=(a.id!==undefined)?a.id:a,c=this._5;if(c.hasOwnProperty(b))return;c[b]=this._f.length;this._f.push(a)};var m=d.Deferred=function(){this._g='deferred';this._h=null;this._i=[]};m.prototype.callback=function(a,b){if(this._g==='succeeded')a.call(b,this._h);else this._i.push([a,b])};m.prototype.succeed=function(a){this._g='succeeded';this._h=a;var b;while(b=this._i.shift())b[0].call(b[1],a)};d.ENV=JS.ENV;d.onerror=function(a){throw a};d._j=function(a){d.onerror(new Error(a));};var l=d.prototype,n=[['requires','_6'],['uses','_d'],['styling','_e']],o=n.length;while(o--)(function(pair){var q=pair[0],r=pair[1];l[q]=function(){var a=arguments.length,b;for(b=0;b<a;b++)this[r].push(arguments[b]);return this}})(n[o]);l.provides=function(){var a=arguments.length,b;for(b=0;b<a;b++){this._2.push(arguments[b]);d._8(arguments[b]).pkg=this}return this};l.setup=function(a){this._k=a;return this};l._r=function(a,b,c){if(this._7[a])return b.call(c);var e=this._3[a]=this._3[a]||[];e.push([b,c]);this._s()};l._1=function(a){if(this._7[a])return false;this._7[a]=true;var b=this._3[a];if(!b)return true;delete this._3[a];for(var c=0,e=b.length;c<e;c++)b[c][0].call(b[c][1]);return true};l._l=function(a){if(!a&&this.__isLoaded!==undefined)return this.__isLoaded;var b=this._2.list,c=b.length,e,h;while(c--){e=b[c];h=d._4(e,this._m);if(h!==undefined)continue;if(a)return d._j('Expected package at '+this._0+' to define '+e);else return this.__isLoaded=false}return this.__isLoaded=true};l._s=function(){if(!this._1('request'))return;this._t();var i=this._6.list.concat(this._d.list),g=this._9||[],k=(this._0||{}).length,j=this;d.when({load:i});d.when({complete:this._6.list},function(){d.when({complete:i,load:[this]},function(){this._1('complete')},this);var c=function(a){if(k===0)return e(a);k-=1;var b=j._0.length-k-1;d.Loader.loadFile(j._0[b],c,g[b])};var e=function(a){j._m=a;if(j._k)j._k();j._l(true);j._1('load')};if(this._l()){this._1('download');return this._1('load')}if(this._0===undefined)return d._j('No load path found for '+this._2.list[0]);if(typeof this._0==='function')this._0(e);else c();if(!d.Loader.loadStyle)return;var h=this._e.list,f=h.length;while(f--)d.Loader.loadStyle(h[f]);this._1('download')},this)};l._t=function(){if(this._9||!(this._0 instanceof Array)||!d.Loader.fetch)return;this._9=[];for(var a=0,b=this._0.length;a<b;a++)this._9[a]=d.Loader.fetch(this._0[a])};l.toString=function(){return'Package:'+this._2.list.join(',')};d.when=function(a,b,c){var e=[],h={},f,i,g;for(f in a){if(!a.hasOwnProperty(f))continue;h[f]=[];i=new d.OrderedSet(a[f]);g=i.list.length;while(g--)e.push([f,i.list[g],g])}var k=g=e.length;if(k===0)return b&&b.call(c,h);while(g--)(function(f){var j=d._a(f[1]);j._r(f[0],function(){h[f[0]][f[2]]=d._4(f[1],j._m);k-=1;if(k===0&&b)b.call(c,h)})})(e[g])};d._n=1;d._b={};d._c={};d._o=[];d._5=function(a){a.id=this._n;this._n+=1};d._p=function(a){var b=a.toString(),c=this._b[b];if(c)return c;if(typeof a==='string')a=[].slice.call(arguments);c=this._b[b]=new this(a);return c};d._a=function(a){if(typeof a!=='string')return a;var b=this._8(a);if(b.pkg)return b.pkg;var c=this._u(a);if(c)return c;var e=new this();e.provides(a);return e};d.remove=function(a){var b=this._a(a);delete this._c[a];delete this._b[b._0]};d._v=function(a,b){this._o.push([a,b])};d._u=function(e){var h=this._o,f=h.length,i,g,k;for(i=0;i<f;i++){g=h[i];if(!g[0].test(e))continue;k=g[1].from+'/'+e.replace(/([a-z])([A-Z])/g,function(a,b,c){return b+'_'+c}).replace(/\./g,'/').toLowerCase()+'.js';var j=new this([k]);j.provides(e);if(k=g[1].require)j.requires(e.replace(g[0],k));return j}return null};d._8=function(a){return this._c[a]=this._c[a]||{}};d._4=function(a,b){if(typeof a!=='string')return undefined;var c=b?{}:this._8(a);if(c.obj!==undefined)return c.obj;var e=b||this.ENV,h=a.split('.'),f;while(f=h.shift())e=e&&e[f];if(b&&e===undefined)return this._4(a);return c.obj=e}})(JS.Package);JS.Package.DomLoader={HOST_REGEX:/^https?\:\/\/[^\/]+/i,usable:function(){return!!JS.Package._4('window.document.getElementsByTagName')},__FILE__:function(){var a=document.getElementsByTagName('script');src=a[a.length-1].src,url=window.location.href;if(/^\w+\:\/+/.test(src))return src;if(/^\//.test(src))return window.location.origin+src;return url.replace(/[^\/]*$/g,'')+src},cacheBust:function(a){var b=new Date().getTime();return a+(/\?/.test(a)?'&':'?')+b},fetch:function(a){var b=a;if(JS.cacheBust)a=this.cacheBust(a);this.HOST=this.HOST||this.HOST_REGEX.exec(window.location.href);var c=this.HOST_REGEX.exec(a);if(!this.HOST||(c&&c[0]!==this.HOST[0]))return null;JS.Package.log('Loading '+a);var e=new JS.Package.Deferred(),h=this,f=window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();f.open('GET',a,true);f.onreadystatechange=function(){if(f.readyState!==4)return;f.onreadystatechange=h._q;e.succeed(f.responseText+'\n//@ sourceURL='+b);f=null};f.send(null);return e},loadFile:function(c,e,h){if(JS.cacheBust&&!h)c=this.cacheBust(c);var f=this,i=document.getElementsByTagName('head')[0],g=document.createElement('script');g.type='text/javascript';if(h)return h.callback(function(code){JS.Package.log('Executing '+c);eval(code);e()});JS.Package.log('Loading and executing '+c);g.src=c;g.onload=g.onreadystatechange=function(){var a=g.readyState,b=g.status;if(!a||a==='loaded'||a==='complete'||(a===4&&b===200)){e();g.onload=g.onreadystatechange=f._q;i=null;g=null}};i.appendChild(g)},loadStyle:function(a){var b=document.createElement('link');b.rel='stylesheet';b.type='text/css';b.href=a;document.getElementsByTagName('head')[0].appendChild(b)},_q:function(){}};JS.Package.Loader=JS.Package.DomLoader;JS.Package.DSL={__FILE__:function(){return JS.Package.Loader.__FILE__()},pkg:function(a,b){var c=b?JS.Package._p(b):JS.Package._a(a);c.provides(a);return c},file:function(){return JS.Package._p.apply(JS.Package,arguments)},load:function(a,b){JS.Package.Loader.loadFile(a,b)},autoload:function(a,b){JS.Package._v(a,b)}};JS.Package.DSL.files=JS.Package.DSL.file;JS.Package.DSL.loader=JS.Package.DSL.file;JS.Packages=function(a){a.call(JS.Package.DSL)};JS.cacheBust=false;JS.load=function(a,b){JS.Package.Loader.loadFile(a,function(){if(typeof b==='function')b()});return this};JS.require=function(){var b=[],c=0;while(typeof arguments[c]==='string'){b.push(arguments[c]);c+=1}var e=arguments[c],h=arguments[c+1];JS.Package.when({complete:b},function(a){if(!e)return;e.apply(h||null,a&&a.complete)});return this};
|
@@ -0,0 +1,3174 @@
|
|
1
|
+
var Pathology = {
|
2
|
+
evaluate: function(xpathExpression, context, nsResolver, resultType, result) {
|
3
|
+
result = result || new Pathology.XPathResult(resultType);
|
4
|
+
var expression = Pathology.XPathParser.parse(xpathExpression);
|
5
|
+
expression.evaluate(context, context, resultType, result);
|
6
|
+
return result;
|
7
|
+
},
|
8
|
+
|
9
|
+
atomize: function(expression, context, root) {
|
10
|
+
var result = expression.evaluate(context, root);
|
11
|
+
if (result && result.atomize) result = result.atomize();
|
12
|
+
return result;
|
13
|
+
},
|
14
|
+
|
15
|
+
array: function(list) {
|
16
|
+
if (!list) return [];
|
17
|
+
var array = [], i = list.length;
|
18
|
+
while (i--) array[i] = list[i];
|
19
|
+
return array;
|
20
|
+
},
|
21
|
+
|
22
|
+
indexOf: function(list, item) {
|
23
|
+
if (list.indexOf) return list.indexOf(item);
|
24
|
+
for (var i = 0, n = list.length; i < n; i++) {
|
25
|
+
if (list[i] === item) return i;
|
26
|
+
}
|
27
|
+
return -1;
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
if (typeof XPathResult === 'undefined') {
|
32
|
+
XPathResult = {
|
33
|
+
ANY_TYPE: 0,
|
34
|
+
NUMBER_TYPE: 1,
|
35
|
+
STRING_TYPE: 2,
|
36
|
+
BOOLEAN_TYPE: 3,
|
37
|
+
UNORDERED_NODE_ITERATOR_TYPE: 4,
|
38
|
+
ORDERED_NODE_ITERATOR_TYPE: 5,
|
39
|
+
UNORDERED_NODE_SNAPSHOT_TYPE: 6,
|
40
|
+
ORDERED_NODE_SNAPSHOT_TYPE: 7,
|
41
|
+
ANY_UNORDERED_NODE_TYPE: 8,
|
42
|
+
FIRST_ORDERED_NODE_TYPE: 9
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
if (typeof document.evaluate === 'undefined') {
|
47
|
+
document.evaluate = function() {
|
48
|
+
return Pathology.evaluate.apply(Pathology, arguments);
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
Pathology.XPathResult = function(resultType) {
|
54
|
+
this._type = resultType;
|
55
|
+
this._nodes = [];
|
56
|
+
this._index = 0;
|
57
|
+
};
|
58
|
+
|
59
|
+
Pathology.XPathResult.prototype.push = function(node) {
|
60
|
+
if (this._type !== 0 && node.nodeType !== this._type) return;
|
61
|
+
if (Pathology.indexOf(this._nodes, node) >= 0) return;
|
62
|
+
this._nodes.push(node);
|
63
|
+
};
|
64
|
+
|
65
|
+
Pathology.XPathResult.prototype.iterateNext = function() {
|
66
|
+
var node = this._nodes[this._index];
|
67
|
+
if (!node) return null;
|
68
|
+
this._index += 1;
|
69
|
+
return node;
|
70
|
+
};
|
71
|
+
|
72
|
+
Pathology.XPathResult.prototype.atomize = function() {
|
73
|
+
if (this._nodes.length === 0) return null;
|
74
|
+
if (this._nodes.length === 1) {
|
75
|
+
var node = this._nodes[0];
|
76
|
+
if (node.nodeValue === undefined || node.nodeValue === null) return node;
|
77
|
+
return node.nodeValue;
|
78
|
+
} else {
|
79
|
+
var nodes = [];
|
80
|
+
for (var i = 0, n = this._nodes.length; i < n; i++) nodes.push(this._nodes[i].nodeValue);
|
81
|
+
return nodes;
|
82
|
+
}
|
83
|
+
};
|
84
|
+
|
85
|
+
Pathology.XPathResult.prototype.makeString = function() {
|
86
|
+
var first = this._nodes[0];
|
87
|
+
if (!first) return '';
|
88
|
+
|
89
|
+
switch (first.nodeType) {
|
90
|
+
case XPathResult.STRING_TYPE:
|
91
|
+
return this.atomize();
|
92
|
+
|
93
|
+
case XPathResult.BOOLEAN_TYPE:
|
94
|
+
var parts = [];
|
95
|
+
for (var i = 0, n = this._nodes.length; i < n; i++)
|
96
|
+
parts.push(this._nodes[i].nodeValue);
|
97
|
+
return parts.join('');
|
98
|
+
|
99
|
+
default:
|
100
|
+
var result = document.evaluate('//text()', first, null, XPathResult.ANY_TYPE, null);
|
101
|
+
return result.makeString();
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
|
106
|
+
(function() {
|
107
|
+
var extend = function (destination, source) {
|
108
|
+
if (!destination || !source) return destination;
|
109
|
+
for (var key in source) {
|
110
|
+
if (destination[key] !== source[key])
|
111
|
+
destination[key] = source[key];
|
112
|
+
}
|
113
|
+
return destination;
|
114
|
+
};
|
115
|
+
|
116
|
+
var find = function (root, objectName) {
|
117
|
+
var parts = objectName.split('.'),
|
118
|
+
part;
|
119
|
+
|
120
|
+
while (part = parts.shift()) {
|
121
|
+
root = root[part];
|
122
|
+
if (root === undefined)
|
123
|
+
throw new Error('Cannot find object named ' + objectName);
|
124
|
+
}
|
125
|
+
return root;
|
126
|
+
};
|
127
|
+
|
128
|
+
var formatError = function (error) {
|
129
|
+
var lines = error.input.split(/\n/g),
|
130
|
+
lineNo = 0,
|
131
|
+
offset = 0;
|
132
|
+
|
133
|
+
while (offset < error.offset + 1) {
|
134
|
+
offset += lines[lineNo].length + 1;
|
135
|
+
lineNo += 1;
|
136
|
+
}
|
137
|
+
var message = 'Line ' + lineNo + ': expected ' + error.expected + '\n',
|
138
|
+
line = lines[lineNo - 1];
|
139
|
+
|
140
|
+
message += line + '\n';
|
141
|
+
offset -= line.length + 1;
|
142
|
+
|
143
|
+
while (offset < error.offset) {
|
144
|
+
message += ' ';
|
145
|
+
offset += 1;
|
146
|
+
}
|
147
|
+
return message + '^';
|
148
|
+
};
|
149
|
+
|
150
|
+
var Grammar = {
|
151
|
+
__consume__union_expression: function(input) {
|
152
|
+
var address0 = null, index0 = this._offset;
|
153
|
+
this._nodeCache["union_expression"] = this._nodeCache["union_expression"] || {};
|
154
|
+
var cached = this._nodeCache["union_expression"][index0];
|
155
|
+
if (cached) {
|
156
|
+
this._offset += cached.textValue.length;
|
157
|
+
return cached;
|
158
|
+
}
|
159
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
160
|
+
var address1 = null;
|
161
|
+
address1 = this.__consume__location_path();
|
162
|
+
if (address1) {
|
163
|
+
elements0.push(address1);
|
164
|
+
text0 += address1.textValue;
|
165
|
+
labelled0.head = address1;
|
166
|
+
var address2 = null;
|
167
|
+
var remaining0 = 0, index2 = this._offset, elements1 = [], text1 = "", address3 = true;
|
168
|
+
while (address3) {
|
169
|
+
var index3 = this._offset, elements2 = [], labelled1 = {}, text2 = "";
|
170
|
+
var address4 = null;
|
171
|
+
address4 = this.__consume__space();
|
172
|
+
if (address4) {
|
173
|
+
elements2.push(address4);
|
174
|
+
text2 += address4.textValue;
|
175
|
+
labelled1.space = address4;
|
176
|
+
var address5 = null;
|
177
|
+
var slice0 = null;
|
178
|
+
if (this._input.length > this._offset) {
|
179
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
180
|
+
} else {
|
181
|
+
slice0 = null;
|
182
|
+
}
|
183
|
+
if (slice0 === "|") {
|
184
|
+
var klass0 = this.constructor.SyntaxNode;
|
185
|
+
var type0 = null;
|
186
|
+
address5 = new klass0("|", this._offset, []);
|
187
|
+
if (typeof type0 === "object") {
|
188
|
+
extend(address5, type0);
|
189
|
+
}
|
190
|
+
this._offset += 1;
|
191
|
+
} else {
|
192
|
+
address5 = null;
|
193
|
+
var slice1 = null;
|
194
|
+
if (this._input.length > this._offset) {
|
195
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
196
|
+
} else {
|
197
|
+
slice1 = null;
|
198
|
+
}
|
199
|
+
if (!this.error || this.error.offset <= this._offset) {
|
200
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"|\""};
|
201
|
+
}
|
202
|
+
}
|
203
|
+
if (address5) {
|
204
|
+
elements2.push(address5);
|
205
|
+
text2 += address5.textValue;
|
206
|
+
var address6 = null;
|
207
|
+
address6 = this.__consume__space();
|
208
|
+
if (address6) {
|
209
|
+
elements2.push(address6);
|
210
|
+
text2 += address6.textValue;
|
211
|
+
labelled1.space = address6;
|
212
|
+
var address7 = null;
|
213
|
+
address7 = this.__consume__location_path();
|
214
|
+
if (address7) {
|
215
|
+
elements2.push(address7);
|
216
|
+
text2 += address7.textValue;
|
217
|
+
labelled1.location_path = address7;
|
218
|
+
} else {
|
219
|
+
elements2 = null;
|
220
|
+
this._offset = index3;
|
221
|
+
}
|
222
|
+
} else {
|
223
|
+
elements2 = null;
|
224
|
+
this._offset = index3;
|
225
|
+
}
|
226
|
+
} else {
|
227
|
+
elements2 = null;
|
228
|
+
this._offset = index3;
|
229
|
+
}
|
230
|
+
} else {
|
231
|
+
elements2 = null;
|
232
|
+
this._offset = index3;
|
233
|
+
}
|
234
|
+
if (elements2) {
|
235
|
+
this._offset = index3;
|
236
|
+
var klass1 = this.constructor.SyntaxNode;
|
237
|
+
var type1 = null;
|
238
|
+
address3 = new klass1(text2, this._offset, elements2, labelled1);
|
239
|
+
if (typeof type1 === "object") {
|
240
|
+
extend(address3, type1);
|
241
|
+
}
|
242
|
+
this._offset += text2.length;
|
243
|
+
} else {
|
244
|
+
address3 = null;
|
245
|
+
}
|
246
|
+
if (address3) {
|
247
|
+
elements1.push(address3);
|
248
|
+
text1 += address3.textValue;
|
249
|
+
remaining0 -= 1;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
if (remaining0 <= 0) {
|
253
|
+
this._offset = index2;
|
254
|
+
var klass2 = this.constructor.SyntaxNode;
|
255
|
+
var type2 = null;
|
256
|
+
address2 = new klass2(text1, this._offset, elements1);
|
257
|
+
if (typeof type2 === "object") {
|
258
|
+
extend(address2, type2);
|
259
|
+
}
|
260
|
+
this._offset += text1.length;
|
261
|
+
} else {
|
262
|
+
address2 = null;
|
263
|
+
}
|
264
|
+
if (address2) {
|
265
|
+
elements0.push(address2);
|
266
|
+
text0 += address2.textValue;
|
267
|
+
labelled0.rest = address2;
|
268
|
+
} else {
|
269
|
+
elements0 = null;
|
270
|
+
this._offset = index1;
|
271
|
+
}
|
272
|
+
} else {
|
273
|
+
elements0 = null;
|
274
|
+
this._offset = index1;
|
275
|
+
}
|
276
|
+
if (elements0) {
|
277
|
+
this._offset = index1;
|
278
|
+
var klass3 = this.constructor.SyntaxNode;
|
279
|
+
var type3 = find(this.constructor, "Union");
|
280
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
281
|
+
if (typeof type3 === "object") {
|
282
|
+
extend(address0, type3);
|
283
|
+
}
|
284
|
+
this._offset += text0.length;
|
285
|
+
} else {
|
286
|
+
address0 = null;
|
287
|
+
}
|
288
|
+
return this._nodeCache["union_expression"][index0] = address0;
|
289
|
+
},
|
290
|
+
__consume__location_path: function(input) {
|
291
|
+
var address0 = null, index0 = this._offset;
|
292
|
+
this._nodeCache["location_path"] = this._nodeCache["location_path"] || {};
|
293
|
+
var cached = this._nodeCache["location_path"][index0];
|
294
|
+
if (cached) {
|
295
|
+
this._offset += cached.textValue.length;
|
296
|
+
return cached;
|
297
|
+
}
|
298
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
299
|
+
var address1 = null;
|
300
|
+
address1 = this.__consume__location_step();
|
301
|
+
if (address1) {
|
302
|
+
elements0.push(address1);
|
303
|
+
text0 += address1.textValue;
|
304
|
+
labelled0.head = address1;
|
305
|
+
var address2 = null;
|
306
|
+
var remaining0 = 0, index2 = this._offset, elements1 = [], text1 = "", address3 = true;
|
307
|
+
while (address3) {
|
308
|
+
address3 = this.__consume__location_step();
|
309
|
+
if (address3) {
|
310
|
+
elements1.push(address3);
|
311
|
+
text1 += address3.textValue;
|
312
|
+
remaining0 -= 1;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
if (remaining0 <= 0) {
|
316
|
+
this._offset = index2;
|
317
|
+
var klass0 = this.constructor.SyntaxNode;
|
318
|
+
var type0 = null;
|
319
|
+
address2 = new klass0(text1, this._offset, elements1);
|
320
|
+
if (typeof type0 === "object") {
|
321
|
+
extend(address2, type0);
|
322
|
+
}
|
323
|
+
this._offset += text1.length;
|
324
|
+
} else {
|
325
|
+
address2 = null;
|
326
|
+
}
|
327
|
+
if (address2) {
|
328
|
+
elements0.push(address2);
|
329
|
+
text0 += address2.textValue;
|
330
|
+
labelled0.rest = address2;
|
331
|
+
} else {
|
332
|
+
elements0 = null;
|
333
|
+
this._offset = index1;
|
334
|
+
}
|
335
|
+
} else {
|
336
|
+
elements0 = null;
|
337
|
+
this._offset = index1;
|
338
|
+
}
|
339
|
+
if (elements0) {
|
340
|
+
this._offset = index1;
|
341
|
+
var klass1 = this.constructor.SyntaxNode;
|
342
|
+
var type1 = find(this.constructor, "LocationPath");
|
343
|
+
address0 = new klass1(text0, this._offset, elements0, labelled0);
|
344
|
+
if (typeof type1 === "object") {
|
345
|
+
extend(address0, type1);
|
346
|
+
}
|
347
|
+
this._offset += text0.length;
|
348
|
+
} else {
|
349
|
+
address0 = null;
|
350
|
+
}
|
351
|
+
return this._nodeCache["location_path"][index0] = address0;
|
352
|
+
},
|
353
|
+
__consume__location_step: function(input) {
|
354
|
+
var address0 = null, index0 = this._offset;
|
355
|
+
this._nodeCache["location_step"] = this._nodeCache["location_step"] || {};
|
356
|
+
var cached = this._nodeCache["location_step"][index0];
|
357
|
+
if (cached) {
|
358
|
+
this._offset += cached.textValue.length;
|
359
|
+
return cached;
|
360
|
+
}
|
361
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
362
|
+
var address1 = null;
|
363
|
+
var index2 = this._offset;
|
364
|
+
var slice0 = null;
|
365
|
+
if (this._input.length > this._offset) {
|
366
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
367
|
+
} else {
|
368
|
+
slice0 = null;
|
369
|
+
}
|
370
|
+
if (slice0 === "/") {
|
371
|
+
var klass0 = this.constructor.SyntaxNode;
|
372
|
+
var type0 = null;
|
373
|
+
address1 = new klass0("/", this._offset, []);
|
374
|
+
if (typeof type0 === "object") {
|
375
|
+
extend(address1, type0);
|
376
|
+
}
|
377
|
+
this._offset += 1;
|
378
|
+
} else {
|
379
|
+
address1 = null;
|
380
|
+
var slice1 = null;
|
381
|
+
if (this._input.length > this._offset) {
|
382
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
383
|
+
} else {
|
384
|
+
slice1 = null;
|
385
|
+
}
|
386
|
+
if (!this.error || this.error.offset <= this._offset) {
|
387
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"/\""};
|
388
|
+
}
|
389
|
+
}
|
390
|
+
if (address1) {
|
391
|
+
} else {
|
392
|
+
this._offset = index2;
|
393
|
+
var klass1 = this.constructor.SyntaxNode;
|
394
|
+
var type1 = null;
|
395
|
+
address1 = new klass1("", this._offset, []);
|
396
|
+
if (typeof type1 === "object") {
|
397
|
+
extend(address1, type1);
|
398
|
+
}
|
399
|
+
this._offset += 0;
|
400
|
+
}
|
401
|
+
if (address1) {
|
402
|
+
elements0.push(address1);
|
403
|
+
text0 += address1.textValue;
|
404
|
+
var address2 = null;
|
405
|
+
var index3 = this._offset;
|
406
|
+
var index4 = this._offset, elements1 = [], labelled1 = {}, text1 = "";
|
407
|
+
var address3 = null;
|
408
|
+
address3 = this.__consume__axis();
|
409
|
+
if (address3) {
|
410
|
+
elements1.push(address3);
|
411
|
+
text1 += address3.textValue;
|
412
|
+
labelled1.axis = address3;
|
413
|
+
var address4 = null;
|
414
|
+
var index5 = this._offset;
|
415
|
+
address4 = this.__consume__node_test();
|
416
|
+
if (address4) {
|
417
|
+
} else {
|
418
|
+
this._offset = index5;
|
419
|
+
var klass2 = this.constructor.SyntaxNode;
|
420
|
+
var type2 = null;
|
421
|
+
address4 = new klass2("", this._offset, []);
|
422
|
+
if (typeof type2 === "object") {
|
423
|
+
extend(address4, type2);
|
424
|
+
}
|
425
|
+
this._offset += 0;
|
426
|
+
}
|
427
|
+
if (address4) {
|
428
|
+
elements1.push(address4);
|
429
|
+
text1 += address4.textValue;
|
430
|
+
labelled1.test = address4;
|
431
|
+
} else {
|
432
|
+
elements1 = null;
|
433
|
+
this._offset = index4;
|
434
|
+
}
|
435
|
+
} else {
|
436
|
+
elements1 = null;
|
437
|
+
this._offset = index4;
|
438
|
+
}
|
439
|
+
if (elements1) {
|
440
|
+
this._offset = index4;
|
441
|
+
var klass3 = this.constructor.SyntaxNode;
|
442
|
+
var type3 = null;
|
443
|
+
address2 = new klass3(text1, this._offset, elements1, labelled1);
|
444
|
+
if (typeof type3 === "object") {
|
445
|
+
extend(address2, type3);
|
446
|
+
}
|
447
|
+
this._offset += text1.length;
|
448
|
+
} else {
|
449
|
+
address2 = null;
|
450
|
+
}
|
451
|
+
if (address2) {
|
452
|
+
} else {
|
453
|
+
this._offset = index3;
|
454
|
+
var index6 = this._offset, elements2 = [], labelled2 = {}, text2 = "";
|
455
|
+
var address5 = null;
|
456
|
+
var index7 = this._offset;
|
457
|
+
address5 = this.__consume__axis();
|
458
|
+
if (address5) {
|
459
|
+
} else {
|
460
|
+
this._offset = index7;
|
461
|
+
var klass4 = this.constructor.SyntaxNode;
|
462
|
+
var type4 = null;
|
463
|
+
address5 = new klass4("", this._offset, []);
|
464
|
+
if (typeof type4 === "object") {
|
465
|
+
extend(address5, type4);
|
466
|
+
}
|
467
|
+
this._offset += 0;
|
468
|
+
}
|
469
|
+
if (address5) {
|
470
|
+
elements2.push(address5);
|
471
|
+
text2 += address5.textValue;
|
472
|
+
labelled2.axis = address5;
|
473
|
+
var address6 = null;
|
474
|
+
address6 = this.__consume__node_test();
|
475
|
+
if (address6) {
|
476
|
+
elements2.push(address6);
|
477
|
+
text2 += address6.textValue;
|
478
|
+
labelled2.test = address6;
|
479
|
+
} else {
|
480
|
+
elements2 = null;
|
481
|
+
this._offset = index6;
|
482
|
+
}
|
483
|
+
} else {
|
484
|
+
elements2 = null;
|
485
|
+
this._offset = index6;
|
486
|
+
}
|
487
|
+
if (elements2) {
|
488
|
+
this._offset = index6;
|
489
|
+
var klass5 = this.constructor.SyntaxNode;
|
490
|
+
var type5 = null;
|
491
|
+
address2 = new klass5(text2, this._offset, elements2, labelled2);
|
492
|
+
if (typeof type5 === "object") {
|
493
|
+
extend(address2, type5);
|
494
|
+
}
|
495
|
+
this._offset += text2.length;
|
496
|
+
} else {
|
497
|
+
address2 = null;
|
498
|
+
}
|
499
|
+
if (address2) {
|
500
|
+
} else {
|
501
|
+
this._offset = index3;
|
502
|
+
}
|
503
|
+
}
|
504
|
+
if (address2) {
|
505
|
+
elements0.push(address2);
|
506
|
+
text0 += address2.textValue;
|
507
|
+
labelled0.selector = address2;
|
508
|
+
var address7 = null;
|
509
|
+
var remaining0 = 0, index8 = this._offset, elements3 = [], text3 = "", address8 = true;
|
510
|
+
while (address8) {
|
511
|
+
address8 = this.__consume__node_predicate();
|
512
|
+
if (address8) {
|
513
|
+
elements3.push(address8);
|
514
|
+
text3 += address8.textValue;
|
515
|
+
remaining0 -= 1;
|
516
|
+
}
|
517
|
+
}
|
518
|
+
if (remaining0 <= 0) {
|
519
|
+
this._offset = index8;
|
520
|
+
var klass6 = this.constructor.SyntaxNode;
|
521
|
+
var type6 = null;
|
522
|
+
address7 = new klass6(text3, this._offset, elements3);
|
523
|
+
if (typeof type6 === "object") {
|
524
|
+
extend(address7, type6);
|
525
|
+
}
|
526
|
+
this._offset += text3.length;
|
527
|
+
} else {
|
528
|
+
address7 = null;
|
529
|
+
}
|
530
|
+
if (address7) {
|
531
|
+
elements0.push(address7);
|
532
|
+
text0 += address7.textValue;
|
533
|
+
labelled0.predicates = address7;
|
534
|
+
} else {
|
535
|
+
elements0 = null;
|
536
|
+
this._offset = index1;
|
537
|
+
}
|
538
|
+
} else {
|
539
|
+
elements0 = null;
|
540
|
+
this._offset = index1;
|
541
|
+
}
|
542
|
+
} else {
|
543
|
+
elements0 = null;
|
544
|
+
this._offset = index1;
|
545
|
+
}
|
546
|
+
if (elements0) {
|
547
|
+
this._offset = index1;
|
548
|
+
var klass7 = this.constructor.SyntaxNode;
|
549
|
+
var type7 = find(this.constructor, "LocationStep");
|
550
|
+
address0 = new klass7(text0, this._offset, elements0, labelled0);
|
551
|
+
if (typeof type7 === "object") {
|
552
|
+
extend(address0, type7);
|
553
|
+
}
|
554
|
+
this._offset += text0.length;
|
555
|
+
} else {
|
556
|
+
address0 = null;
|
557
|
+
}
|
558
|
+
return this._nodeCache["location_step"][index0] = address0;
|
559
|
+
},
|
560
|
+
__consume__axis: function(input) {
|
561
|
+
var address0 = null, index0 = this._offset;
|
562
|
+
this._nodeCache["axis"] = this._nodeCache["axis"] || {};
|
563
|
+
var cached = this._nodeCache["axis"][index0];
|
564
|
+
if (cached) {
|
565
|
+
this._offset += cached.textValue.length;
|
566
|
+
return cached;
|
567
|
+
}
|
568
|
+
var index1 = this._offset;
|
569
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
570
|
+
var address1 = null;
|
571
|
+
var remaining0 = 1, index3 = this._offset, elements1 = [], text1 = "", address2 = true;
|
572
|
+
while (address2) {
|
573
|
+
var slice0 = null;
|
574
|
+
if (this._input.length > this._offset) {
|
575
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
576
|
+
} else {
|
577
|
+
slice0 = null;
|
578
|
+
}
|
579
|
+
if (slice0 && /^[a-z\-]/.test(slice0)) {
|
580
|
+
var klass0 = this.constructor.SyntaxNode;
|
581
|
+
var type0 = null;
|
582
|
+
address2 = new klass0(slice0, this._offset, []);
|
583
|
+
if (typeof type0 === "object") {
|
584
|
+
extend(address2, type0);
|
585
|
+
}
|
586
|
+
this._offset += 1;
|
587
|
+
} else {
|
588
|
+
address2 = null;
|
589
|
+
var slice1 = null;
|
590
|
+
if (this._input.length > this._offset) {
|
591
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
592
|
+
} else {
|
593
|
+
slice1 = null;
|
594
|
+
}
|
595
|
+
if (!this.error || this.error.offset <= this._offset) {
|
596
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[a-z\\-]"};
|
597
|
+
}
|
598
|
+
}
|
599
|
+
if (address2) {
|
600
|
+
elements1.push(address2);
|
601
|
+
text1 += address2.textValue;
|
602
|
+
remaining0 -= 1;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
if (remaining0 <= 0) {
|
606
|
+
this._offset = index3;
|
607
|
+
var klass1 = this.constructor.SyntaxNode;
|
608
|
+
var type1 = null;
|
609
|
+
address1 = new klass1(text1, this._offset, elements1);
|
610
|
+
if (typeof type1 === "object") {
|
611
|
+
extend(address1, type1);
|
612
|
+
}
|
613
|
+
this._offset += text1.length;
|
614
|
+
} else {
|
615
|
+
address1 = null;
|
616
|
+
}
|
617
|
+
if (address1) {
|
618
|
+
elements0.push(address1);
|
619
|
+
text0 += address1.textValue;
|
620
|
+
labelled0.axis_name = address1;
|
621
|
+
var address3 = null;
|
622
|
+
var slice2 = null;
|
623
|
+
if (this._input.length > this._offset) {
|
624
|
+
slice2 = this._input.substring(this._offset, this._offset + 2);
|
625
|
+
} else {
|
626
|
+
slice2 = null;
|
627
|
+
}
|
628
|
+
if (slice2 === "::") {
|
629
|
+
var klass2 = this.constructor.SyntaxNode;
|
630
|
+
var type2 = null;
|
631
|
+
address3 = new klass2("::", this._offset, []);
|
632
|
+
if (typeof type2 === "object") {
|
633
|
+
extend(address3, type2);
|
634
|
+
}
|
635
|
+
this._offset += 2;
|
636
|
+
} else {
|
637
|
+
address3 = null;
|
638
|
+
var slice3 = null;
|
639
|
+
if (this._input.length > this._offset) {
|
640
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
641
|
+
} else {
|
642
|
+
slice3 = null;
|
643
|
+
}
|
644
|
+
if (!this.error || this.error.offset <= this._offset) {
|
645
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"::\""};
|
646
|
+
}
|
647
|
+
}
|
648
|
+
if (address3) {
|
649
|
+
elements0.push(address3);
|
650
|
+
text0 += address3.textValue;
|
651
|
+
} else {
|
652
|
+
elements0 = null;
|
653
|
+
this._offset = index2;
|
654
|
+
}
|
655
|
+
} else {
|
656
|
+
elements0 = null;
|
657
|
+
this._offset = index2;
|
658
|
+
}
|
659
|
+
if (elements0) {
|
660
|
+
this._offset = index2;
|
661
|
+
var klass3 = this.constructor.SyntaxNode;
|
662
|
+
var type3 = null;
|
663
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
664
|
+
if (typeof type3 === "object") {
|
665
|
+
extend(address0, type3);
|
666
|
+
}
|
667
|
+
this._offset += text0.length;
|
668
|
+
} else {
|
669
|
+
address0 = null;
|
670
|
+
}
|
671
|
+
if (address0) {
|
672
|
+
} else {
|
673
|
+
this._offset = index1;
|
674
|
+
address0 = this.__consume__axis_shorthand();
|
675
|
+
if (address0) {
|
676
|
+
} else {
|
677
|
+
this._offset = index1;
|
678
|
+
}
|
679
|
+
}
|
680
|
+
return this._nodeCache["axis"][index0] = address0;
|
681
|
+
},
|
682
|
+
__consume__axis_shorthand: function(input) {
|
683
|
+
var address0 = null, index0 = this._offset;
|
684
|
+
this._nodeCache["axis_shorthand"] = this._nodeCache["axis_shorthand"] || {};
|
685
|
+
var cached = this._nodeCache["axis_shorthand"][index0];
|
686
|
+
if (cached) {
|
687
|
+
this._offset += cached.textValue.length;
|
688
|
+
return cached;
|
689
|
+
}
|
690
|
+
var index1 = this._offset;
|
691
|
+
var slice0 = null;
|
692
|
+
if (this._input.length > this._offset) {
|
693
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
694
|
+
} else {
|
695
|
+
slice0 = null;
|
696
|
+
}
|
697
|
+
if (slice0 === "@") {
|
698
|
+
var klass0 = this.constructor.SyntaxNode;
|
699
|
+
var type0 = null;
|
700
|
+
address0 = new klass0("@", this._offset, []);
|
701
|
+
if (typeof type0 === "object") {
|
702
|
+
extend(address0, type0);
|
703
|
+
}
|
704
|
+
this._offset += 1;
|
705
|
+
} else {
|
706
|
+
address0 = null;
|
707
|
+
var slice1 = null;
|
708
|
+
if (this._input.length > this._offset) {
|
709
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
710
|
+
} else {
|
711
|
+
slice1 = null;
|
712
|
+
}
|
713
|
+
if (!this.error || this.error.offset <= this._offset) {
|
714
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"@\""};
|
715
|
+
}
|
716
|
+
}
|
717
|
+
if (address0) {
|
718
|
+
} else {
|
719
|
+
this._offset = index1;
|
720
|
+
var slice2 = null;
|
721
|
+
if (this._input.length > this._offset) {
|
722
|
+
slice2 = this._input.substring(this._offset, this._offset + 2);
|
723
|
+
} else {
|
724
|
+
slice2 = null;
|
725
|
+
}
|
726
|
+
if (slice2 === "..") {
|
727
|
+
var klass1 = this.constructor.SyntaxNode;
|
728
|
+
var type1 = null;
|
729
|
+
address0 = new klass1("..", this._offset, []);
|
730
|
+
if (typeof type1 === "object") {
|
731
|
+
extend(address0, type1);
|
732
|
+
}
|
733
|
+
this._offset += 2;
|
734
|
+
} else {
|
735
|
+
address0 = null;
|
736
|
+
var slice3 = null;
|
737
|
+
if (this._input.length > this._offset) {
|
738
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
739
|
+
} else {
|
740
|
+
slice3 = null;
|
741
|
+
}
|
742
|
+
if (!this.error || this.error.offset <= this._offset) {
|
743
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"..\""};
|
744
|
+
}
|
745
|
+
}
|
746
|
+
if (address0) {
|
747
|
+
} else {
|
748
|
+
this._offset = index1;
|
749
|
+
var slice4 = null;
|
750
|
+
if (this._input.length > this._offset) {
|
751
|
+
slice4 = this._input.substring(this._offset, this._offset + 1);
|
752
|
+
} else {
|
753
|
+
slice4 = null;
|
754
|
+
}
|
755
|
+
if (slice4 === ".") {
|
756
|
+
var klass2 = this.constructor.SyntaxNode;
|
757
|
+
var type2 = null;
|
758
|
+
address0 = new klass2(".", this._offset, []);
|
759
|
+
if (typeof type2 === "object") {
|
760
|
+
extend(address0, type2);
|
761
|
+
}
|
762
|
+
this._offset += 1;
|
763
|
+
} else {
|
764
|
+
address0 = null;
|
765
|
+
var slice5 = null;
|
766
|
+
if (this._input.length > this._offset) {
|
767
|
+
slice5 = this._input.substring(this._offset, this._offset + 1);
|
768
|
+
} else {
|
769
|
+
slice5 = null;
|
770
|
+
}
|
771
|
+
if (!this.error || this.error.offset <= this._offset) {
|
772
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\".\""};
|
773
|
+
}
|
774
|
+
}
|
775
|
+
if (address0) {
|
776
|
+
} else {
|
777
|
+
this._offset = index1;
|
778
|
+
var slice6 = null;
|
779
|
+
if (this._input.length > this._offset) {
|
780
|
+
slice6 = this._input.substring(this._offset, this._offset + 1);
|
781
|
+
} else {
|
782
|
+
slice6 = null;
|
783
|
+
}
|
784
|
+
if (slice6 === "/") {
|
785
|
+
var klass3 = this.constructor.SyntaxNode;
|
786
|
+
var type3 = null;
|
787
|
+
address0 = new klass3("/", this._offset, []);
|
788
|
+
if (typeof type3 === "object") {
|
789
|
+
extend(address0, type3);
|
790
|
+
}
|
791
|
+
this._offset += 1;
|
792
|
+
} else {
|
793
|
+
address0 = null;
|
794
|
+
var slice7 = null;
|
795
|
+
if (this._input.length > this._offset) {
|
796
|
+
slice7 = this._input.substring(this._offset, this._offset + 1);
|
797
|
+
} else {
|
798
|
+
slice7 = null;
|
799
|
+
}
|
800
|
+
if (!this.error || this.error.offset <= this._offset) {
|
801
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"/\""};
|
802
|
+
}
|
803
|
+
}
|
804
|
+
if (address0) {
|
805
|
+
} else {
|
806
|
+
this._offset = index1;
|
807
|
+
}
|
808
|
+
}
|
809
|
+
}
|
810
|
+
}
|
811
|
+
return this._nodeCache["axis_shorthand"][index0] = address0;
|
812
|
+
},
|
813
|
+
__consume__node_test: function(input) {
|
814
|
+
var address0 = null, index0 = this._offset;
|
815
|
+
this._nodeCache["node_test"] = this._nodeCache["node_test"] || {};
|
816
|
+
var cached = this._nodeCache["node_test"][index0];
|
817
|
+
if (cached) {
|
818
|
+
this._offset += cached.textValue.length;
|
819
|
+
return cached;
|
820
|
+
}
|
821
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
822
|
+
var address1 = null;
|
823
|
+
var index2 = this._offset;
|
824
|
+
address1 = this.__consume__node_condition();
|
825
|
+
if (address1) {
|
826
|
+
} else {
|
827
|
+
this._offset = index2;
|
828
|
+
address1 = this.__consume__node_name();
|
829
|
+
if (address1) {
|
830
|
+
} else {
|
831
|
+
this._offset = index2;
|
832
|
+
var slice0 = null;
|
833
|
+
if (this._input.length > this._offset) {
|
834
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
835
|
+
} else {
|
836
|
+
slice0 = null;
|
837
|
+
}
|
838
|
+
if (slice0 === "*") {
|
839
|
+
var klass0 = this.constructor.SyntaxNode;
|
840
|
+
var type0 = null;
|
841
|
+
address1 = new klass0("*", this._offset, []);
|
842
|
+
if (typeof type0 === "object") {
|
843
|
+
extend(address1, type0);
|
844
|
+
}
|
845
|
+
this._offset += 1;
|
846
|
+
} else {
|
847
|
+
address1 = null;
|
848
|
+
var slice1 = null;
|
849
|
+
if (this._input.length > this._offset) {
|
850
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
851
|
+
} else {
|
852
|
+
slice1 = null;
|
853
|
+
}
|
854
|
+
if (!this.error || this.error.offset <= this._offset) {
|
855
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"*\""};
|
856
|
+
}
|
857
|
+
}
|
858
|
+
if (address1) {
|
859
|
+
} else {
|
860
|
+
this._offset = index2;
|
861
|
+
}
|
862
|
+
}
|
863
|
+
}
|
864
|
+
if (address1) {
|
865
|
+
elements0.push(address1);
|
866
|
+
text0 += address1.textValue;
|
867
|
+
var address2 = null;
|
868
|
+
var index3 = this._offset;
|
869
|
+
address2 = this.__consume__subscript();
|
870
|
+
if (address2) {
|
871
|
+
} else {
|
872
|
+
this._offset = index3;
|
873
|
+
var klass1 = this.constructor.SyntaxNode;
|
874
|
+
var type1 = null;
|
875
|
+
address2 = new klass1("", this._offset, []);
|
876
|
+
if (typeof type1 === "object") {
|
877
|
+
extend(address2, type1);
|
878
|
+
}
|
879
|
+
this._offset += 0;
|
880
|
+
}
|
881
|
+
if (address2) {
|
882
|
+
elements0.push(address2);
|
883
|
+
text0 += address2.textValue;
|
884
|
+
labelled0.subscript = address2;
|
885
|
+
} else {
|
886
|
+
elements0 = null;
|
887
|
+
this._offset = index1;
|
888
|
+
}
|
889
|
+
} else {
|
890
|
+
elements0 = null;
|
891
|
+
this._offset = index1;
|
892
|
+
}
|
893
|
+
if (elements0) {
|
894
|
+
this._offset = index1;
|
895
|
+
var klass2 = this.constructor.SyntaxNode;
|
896
|
+
var type2 = find(this.constructor, "NodeTest");
|
897
|
+
address0 = new klass2(text0, this._offset, elements0, labelled0);
|
898
|
+
if (typeof type2 === "object") {
|
899
|
+
extend(address0, type2);
|
900
|
+
}
|
901
|
+
this._offset += text0.length;
|
902
|
+
} else {
|
903
|
+
address0 = null;
|
904
|
+
}
|
905
|
+
return this._nodeCache["node_test"][index0] = address0;
|
906
|
+
},
|
907
|
+
__consume__node_condition: function(input) {
|
908
|
+
var address0 = null, index0 = this._offset;
|
909
|
+
this._nodeCache["node_condition"] = this._nodeCache["node_condition"] || {};
|
910
|
+
var cached = this._nodeCache["node_condition"][index0];
|
911
|
+
if (cached) {
|
912
|
+
this._offset += cached.textValue.length;
|
913
|
+
return cached;
|
914
|
+
}
|
915
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
916
|
+
var address1 = null;
|
917
|
+
var remaining0 = 1, index2 = this._offset, elements1 = [], text1 = "", address2 = true;
|
918
|
+
while (address2) {
|
919
|
+
var slice0 = null;
|
920
|
+
if (this._input.length > this._offset) {
|
921
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
922
|
+
} else {
|
923
|
+
slice0 = null;
|
924
|
+
}
|
925
|
+
if (slice0 && /^[a-z\-]/.test(slice0)) {
|
926
|
+
var klass0 = this.constructor.SyntaxNode;
|
927
|
+
var type0 = null;
|
928
|
+
address2 = new klass0(slice0, this._offset, []);
|
929
|
+
if (typeof type0 === "object") {
|
930
|
+
extend(address2, type0);
|
931
|
+
}
|
932
|
+
this._offset += 1;
|
933
|
+
} else {
|
934
|
+
address2 = null;
|
935
|
+
var slice1 = null;
|
936
|
+
if (this._input.length > this._offset) {
|
937
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
938
|
+
} else {
|
939
|
+
slice1 = null;
|
940
|
+
}
|
941
|
+
if (!this.error || this.error.offset <= this._offset) {
|
942
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[a-z\\-]"};
|
943
|
+
}
|
944
|
+
}
|
945
|
+
if (address2) {
|
946
|
+
elements1.push(address2);
|
947
|
+
text1 += address2.textValue;
|
948
|
+
remaining0 -= 1;
|
949
|
+
}
|
950
|
+
}
|
951
|
+
if (remaining0 <= 0) {
|
952
|
+
this._offset = index2;
|
953
|
+
var klass1 = this.constructor.SyntaxNode;
|
954
|
+
var type1 = null;
|
955
|
+
address1 = new klass1(text1, this._offset, elements1);
|
956
|
+
if (typeof type1 === "object") {
|
957
|
+
extend(address1, type1);
|
958
|
+
}
|
959
|
+
this._offset += text1.length;
|
960
|
+
} else {
|
961
|
+
address1 = null;
|
962
|
+
}
|
963
|
+
if (address1) {
|
964
|
+
elements0.push(address1);
|
965
|
+
text0 += address1.textValue;
|
966
|
+
labelled0.condition_name = address1;
|
967
|
+
var address3 = null;
|
968
|
+
var slice2 = null;
|
969
|
+
if (this._input.length > this._offset) {
|
970
|
+
slice2 = this._input.substring(this._offset, this._offset + 2);
|
971
|
+
} else {
|
972
|
+
slice2 = null;
|
973
|
+
}
|
974
|
+
if (slice2 === "()") {
|
975
|
+
var klass2 = this.constructor.SyntaxNode;
|
976
|
+
var type2 = null;
|
977
|
+
address3 = new klass2("()", this._offset, []);
|
978
|
+
if (typeof type2 === "object") {
|
979
|
+
extend(address3, type2);
|
980
|
+
}
|
981
|
+
this._offset += 2;
|
982
|
+
} else {
|
983
|
+
address3 = null;
|
984
|
+
var slice3 = null;
|
985
|
+
if (this._input.length > this._offset) {
|
986
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
987
|
+
} else {
|
988
|
+
slice3 = null;
|
989
|
+
}
|
990
|
+
if (!this.error || this.error.offset <= this._offset) {
|
991
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"()\""};
|
992
|
+
}
|
993
|
+
}
|
994
|
+
if (address3) {
|
995
|
+
elements0.push(address3);
|
996
|
+
text0 += address3.textValue;
|
997
|
+
} else {
|
998
|
+
elements0 = null;
|
999
|
+
this._offset = index1;
|
1000
|
+
}
|
1001
|
+
} else {
|
1002
|
+
elements0 = null;
|
1003
|
+
this._offset = index1;
|
1004
|
+
}
|
1005
|
+
if (elements0) {
|
1006
|
+
this._offset = index1;
|
1007
|
+
var klass3 = this.constructor.SyntaxNode;
|
1008
|
+
var type3 = null;
|
1009
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
1010
|
+
if (typeof type3 === "object") {
|
1011
|
+
extend(address0, type3);
|
1012
|
+
}
|
1013
|
+
this._offset += text0.length;
|
1014
|
+
} else {
|
1015
|
+
address0 = null;
|
1016
|
+
}
|
1017
|
+
return this._nodeCache["node_condition"][index0] = address0;
|
1018
|
+
},
|
1019
|
+
__consume__node_name: function(input) {
|
1020
|
+
var address0 = null, index0 = this._offset;
|
1021
|
+
this._nodeCache["node_name"] = this._nodeCache["node_name"] || {};
|
1022
|
+
var cached = this._nodeCache["node_name"][index0];
|
1023
|
+
if (cached) {
|
1024
|
+
this._offset += cached.textValue.length;
|
1025
|
+
return cached;
|
1026
|
+
}
|
1027
|
+
var remaining0 = 1, index1 = this._offset, elements0 = [], text0 = "", address1 = true;
|
1028
|
+
while (address1) {
|
1029
|
+
var slice0 = null;
|
1030
|
+
if (this._input.length > this._offset) {
|
1031
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1032
|
+
} else {
|
1033
|
+
slice0 = null;
|
1034
|
+
}
|
1035
|
+
if (slice0 && /^[A-Za-z0-9\-]/.test(slice0)) {
|
1036
|
+
var klass0 = this.constructor.SyntaxNode;
|
1037
|
+
var type0 = null;
|
1038
|
+
address1 = new klass0(slice0, this._offset, []);
|
1039
|
+
if (typeof type0 === "object") {
|
1040
|
+
extend(address1, type0);
|
1041
|
+
}
|
1042
|
+
this._offset += 1;
|
1043
|
+
} else {
|
1044
|
+
address1 = null;
|
1045
|
+
var slice1 = null;
|
1046
|
+
if (this._input.length > this._offset) {
|
1047
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1048
|
+
} else {
|
1049
|
+
slice1 = null;
|
1050
|
+
}
|
1051
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1052
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[A-Za-z0-9\\-]"};
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
if (address1) {
|
1056
|
+
elements0.push(address1);
|
1057
|
+
text0 += address1.textValue;
|
1058
|
+
remaining0 -= 1;
|
1059
|
+
}
|
1060
|
+
}
|
1061
|
+
if (remaining0 <= 0) {
|
1062
|
+
this._offset = index1;
|
1063
|
+
var klass1 = this.constructor.SyntaxNode;
|
1064
|
+
var type1 = null;
|
1065
|
+
address0 = new klass1(text0, this._offset, elements0);
|
1066
|
+
if (typeof type1 === "object") {
|
1067
|
+
extend(address0, type1);
|
1068
|
+
}
|
1069
|
+
this._offset += text0.length;
|
1070
|
+
} else {
|
1071
|
+
address0 = null;
|
1072
|
+
}
|
1073
|
+
return this._nodeCache["node_name"][index0] = address0;
|
1074
|
+
},
|
1075
|
+
__consume__subscript: function(input) {
|
1076
|
+
var address0 = null, index0 = this._offset;
|
1077
|
+
this._nodeCache["subscript"] = this._nodeCache["subscript"] || {};
|
1078
|
+
var cached = this._nodeCache["subscript"][index0];
|
1079
|
+
if (cached) {
|
1080
|
+
this._offset += cached.textValue.length;
|
1081
|
+
return cached;
|
1082
|
+
}
|
1083
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1084
|
+
var address1 = null;
|
1085
|
+
var slice0 = null;
|
1086
|
+
if (this._input.length > this._offset) {
|
1087
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1088
|
+
} else {
|
1089
|
+
slice0 = null;
|
1090
|
+
}
|
1091
|
+
if (slice0 === "[") {
|
1092
|
+
var klass0 = this.constructor.SyntaxNode;
|
1093
|
+
var type0 = null;
|
1094
|
+
address1 = new klass0("[", this._offset, []);
|
1095
|
+
if (typeof type0 === "object") {
|
1096
|
+
extend(address1, type0);
|
1097
|
+
}
|
1098
|
+
this._offset += 1;
|
1099
|
+
} else {
|
1100
|
+
address1 = null;
|
1101
|
+
var slice1 = null;
|
1102
|
+
if (this._input.length > this._offset) {
|
1103
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1104
|
+
} else {
|
1105
|
+
slice1 = null;
|
1106
|
+
}
|
1107
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1108
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"[\""};
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
if (address1) {
|
1112
|
+
elements0.push(address1);
|
1113
|
+
text0 += address1.textValue;
|
1114
|
+
var address2 = null;
|
1115
|
+
address2 = this.__consume__space();
|
1116
|
+
if (address2) {
|
1117
|
+
elements0.push(address2);
|
1118
|
+
text0 += address2.textValue;
|
1119
|
+
labelled0.space = address2;
|
1120
|
+
var address3 = null;
|
1121
|
+
address3 = this.__consume__integer();
|
1122
|
+
if (address3) {
|
1123
|
+
elements0.push(address3);
|
1124
|
+
text0 += address3.textValue;
|
1125
|
+
labelled0.integer = address3;
|
1126
|
+
var address4 = null;
|
1127
|
+
address4 = this.__consume__space();
|
1128
|
+
if (address4) {
|
1129
|
+
elements0.push(address4);
|
1130
|
+
text0 += address4.textValue;
|
1131
|
+
labelled0.space = address4;
|
1132
|
+
var address5 = null;
|
1133
|
+
var slice2 = null;
|
1134
|
+
if (this._input.length > this._offset) {
|
1135
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
1136
|
+
} else {
|
1137
|
+
slice2 = null;
|
1138
|
+
}
|
1139
|
+
if (slice2 === "]") {
|
1140
|
+
var klass1 = this.constructor.SyntaxNode;
|
1141
|
+
var type1 = null;
|
1142
|
+
address5 = new klass1("]", this._offset, []);
|
1143
|
+
if (typeof type1 === "object") {
|
1144
|
+
extend(address5, type1);
|
1145
|
+
}
|
1146
|
+
this._offset += 1;
|
1147
|
+
} else {
|
1148
|
+
address5 = null;
|
1149
|
+
var slice3 = null;
|
1150
|
+
if (this._input.length > this._offset) {
|
1151
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
1152
|
+
} else {
|
1153
|
+
slice3 = null;
|
1154
|
+
}
|
1155
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1156
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"]\""};
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
if (address5) {
|
1160
|
+
elements0.push(address5);
|
1161
|
+
text0 += address5.textValue;
|
1162
|
+
} else {
|
1163
|
+
elements0 = null;
|
1164
|
+
this._offset = index1;
|
1165
|
+
}
|
1166
|
+
} else {
|
1167
|
+
elements0 = null;
|
1168
|
+
this._offset = index1;
|
1169
|
+
}
|
1170
|
+
} else {
|
1171
|
+
elements0 = null;
|
1172
|
+
this._offset = index1;
|
1173
|
+
}
|
1174
|
+
} else {
|
1175
|
+
elements0 = null;
|
1176
|
+
this._offset = index1;
|
1177
|
+
}
|
1178
|
+
} else {
|
1179
|
+
elements0 = null;
|
1180
|
+
this._offset = index1;
|
1181
|
+
}
|
1182
|
+
if (elements0) {
|
1183
|
+
this._offset = index1;
|
1184
|
+
var klass2 = this.constructor.SyntaxNode;
|
1185
|
+
var type2 = null;
|
1186
|
+
address0 = new klass2(text0, this._offset, elements0, labelled0);
|
1187
|
+
if (typeof type2 === "object") {
|
1188
|
+
extend(address0, type2);
|
1189
|
+
}
|
1190
|
+
this._offset += text0.length;
|
1191
|
+
} else {
|
1192
|
+
address0 = null;
|
1193
|
+
}
|
1194
|
+
return this._nodeCache["subscript"][index0] = address0;
|
1195
|
+
},
|
1196
|
+
__consume__node_predicate: function(input) {
|
1197
|
+
var address0 = null, index0 = this._offset;
|
1198
|
+
this._nodeCache["node_predicate"] = this._nodeCache["node_predicate"] || {};
|
1199
|
+
var cached = this._nodeCache["node_predicate"][index0];
|
1200
|
+
if (cached) {
|
1201
|
+
this._offset += cached.textValue.length;
|
1202
|
+
return cached;
|
1203
|
+
}
|
1204
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1205
|
+
var address1 = null;
|
1206
|
+
var slice0 = null;
|
1207
|
+
if (this._input.length > this._offset) {
|
1208
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1209
|
+
} else {
|
1210
|
+
slice0 = null;
|
1211
|
+
}
|
1212
|
+
if (slice0 === "[") {
|
1213
|
+
var klass0 = this.constructor.SyntaxNode;
|
1214
|
+
var type0 = null;
|
1215
|
+
address1 = new klass0("[", this._offset, []);
|
1216
|
+
if (typeof type0 === "object") {
|
1217
|
+
extend(address1, type0);
|
1218
|
+
}
|
1219
|
+
this._offset += 1;
|
1220
|
+
} else {
|
1221
|
+
address1 = null;
|
1222
|
+
var slice1 = null;
|
1223
|
+
if (this._input.length > this._offset) {
|
1224
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1225
|
+
} else {
|
1226
|
+
slice1 = null;
|
1227
|
+
}
|
1228
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1229
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"[\""};
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
if (address1) {
|
1233
|
+
elements0.push(address1);
|
1234
|
+
text0 += address1.textValue;
|
1235
|
+
var address2 = null;
|
1236
|
+
address2 = this.__consume__expression();
|
1237
|
+
if (address2) {
|
1238
|
+
elements0.push(address2);
|
1239
|
+
text0 += address2.textValue;
|
1240
|
+
labelled0.expression = address2;
|
1241
|
+
var address3 = null;
|
1242
|
+
var slice2 = null;
|
1243
|
+
if (this._input.length > this._offset) {
|
1244
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
1245
|
+
} else {
|
1246
|
+
slice2 = null;
|
1247
|
+
}
|
1248
|
+
if (slice2 === "]") {
|
1249
|
+
var klass1 = this.constructor.SyntaxNode;
|
1250
|
+
var type1 = null;
|
1251
|
+
address3 = new klass1("]", this._offset, []);
|
1252
|
+
if (typeof type1 === "object") {
|
1253
|
+
extend(address3, type1);
|
1254
|
+
}
|
1255
|
+
this._offset += 1;
|
1256
|
+
} else {
|
1257
|
+
address3 = null;
|
1258
|
+
var slice3 = null;
|
1259
|
+
if (this._input.length > this._offset) {
|
1260
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
1261
|
+
} else {
|
1262
|
+
slice3 = null;
|
1263
|
+
}
|
1264
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1265
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"]\""};
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
if (address3) {
|
1269
|
+
elements0.push(address3);
|
1270
|
+
text0 += address3.textValue;
|
1271
|
+
var address4 = null;
|
1272
|
+
var index2 = this._offset;
|
1273
|
+
address4 = this.__consume__subscript();
|
1274
|
+
if (address4) {
|
1275
|
+
} else {
|
1276
|
+
this._offset = index2;
|
1277
|
+
var klass2 = this.constructor.SyntaxNode;
|
1278
|
+
var type2 = null;
|
1279
|
+
address4 = new klass2("", this._offset, []);
|
1280
|
+
if (typeof type2 === "object") {
|
1281
|
+
extend(address4, type2);
|
1282
|
+
}
|
1283
|
+
this._offset += 0;
|
1284
|
+
}
|
1285
|
+
if (address4) {
|
1286
|
+
elements0.push(address4);
|
1287
|
+
text0 += address4.textValue;
|
1288
|
+
labelled0.subscript = address4;
|
1289
|
+
} else {
|
1290
|
+
elements0 = null;
|
1291
|
+
this._offset = index1;
|
1292
|
+
}
|
1293
|
+
} else {
|
1294
|
+
elements0 = null;
|
1295
|
+
this._offset = index1;
|
1296
|
+
}
|
1297
|
+
} else {
|
1298
|
+
elements0 = null;
|
1299
|
+
this._offset = index1;
|
1300
|
+
}
|
1301
|
+
} else {
|
1302
|
+
elements0 = null;
|
1303
|
+
this._offset = index1;
|
1304
|
+
}
|
1305
|
+
if (elements0) {
|
1306
|
+
this._offset = index1;
|
1307
|
+
var klass3 = this.constructor.SyntaxNode;
|
1308
|
+
var type3 = null;
|
1309
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
1310
|
+
if (typeof type3 === "object") {
|
1311
|
+
extend(address0, type3);
|
1312
|
+
}
|
1313
|
+
this._offset += text0.length;
|
1314
|
+
} else {
|
1315
|
+
address0 = null;
|
1316
|
+
}
|
1317
|
+
return this._nodeCache["node_predicate"][index0] = address0;
|
1318
|
+
},
|
1319
|
+
__consume__expression: function(input) {
|
1320
|
+
var address0 = null, index0 = this._offset;
|
1321
|
+
this._nodeCache["expression"] = this._nodeCache["expression"] || {};
|
1322
|
+
var cached = this._nodeCache["expression"][index0];
|
1323
|
+
if (cached) {
|
1324
|
+
this._offset += cached.textValue.length;
|
1325
|
+
return cached;
|
1326
|
+
}
|
1327
|
+
var index1 = this._offset;
|
1328
|
+
address0 = this.__consume__or_expression();
|
1329
|
+
if (address0) {
|
1330
|
+
} else {
|
1331
|
+
this._offset = index1;
|
1332
|
+
address0 = this.__consume__and_expression();
|
1333
|
+
if (address0) {
|
1334
|
+
} else {
|
1335
|
+
this._offset = index1;
|
1336
|
+
address0 = this.__consume__comparison();
|
1337
|
+
if (address0) {
|
1338
|
+
} else {
|
1339
|
+
this._offset = index1;
|
1340
|
+
address0 = this.__consume__atom();
|
1341
|
+
if (address0) {
|
1342
|
+
} else {
|
1343
|
+
this._offset = index1;
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
}
|
1348
|
+
return this._nodeCache["expression"][index0] = address0;
|
1349
|
+
},
|
1350
|
+
__consume__or_expression: function(input) {
|
1351
|
+
var address0 = null, index0 = this._offset;
|
1352
|
+
this._nodeCache["or_expression"] = this._nodeCache["or_expression"] || {};
|
1353
|
+
var cached = this._nodeCache["or_expression"][index0];
|
1354
|
+
if (cached) {
|
1355
|
+
this._offset += cached.textValue.length;
|
1356
|
+
return cached;
|
1357
|
+
}
|
1358
|
+
var index1 = this._offset;
|
1359
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1360
|
+
var address1 = null;
|
1361
|
+
address1 = this.__consume__and_expression();
|
1362
|
+
if (address1) {
|
1363
|
+
elements0.push(address1);
|
1364
|
+
text0 += address1.textValue;
|
1365
|
+
labelled0.left = address1;
|
1366
|
+
var address2 = null;
|
1367
|
+
var slice0 = null;
|
1368
|
+
if (this._input.length > this._offset) {
|
1369
|
+
slice0 = this._input.substring(this._offset, this._offset + 2);
|
1370
|
+
} else {
|
1371
|
+
slice0 = null;
|
1372
|
+
}
|
1373
|
+
if (slice0 === "or") {
|
1374
|
+
var klass0 = this.constructor.SyntaxNode;
|
1375
|
+
var type0 = null;
|
1376
|
+
address2 = new klass0("or", this._offset, []);
|
1377
|
+
if (typeof type0 === "object") {
|
1378
|
+
extend(address2, type0);
|
1379
|
+
}
|
1380
|
+
this._offset += 2;
|
1381
|
+
} else {
|
1382
|
+
address2 = null;
|
1383
|
+
var slice1 = null;
|
1384
|
+
if (this._input.length > this._offset) {
|
1385
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1386
|
+
} else {
|
1387
|
+
slice1 = null;
|
1388
|
+
}
|
1389
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1390
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"or\""};
|
1391
|
+
}
|
1392
|
+
}
|
1393
|
+
if (address2) {
|
1394
|
+
elements0.push(address2);
|
1395
|
+
text0 += address2.textValue;
|
1396
|
+
var address3 = null;
|
1397
|
+
address3 = this.__consume__or_expression();
|
1398
|
+
if (address3) {
|
1399
|
+
elements0.push(address3);
|
1400
|
+
text0 += address3.textValue;
|
1401
|
+
labelled0.right = address3;
|
1402
|
+
} else {
|
1403
|
+
elements0 = null;
|
1404
|
+
this._offset = index2;
|
1405
|
+
}
|
1406
|
+
} else {
|
1407
|
+
elements0 = null;
|
1408
|
+
this._offset = index2;
|
1409
|
+
}
|
1410
|
+
} else {
|
1411
|
+
elements0 = null;
|
1412
|
+
this._offset = index2;
|
1413
|
+
}
|
1414
|
+
if (elements0) {
|
1415
|
+
this._offset = index2;
|
1416
|
+
var klass1 = this.constructor.SyntaxNode;
|
1417
|
+
var type1 = find(this.constructor, "Or");
|
1418
|
+
address0 = new klass1(text0, this._offset, elements0, labelled0);
|
1419
|
+
if (typeof type1 === "object") {
|
1420
|
+
extend(address0, type1);
|
1421
|
+
}
|
1422
|
+
this._offset += text0.length;
|
1423
|
+
} else {
|
1424
|
+
address0 = null;
|
1425
|
+
}
|
1426
|
+
if (address0) {
|
1427
|
+
} else {
|
1428
|
+
this._offset = index1;
|
1429
|
+
address0 = this.__consume__and_expression();
|
1430
|
+
if (address0) {
|
1431
|
+
} else {
|
1432
|
+
this._offset = index1;
|
1433
|
+
}
|
1434
|
+
}
|
1435
|
+
return this._nodeCache["or_expression"][index0] = address0;
|
1436
|
+
},
|
1437
|
+
__consume__and_expression: function(input) {
|
1438
|
+
var address0 = null, index0 = this._offset;
|
1439
|
+
this._nodeCache["and_expression"] = this._nodeCache["and_expression"] || {};
|
1440
|
+
var cached = this._nodeCache["and_expression"][index0];
|
1441
|
+
if (cached) {
|
1442
|
+
this._offset += cached.textValue.length;
|
1443
|
+
return cached;
|
1444
|
+
}
|
1445
|
+
var index1 = this._offset;
|
1446
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1447
|
+
var address1 = null;
|
1448
|
+
address1 = this.__consume__comparison();
|
1449
|
+
if (address1) {
|
1450
|
+
elements0.push(address1);
|
1451
|
+
text0 += address1.textValue;
|
1452
|
+
labelled0.left = address1;
|
1453
|
+
var address2 = null;
|
1454
|
+
var slice0 = null;
|
1455
|
+
if (this._input.length > this._offset) {
|
1456
|
+
slice0 = this._input.substring(this._offset, this._offset + 3);
|
1457
|
+
} else {
|
1458
|
+
slice0 = null;
|
1459
|
+
}
|
1460
|
+
if (slice0 === "and") {
|
1461
|
+
var klass0 = this.constructor.SyntaxNode;
|
1462
|
+
var type0 = null;
|
1463
|
+
address2 = new klass0("and", this._offset, []);
|
1464
|
+
if (typeof type0 === "object") {
|
1465
|
+
extend(address2, type0);
|
1466
|
+
}
|
1467
|
+
this._offset += 3;
|
1468
|
+
} else {
|
1469
|
+
address2 = null;
|
1470
|
+
var slice1 = null;
|
1471
|
+
if (this._input.length > this._offset) {
|
1472
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1473
|
+
} else {
|
1474
|
+
slice1 = null;
|
1475
|
+
}
|
1476
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1477
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"and\""};
|
1478
|
+
}
|
1479
|
+
}
|
1480
|
+
if (address2) {
|
1481
|
+
elements0.push(address2);
|
1482
|
+
text0 += address2.textValue;
|
1483
|
+
var address3 = null;
|
1484
|
+
address3 = this.__consume__and_expression();
|
1485
|
+
if (address3) {
|
1486
|
+
elements0.push(address3);
|
1487
|
+
text0 += address3.textValue;
|
1488
|
+
labelled0.right = address3;
|
1489
|
+
} else {
|
1490
|
+
elements0 = null;
|
1491
|
+
this._offset = index2;
|
1492
|
+
}
|
1493
|
+
} else {
|
1494
|
+
elements0 = null;
|
1495
|
+
this._offset = index2;
|
1496
|
+
}
|
1497
|
+
} else {
|
1498
|
+
elements0 = null;
|
1499
|
+
this._offset = index2;
|
1500
|
+
}
|
1501
|
+
if (elements0) {
|
1502
|
+
this._offset = index2;
|
1503
|
+
var klass1 = this.constructor.SyntaxNode;
|
1504
|
+
var type1 = find(this.constructor, "And");
|
1505
|
+
address0 = new klass1(text0, this._offset, elements0, labelled0);
|
1506
|
+
if (typeof type1 === "object") {
|
1507
|
+
extend(address0, type1);
|
1508
|
+
}
|
1509
|
+
this._offset += text0.length;
|
1510
|
+
} else {
|
1511
|
+
address0 = null;
|
1512
|
+
}
|
1513
|
+
if (address0) {
|
1514
|
+
} else {
|
1515
|
+
this._offset = index1;
|
1516
|
+
address0 = this.__consume__comparison();
|
1517
|
+
if (address0) {
|
1518
|
+
} else {
|
1519
|
+
this._offset = index1;
|
1520
|
+
}
|
1521
|
+
}
|
1522
|
+
return this._nodeCache["and_expression"][index0] = address0;
|
1523
|
+
},
|
1524
|
+
__consume__comparison: function(input) {
|
1525
|
+
var address0 = null, index0 = this._offset;
|
1526
|
+
this._nodeCache["comparison"] = this._nodeCache["comparison"] || {};
|
1527
|
+
var cached = this._nodeCache["comparison"][index0];
|
1528
|
+
if (cached) {
|
1529
|
+
this._offset += cached.textValue.length;
|
1530
|
+
return cached;
|
1531
|
+
}
|
1532
|
+
var index1 = this._offset;
|
1533
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1534
|
+
var address1 = null;
|
1535
|
+
address1 = this.__consume__atom();
|
1536
|
+
if (address1) {
|
1537
|
+
elements0.push(address1);
|
1538
|
+
text0 += address1.textValue;
|
1539
|
+
labelled0.left = address1;
|
1540
|
+
var address2 = null;
|
1541
|
+
address2 = this.__consume__comparator();
|
1542
|
+
if (address2) {
|
1543
|
+
elements0.push(address2);
|
1544
|
+
text0 += address2.textValue;
|
1545
|
+
labelled0.comparator = address2;
|
1546
|
+
var address3 = null;
|
1547
|
+
address3 = this.__consume__comparison();
|
1548
|
+
if (address3) {
|
1549
|
+
elements0.push(address3);
|
1550
|
+
text0 += address3.textValue;
|
1551
|
+
labelled0.right = address3;
|
1552
|
+
} else {
|
1553
|
+
elements0 = null;
|
1554
|
+
this._offset = index2;
|
1555
|
+
}
|
1556
|
+
} else {
|
1557
|
+
elements0 = null;
|
1558
|
+
this._offset = index2;
|
1559
|
+
}
|
1560
|
+
} else {
|
1561
|
+
elements0 = null;
|
1562
|
+
this._offset = index2;
|
1563
|
+
}
|
1564
|
+
if (elements0) {
|
1565
|
+
this._offset = index2;
|
1566
|
+
var klass0 = this.constructor.SyntaxNode;
|
1567
|
+
var type0 = find(this.constructor, "Comparison");
|
1568
|
+
address0 = new klass0(text0, this._offset, elements0, labelled0);
|
1569
|
+
if (typeof type0 === "object") {
|
1570
|
+
extend(address0, type0);
|
1571
|
+
}
|
1572
|
+
this._offset += text0.length;
|
1573
|
+
} else {
|
1574
|
+
address0 = null;
|
1575
|
+
}
|
1576
|
+
if (address0) {
|
1577
|
+
} else {
|
1578
|
+
this._offset = index1;
|
1579
|
+
address0 = this.__consume__atom();
|
1580
|
+
if (address0) {
|
1581
|
+
} else {
|
1582
|
+
this._offset = index1;
|
1583
|
+
}
|
1584
|
+
}
|
1585
|
+
return this._nodeCache["comparison"][index0] = address0;
|
1586
|
+
},
|
1587
|
+
__consume__comparator: function(input) {
|
1588
|
+
var address0 = null, index0 = this._offset;
|
1589
|
+
this._nodeCache["comparator"] = this._nodeCache["comparator"] || {};
|
1590
|
+
var cached = this._nodeCache["comparator"][index0];
|
1591
|
+
if (cached) {
|
1592
|
+
this._offset += cached.textValue.length;
|
1593
|
+
return cached;
|
1594
|
+
}
|
1595
|
+
var index1 = this._offset;
|
1596
|
+
var slice0 = null;
|
1597
|
+
if (this._input.length > this._offset) {
|
1598
|
+
slice0 = this._input.substring(this._offset, this._offset + 2);
|
1599
|
+
} else {
|
1600
|
+
slice0 = null;
|
1601
|
+
}
|
1602
|
+
if (slice0 === "!=") {
|
1603
|
+
var klass0 = this.constructor.SyntaxNode;
|
1604
|
+
var type0 = null;
|
1605
|
+
address0 = new klass0("!=", this._offset, []);
|
1606
|
+
if (typeof type0 === "object") {
|
1607
|
+
extend(address0, type0);
|
1608
|
+
}
|
1609
|
+
this._offset += 2;
|
1610
|
+
} else {
|
1611
|
+
address0 = null;
|
1612
|
+
var slice1 = null;
|
1613
|
+
if (this._input.length > this._offset) {
|
1614
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1615
|
+
} else {
|
1616
|
+
slice1 = null;
|
1617
|
+
}
|
1618
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1619
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"!=\""};
|
1620
|
+
}
|
1621
|
+
}
|
1622
|
+
if (address0) {
|
1623
|
+
} else {
|
1624
|
+
this._offset = index1;
|
1625
|
+
var slice2 = null;
|
1626
|
+
if (this._input.length > this._offset) {
|
1627
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
1628
|
+
} else {
|
1629
|
+
slice2 = null;
|
1630
|
+
}
|
1631
|
+
if (slice2 === "=") {
|
1632
|
+
var klass1 = this.constructor.SyntaxNode;
|
1633
|
+
var type1 = null;
|
1634
|
+
address0 = new klass1("=", this._offset, []);
|
1635
|
+
if (typeof type1 === "object") {
|
1636
|
+
extend(address0, type1);
|
1637
|
+
}
|
1638
|
+
this._offset += 1;
|
1639
|
+
} else {
|
1640
|
+
address0 = null;
|
1641
|
+
var slice3 = null;
|
1642
|
+
if (this._input.length > this._offset) {
|
1643
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
1644
|
+
} else {
|
1645
|
+
slice3 = null;
|
1646
|
+
}
|
1647
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1648
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"=\""};
|
1649
|
+
}
|
1650
|
+
}
|
1651
|
+
if (address0) {
|
1652
|
+
} else {
|
1653
|
+
this._offset = index1;
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
return this._nodeCache["comparator"][index0] = address0;
|
1657
|
+
},
|
1658
|
+
__consume__atom: function(input) {
|
1659
|
+
var address0 = null, index0 = this._offset;
|
1660
|
+
this._nodeCache["atom"] = this._nodeCache["atom"] || {};
|
1661
|
+
var cached = this._nodeCache["atom"][index0];
|
1662
|
+
if (cached) {
|
1663
|
+
this._offset += cached.textValue.length;
|
1664
|
+
return cached;
|
1665
|
+
}
|
1666
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1667
|
+
var address1 = null;
|
1668
|
+
address1 = this.__consume__space();
|
1669
|
+
if (address1) {
|
1670
|
+
elements0.push(address1);
|
1671
|
+
text0 += address1.textValue;
|
1672
|
+
labelled0.space = address1;
|
1673
|
+
var address2 = null;
|
1674
|
+
var index2 = this._offset;
|
1675
|
+
var index3 = this._offset, elements1 = [], labelled1 = {}, text1 = "";
|
1676
|
+
var address3 = null;
|
1677
|
+
var slice0 = null;
|
1678
|
+
if (this._input.length > this._offset) {
|
1679
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1680
|
+
} else {
|
1681
|
+
slice0 = null;
|
1682
|
+
}
|
1683
|
+
if (slice0 === "(") {
|
1684
|
+
var klass0 = this.constructor.SyntaxNode;
|
1685
|
+
var type0 = null;
|
1686
|
+
address3 = new klass0("(", this._offset, []);
|
1687
|
+
if (typeof type0 === "object") {
|
1688
|
+
extend(address3, type0);
|
1689
|
+
}
|
1690
|
+
this._offset += 1;
|
1691
|
+
} else {
|
1692
|
+
address3 = null;
|
1693
|
+
var slice1 = null;
|
1694
|
+
if (this._input.length > this._offset) {
|
1695
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1696
|
+
} else {
|
1697
|
+
slice1 = null;
|
1698
|
+
}
|
1699
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1700
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"(\""};
|
1701
|
+
}
|
1702
|
+
}
|
1703
|
+
if (address3) {
|
1704
|
+
elements1.push(address3);
|
1705
|
+
text1 += address3.textValue;
|
1706
|
+
var address4 = null;
|
1707
|
+
address4 = this.__consume__expression();
|
1708
|
+
if (address4) {
|
1709
|
+
elements1.push(address4);
|
1710
|
+
text1 += address4.textValue;
|
1711
|
+
labelled1.in_parens = address4;
|
1712
|
+
var address5 = null;
|
1713
|
+
var slice2 = null;
|
1714
|
+
if (this._input.length > this._offset) {
|
1715
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
1716
|
+
} else {
|
1717
|
+
slice2 = null;
|
1718
|
+
}
|
1719
|
+
if (slice2 === ")") {
|
1720
|
+
var klass1 = this.constructor.SyntaxNode;
|
1721
|
+
var type1 = null;
|
1722
|
+
address5 = new klass1(")", this._offset, []);
|
1723
|
+
if (typeof type1 === "object") {
|
1724
|
+
extend(address5, type1);
|
1725
|
+
}
|
1726
|
+
this._offset += 1;
|
1727
|
+
} else {
|
1728
|
+
address5 = null;
|
1729
|
+
var slice3 = null;
|
1730
|
+
if (this._input.length > this._offset) {
|
1731
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
1732
|
+
} else {
|
1733
|
+
slice3 = null;
|
1734
|
+
}
|
1735
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1736
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\")\""};
|
1737
|
+
}
|
1738
|
+
}
|
1739
|
+
if (address5) {
|
1740
|
+
elements1.push(address5);
|
1741
|
+
text1 += address5.textValue;
|
1742
|
+
} else {
|
1743
|
+
elements1 = null;
|
1744
|
+
this._offset = index3;
|
1745
|
+
}
|
1746
|
+
} else {
|
1747
|
+
elements1 = null;
|
1748
|
+
this._offset = index3;
|
1749
|
+
}
|
1750
|
+
} else {
|
1751
|
+
elements1 = null;
|
1752
|
+
this._offset = index3;
|
1753
|
+
}
|
1754
|
+
if (elements1) {
|
1755
|
+
this._offset = index3;
|
1756
|
+
var klass2 = this.constructor.SyntaxNode;
|
1757
|
+
var type2 = null;
|
1758
|
+
address2 = new klass2(text1, this._offset, elements1, labelled1);
|
1759
|
+
if (typeof type2 === "object") {
|
1760
|
+
extend(address2, type2);
|
1761
|
+
}
|
1762
|
+
this._offset += text1.length;
|
1763
|
+
} else {
|
1764
|
+
address2 = null;
|
1765
|
+
}
|
1766
|
+
if (address2) {
|
1767
|
+
} else {
|
1768
|
+
this._offset = index2;
|
1769
|
+
address2 = this.__consume__value();
|
1770
|
+
if (address2) {
|
1771
|
+
} else {
|
1772
|
+
this._offset = index2;
|
1773
|
+
}
|
1774
|
+
}
|
1775
|
+
if (address2) {
|
1776
|
+
elements0.push(address2);
|
1777
|
+
text0 += address2.textValue;
|
1778
|
+
labelled0.expression = address2;
|
1779
|
+
var address6 = null;
|
1780
|
+
address6 = this.__consume__space();
|
1781
|
+
if (address6) {
|
1782
|
+
elements0.push(address6);
|
1783
|
+
text0 += address6.textValue;
|
1784
|
+
labelled0.space = address6;
|
1785
|
+
} else {
|
1786
|
+
elements0 = null;
|
1787
|
+
this._offset = index1;
|
1788
|
+
}
|
1789
|
+
} else {
|
1790
|
+
elements0 = null;
|
1791
|
+
this._offset = index1;
|
1792
|
+
}
|
1793
|
+
} else {
|
1794
|
+
elements0 = null;
|
1795
|
+
this._offset = index1;
|
1796
|
+
}
|
1797
|
+
if (elements0) {
|
1798
|
+
this._offset = index1;
|
1799
|
+
var klass3 = this.constructor.SyntaxNode;
|
1800
|
+
var type3 = find(this.constructor, "Atom");
|
1801
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
1802
|
+
if (typeof type3 === "object") {
|
1803
|
+
extend(address0, type3);
|
1804
|
+
}
|
1805
|
+
this._offset += text0.length;
|
1806
|
+
} else {
|
1807
|
+
address0 = null;
|
1808
|
+
}
|
1809
|
+
return this._nodeCache["atom"][index0] = address0;
|
1810
|
+
},
|
1811
|
+
__consume__value: function(input) {
|
1812
|
+
var address0 = null, index0 = this._offset;
|
1813
|
+
this._nodeCache["value"] = this._nodeCache["value"] || {};
|
1814
|
+
var cached = this._nodeCache["value"][index0];
|
1815
|
+
if (cached) {
|
1816
|
+
this._offset += cached.textValue.length;
|
1817
|
+
return cached;
|
1818
|
+
}
|
1819
|
+
var index1 = this._offset;
|
1820
|
+
address0 = this.__consume__function_call();
|
1821
|
+
if (address0) {
|
1822
|
+
} else {
|
1823
|
+
this._offset = index1;
|
1824
|
+
address0 = this.__consume__string();
|
1825
|
+
if (address0) {
|
1826
|
+
} else {
|
1827
|
+
this._offset = index1;
|
1828
|
+
address0 = this.__consume__union_expression();
|
1829
|
+
if (address0) {
|
1830
|
+
} else {
|
1831
|
+
this._offset = index1;
|
1832
|
+
}
|
1833
|
+
}
|
1834
|
+
}
|
1835
|
+
return this._nodeCache["value"][index0] = address0;
|
1836
|
+
},
|
1837
|
+
__consume__function_call: function(input) {
|
1838
|
+
var address0 = null, index0 = this._offset;
|
1839
|
+
this._nodeCache["function_call"] = this._nodeCache["function_call"] || {};
|
1840
|
+
var cached = this._nodeCache["function_call"][index0];
|
1841
|
+
if (cached) {
|
1842
|
+
this._offset += cached.textValue.length;
|
1843
|
+
return cached;
|
1844
|
+
}
|
1845
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
1846
|
+
var address1 = null;
|
1847
|
+
address1 = this.__consume__function_name();
|
1848
|
+
if (address1) {
|
1849
|
+
elements0.push(address1);
|
1850
|
+
text0 += address1.textValue;
|
1851
|
+
labelled0.function_name = address1;
|
1852
|
+
var address2 = null;
|
1853
|
+
var slice0 = null;
|
1854
|
+
if (this._input.length > this._offset) {
|
1855
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1856
|
+
} else {
|
1857
|
+
slice0 = null;
|
1858
|
+
}
|
1859
|
+
if (slice0 === "(") {
|
1860
|
+
var klass0 = this.constructor.SyntaxNode;
|
1861
|
+
var type0 = null;
|
1862
|
+
address2 = new klass0("(", this._offset, []);
|
1863
|
+
if (typeof type0 === "object") {
|
1864
|
+
extend(address2, type0);
|
1865
|
+
}
|
1866
|
+
this._offset += 1;
|
1867
|
+
} else {
|
1868
|
+
address2 = null;
|
1869
|
+
var slice1 = null;
|
1870
|
+
if (this._input.length > this._offset) {
|
1871
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1872
|
+
} else {
|
1873
|
+
slice1 = null;
|
1874
|
+
}
|
1875
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1876
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"(\""};
|
1877
|
+
}
|
1878
|
+
}
|
1879
|
+
if (address2) {
|
1880
|
+
elements0.push(address2);
|
1881
|
+
text0 += address2.textValue;
|
1882
|
+
var address3 = null;
|
1883
|
+
address3 = this.__consume__function_args();
|
1884
|
+
if (address3) {
|
1885
|
+
elements0.push(address3);
|
1886
|
+
text0 += address3.textValue;
|
1887
|
+
labelled0.function_args = address3;
|
1888
|
+
var address4 = null;
|
1889
|
+
var slice2 = null;
|
1890
|
+
if (this._input.length > this._offset) {
|
1891
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
1892
|
+
} else {
|
1893
|
+
slice2 = null;
|
1894
|
+
}
|
1895
|
+
if (slice2 === ")") {
|
1896
|
+
var klass1 = this.constructor.SyntaxNode;
|
1897
|
+
var type1 = null;
|
1898
|
+
address4 = new klass1(")", this._offset, []);
|
1899
|
+
if (typeof type1 === "object") {
|
1900
|
+
extend(address4, type1);
|
1901
|
+
}
|
1902
|
+
this._offset += 1;
|
1903
|
+
} else {
|
1904
|
+
address4 = null;
|
1905
|
+
var slice3 = null;
|
1906
|
+
if (this._input.length > this._offset) {
|
1907
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
1908
|
+
} else {
|
1909
|
+
slice3 = null;
|
1910
|
+
}
|
1911
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1912
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\")\""};
|
1913
|
+
}
|
1914
|
+
}
|
1915
|
+
if (address4) {
|
1916
|
+
elements0.push(address4);
|
1917
|
+
text0 += address4.textValue;
|
1918
|
+
} else {
|
1919
|
+
elements0 = null;
|
1920
|
+
this._offset = index1;
|
1921
|
+
}
|
1922
|
+
} else {
|
1923
|
+
elements0 = null;
|
1924
|
+
this._offset = index1;
|
1925
|
+
}
|
1926
|
+
} else {
|
1927
|
+
elements0 = null;
|
1928
|
+
this._offset = index1;
|
1929
|
+
}
|
1930
|
+
} else {
|
1931
|
+
elements0 = null;
|
1932
|
+
this._offset = index1;
|
1933
|
+
}
|
1934
|
+
if (elements0) {
|
1935
|
+
this._offset = index1;
|
1936
|
+
var klass2 = this.constructor.SyntaxNode;
|
1937
|
+
var type2 = find(this.constructor, "FunctionCall");
|
1938
|
+
address0 = new klass2(text0, this._offset, elements0, labelled0);
|
1939
|
+
if (typeof type2 === "object") {
|
1940
|
+
extend(address0, type2);
|
1941
|
+
}
|
1942
|
+
this._offset += text0.length;
|
1943
|
+
} else {
|
1944
|
+
address0 = null;
|
1945
|
+
}
|
1946
|
+
return this._nodeCache["function_call"][index0] = address0;
|
1947
|
+
},
|
1948
|
+
__consume__function_name: function(input) {
|
1949
|
+
var address0 = null, index0 = this._offset;
|
1950
|
+
this._nodeCache["function_name"] = this._nodeCache["function_name"] || {};
|
1951
|
+
var cached = this._nodeCache["function_name"][index0];
|
1952
|
+
if (cached) {
|
1953
|
+
this._offset += cached.textValue.length;
|
1954
|
+
return cached;
|
1955
|
+
}
|
1956
|
+
var remaining0 = 1, index1 = this._offset, elements0 = [], text0 = "", address1 = true;
|
1957
|
+
while (address1) {
|
1958
|
+
var slice0 = null;
|
1959
|
+
if (this._input.length > this._offset) {
|
1960
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
1961
|
+
} else {
|
1962
|
+
slice0 = null;
|
1963
|
+
}
|
1964
|
+
if (slice0 && /^[a-z\-]/.test(slice0)) {
|
1965
|
+
var klass0 = this.constructor.SyntaxNode;
|
1966
|
+
var type0 = null;
|
1967
|
+
address1 = new klass0(slice0, this._offset, []);
|
1968
|
+
if (typeof type0 === "object") {
|
1969
|
+
extend(address1, type0);
|
1970
|
+
}
|
1971
|
+
this._offset += 1;
|
1972
|
+
} else {
|
1973
|
+
address1 = null;
|
1974
|
+
var slice1 = null;
|
1975
|
+
if (this._input.length > this._offset) {
|
1976
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
1977
|
+
} else {
|
1978
|
+
slice1 = null;
|
1979
|
+
}
|
1980
|
+
if (!this.error || this.error.offset <= this._offset) {
|
1981
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[a-z\\-]"};
|
1982
|
+
}
|
1983
|
+
}
|
1984
|
+
if (address1) {
|
1985
|
+
elements0.push(address1);
|
1986
|
+
text0 += address1.textValue;
|
1987
|
+
remaining0 -= 1;
|
1988
|
+
}
|
1989
|
+
}
|
1990
|
+
if (remaining0 <= 0) {
|
1991
|
+
this._offset = index1;
|
1992
|
+
var klass1 = this.constructor.SyntaxNode;
|
1993
|
+
var type1 = null;
|
1994
|
+
address0 = new klass1(text0, this._offset, elements0);
|
1995
|
+
if (typeof type1 === "object") {
|
1996
|
+
extend(address0, type1);
|
1997
|
+
}
|
1998
|
+
this._offset += text0.length;
|
1999
|
+
} else {
|
2000
|
+
address0 = null;
|
2001
|
+
}
|
2002
|
+
return this._nodeCache["function_name"][index0] = address0;
|
2003
|
+
},
|
2004
|
+
__consume__function_args: function(input) {
|
2005
|
+
var address0 = null, index0 = this._offset;
|
2006
|
+
this._nodeCache["function_args"] = this._nodeCache["function_args"] || {};
|
2007
|
+
var cached = this._nodeCache["function_args"][index0];
|
2008
|
+
if (cached) {
|
2009
|
+
this._offset += cached.textValue.length;
|
2010
|
+
return cached;
|
2011
|
+
}
|
2012
|
+
var index1 = this._offset;
|
2013
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
2014
|
+
var address1 = null;
|
2015
|
+
address1 = this.__consume__expression();
|
2016
|
+
if (address1) {
|
2017
|
+
elements0.push(address1);
|
2018
|
+
text0 += address1.textValue;
|
2019
|
+
labelled0.first = address1;
|
2020
|
+
var address2 = null;
|
2021
|
+
var remaining0 = 0, index3 = this._offset, elements1 = [], text1 = "", address3 = true;
|
2022
|
+
while (address3) {
|
2023
|
+
var index4 = this._offset, elements2 = [], labelled1 = {}, text2 = "";
|
2024
|
+
var address4 = null;
|
2025
|
+
var slice0 = null;
|
2026
|
+
if (this._input.length > this._offset) {
|
2027
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
2028
|
+
} else {
|
2029
|
+
slice0 = null;
|
2030
|
+
}
|
2031
|
+
if (slice0 === ",") {
|
2032
|
+
var klass0 = this.constructor.SyntaxNode;
|
2033
|
+
var type0 = null;
|
2034
|
+
address4 = new klass0(",", this._offset, []);
|
2035
|
+
if (typeof type0 === "object") {
|
2036
|
+
extend(address4, type0);
|
2037
|
+
}
|
2038
|
+
this._offset += 1;
|
2039
|
+
} else {
|
2040
|
+
address4 = null;
|
2041
|
+
var slice1 = null;
|
2042
|
+
if (this._input.length > this._offset) {
|
2043
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
2044
|
+
} else {
|
2045
|
+
slice1 = null;
|
2046
|
+
}
|
2047
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2048
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\",\""};
|
2049
|
+
}
|
2050
|
+
}
|
2051
|
+
if (address4) {
|
2052
|
+
elements2.push(address4);
|
2053
|
+
text2 += address4.textValue;
|
2054
|
+
var address5 = null;
|
2055
|
+
address5 = this.__consume__expression();
|
2056
|
+
if (address5) {
|
2057
|
+
elements2.push(address5);
|
2058
|
+
text2 += address5.textValue;
|
2059
|
+
labelled1.expression = address5;
|
2060
|
+
} else {
|
2061
|
+
elements2 = null;
|
2062
|
+
this._offset = index4;
|
2063
|
+
}
|
2064
|
+
} else {
|
2065
|
+
elements2 = null;
|
2066
|
+
this._offset = index4;
|
2067
|
+
}
|
2068
|
+
if (elements2) {
|
2069
|
+
this._offset = index4;
|
2070
|
+
var klass1 = this.constructor.SyntaxNode;
|
2071
|
+
var type1 = null;
|
2072
|
+
address3 = new klass1(text2, this._offset, elements2, labelled1);
|
2073
|
+
if (typeof type1 === "object") {
|
2074
|
+
extend(address3, type1);
|
2075
|
+
}
|
2076
|
+
this._offset += text2.length;
|
2077
|
+
} else {
|
2078
|
+
address3 = null;
|
2079
|
+
}
|
2080
|
+
if (address3) {
|
2081
|
+
elements1.push(address3);
|
2082
|
+
text1 += address3.textValue;
|
2083
|
+
remaining0 -= 1;
|
2084
|
+
}
|
2085
|
+
}
|
2086
|
+
if (remaining0 <= 0) {
|
2087
|
+
this._offset = index3;
|
2088
|
+
var klass2 = this.constructor.SyntaxNode;
|
2089
|
+
var type2 = null;
|
2090
|
+
address2 = new klass2(text1, this._offset, elements1);
|
2091
|
+
if (typeof type2 === "object") {
|
2092
|
+
extend(address2, type2);
|
2093
|
+
}
|
2094
|
+
this._offset += text1.length;
|
2095
|
+
} else {
|
2096
|
+
address2 = null;
|
2097
|
+
}
|
2098
|
+
if (address2) {
|
2099
|
+
elements0.push(address2);
|
2100
|
+
text0 += address2.textValue;
|
2101
|
+
labelled0.rest = address2;
|
2102
|
+
} else {
|
2103
|
+
elements0 = null;
|
2104
|
+
this._offset = index2;
|
2105
|
+
}
|
2106
|
+
} else {
|
2107
|
+
elements0 = null;
|
2108
|
+
this._offset = index2;
|
2109
|
+
}
|
2110
|
+
if (elements0) {
|
2111
|
+
this._offset = index2;
|
2112
|
+
var klass3 = this.constructor.SyntaxNode;
|
2113
|
+
var type3 = null;
|
2114
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
2115
|
+
if (typeof type3 === "object") {
|
2116
|
+
extend(address0, type3);
|
2117
|
+
}
|
2118
|
+
this._offset += text0.length;
|
2119
|
+
} else {
|
2120
|
+
address0 = null;
|
2121
|
+
}
|
2122
|
+
if (address0) {
|
2123
|
+
} else {
|
2124
|
+
this._offset = index1;
|
2125
|
+
var klass4 = this.constructor.SyntaxNode;
|
2126
|
+
var type4 = null;
|
2127
|
+
address0 = new klass4("", this._offset, []);
|
2128
|
+
if (typeof type4 === "object") {
|
2129
|
+
extend(address0, type4);
|
2130
|
+
}
|
2131
|
+
this._offset += 0;
|
2132
|
+
}
|
2133
|
+
return this._nodeCache["function_args"][index0] = address0;
|
2134
|
+
},
|
2135
|
+
__consume__integer: function(input) {
|
2136
|
+
var address0 = null, index0 = this._offset;
|
2137
|
+
this._nodeCache["integer"] = this._nodeCache["integer"] || {};
|
2138
|
+
var cached = this._nodeCache["integer"][index0];
|
2139
|
+
if (cached) {
|
2140
|
+
this._offset += cached.textValue.length;
|
2141
|
+
return cached;
|
2142
|
+
}
|
2143
|
+
var index1 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
2144
|
+
var address1 = null;
|
2145
|
+
var slice0 = null;
|
2146
|
+
if (this._input.length > this._offset) {
|
2147
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
2148
|
+
} else {
|
2149
|
+
slice0 = null;
|
2150
|
+
}
|
2151
|
+
if (slice0 && /^[1-9]/.test(slice0)) {
|
2152
|
+
var klass0 = this.constructor.SyntaxNode;
|
2153
|
+
var type0 = null;
|
2154
|
+
address1 = new klass0(slice0, this._offset, []);
|
2155
|
+
if (typeof type0 === "object") {
|
2156
|
+
extend(address1, type0);
|
2157
|
+
}
|
2158
|
+
this._offset += 1;
|
2159
|
+
} else {
|
2160
|
+
address1 = null;
|
2161
|
+
var slice1 = null;
|
2162
|
+
if (this._input.length > this._offset) {
|
2163
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
2164
|
+
} else {
|
2165
|
+
slice1 = null;
|
2166
|
+
}
|
2167
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2168
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[1-9]"};
|
2169
|
+
}
|
2170
|
+
}
|
2171
|
+
if (address1) {
|
2172
|
+
elements0.push(address1);
|
2173
|
+
text0 += address1.textValue;
|
2174
|
+
var address2 = null;
|
2175
|
+
var remaining0 = 0, index2 = this._offset, elements1 = [], text1 = "", address3 = true;
|
2176
|
+
while (address3) {
|
2177
|
+
var slice2 = null;
|
2178
|
+
if (this._input.length > this._offset) {
|
2179
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
2180
|
+
} else {
|
2181
|
+
slice2 = null;
|
2182
|
+
}
|
2183
|
+
if (slice2 && /^[0-9]/.test(slice2)) {
|
2184
|
+
var klass1 = this.constructor.SyntaxNode;
|
2185
|
+
var type1 = null;
|
2186
|
+
address3 = new klass1(slice2, this._offset, []);
|
2187
|
+
if (typeof type1 === "object") {
|
2188
|
+
extend(address3, type1);
|
2189
|
+
}
|
2190
|
+
this._offset += 1;
|
2191
|
+
} else {
|
2192
|
+
address3 = null;
|
2193
|
+
var slice3 = null;
|
2194
|
+
if (this._input.length > this._offset) {
|
2195
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
2196
|
+
} else {
|
2197
|
+
slice3 = null;
|
2198
|
+
}
|
2199
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2200
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[0-9]"};
|
2201
|
+
}
|
2202
|
+
}
|
2203
|
+
if (address3) {
|
2204
|
+
elements1.push(address3);
|
2205
|
+
text1 += address3.textValue;
|
2206
|
+
remaining0 -= 1;
|
2207
|
+
}
|
2208
|
+
}
|
2209
|
+
if (remaining0 <= 0) {
|
2210
|
+
this._offset = index2;
|
2211
|
+
var klass2 = this.constructor.SyntaxNode;
|
2212
|
+
var type2 = null;
|
2213
|
+
address2 = new klass2(text1, this._offset, elements1);
|
2214
|
+
if (typeof type2 === "object") {
|
2215
|
+
extend(address2, type2);
|
2216
|
+
}
|
2217
|
+
this._offset += text1.length;
|
2218
|
+
} else {
|
2219
|
+
address2 = null;
|
2220
|
+
}
|
2221
|
+
if (address2) {
|
2222
|
+
elements0.push(address2);
|
2223
|
+
text0 += address2.textValue;
|
2224
|
+
} else {
|
2225
|
+
elements0 = null;
|
2226
|
+
this._offset = index1;
|
2227
|
+
}
|
2228
|
+
} else {
|
2229
|
+
elements0 = null;
|
2230
|
+
this._offset = index1;
|
2231
|
+
}
|
2232
|
+
if (elements0) {
|
2233
|
+
this._offset = index1;
|
2234
|
+
var klass3 = this.constructor.SyntaxNode;
|
2235
|
+
var type3 = find(this.constructor, "Integer");
|
2236
|
+
address0 = new klass3(text0, this._offset, elements0, labelled0);
|
2237
|
+
if (typeof type3 === "object") {
|
2238
|
+
extend(address0, type3);
|
2239
|
+
}
|
2240
|
+
this._offset += text0.length;
|
2241
|
+
} else {
|
2242
|
+
address0 = null;
|
2243
|
+
}
|
2244
|
+
return this._nodeCache["integer"][index0] = address0;
|
2245
|
+
},
|
2246
|
+
__consume__string: function(input) {
|
2247
|
+
var address0 = null, index0 = this._offset;
|
2248
|
+
this._nodeCache["string"] = this._nodeCache["string"] || {};
|
2249
|
+
var cached = this._nodeCache["string"][index0];
|
2250
|
+
if (cached) {
|
2251
|
+
this._offset += cached.textValue.length;
|
2252
|
+
return cached;
|
2253
|
+
}
|
2254
|
+
var index1 = this._offset;
|
2255
|
+
var index2 = this._offset, elements0 = [], labelled0 = {}, text0 = "";
|
2256
|
+
var address1 = null;
|
2257
|
+
var slice0 = null;
|
2258
|
+
if (this._input.length > this._offset) {
|
2259
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
2260
|
+
} else {
|
2261
|
+
slice0 = null;
|
2262
|
+
}
|
2263
|
+
if (slice0 === "'") {
|
2264
|
+
var klass0 = this.constructor.SyntaxNode;
|
2265
|
+
var type0 = null;
|
2266
|
+
address1 = new klass0("'", this._offset, []);
|
2267
|
+
if (typeof type0 === "object") {
|
2268
|
+
extend(address1, type0);
|
2269
|
+
}
|
2270
|
+
this._offset += 1;
|
2271
|
+
} else {
|
2272
|
+
address1 = null;
|
2273
|
+
var slice1 = null;
|
2274
|
+
if (this._input.length > this._offset) {
|
2275
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
2276
|
+
} else {
|
2277
|
+
slice1 = null;
|
2278
|
+
}
|
2279
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2280
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"'\""};
|
2281
|
+
}
|
2282
|
+
}
|
2283
|
+
if (address1) {
|
2284
|
+
elements0.push(address1);
|
2285
|
+
text0 += address1.textValue;
|
2286
|
+
var address2 = null;
|
2287
|
+
var remaining0 = 0, index3 = this._offset, elements1 = [], text1 = "", address3 = true;
|
2288
|
+
while (address3) {
|
2289
|
+
var index4 = this._offset;
|
2290
|
+
var index5 = this._offset, elements2 = [], labelled1 = {}, text2 = "";
|
2291
|
+
var address4 = null;
|
2292
|
+
var slice2 = null;
|
2293
|
+
if (this._input.length > this._offset) {
|
2294
|
+
slice2 = this._input.substring(this._offset, this._offset + 1);
|
2295
|
+
} else {
|
2296
|
+
slice2 = null;
|
2297
|
+
}
|
2298
|
+
if (slice2 === "\\") {
|
2299
|
+
var klass1 = this.constructor.SyntaxNode;
|
2300
|
+
var type1 = null;
|
2301
|
+
address4 = new klass1("\\", this._offset, []);
|
2302
|
+
if (typeof type1 === "object") {
|
2303
|
+
extend(address4, type1);
|
2304
|
+
}
|
2305
|
+
this._offset += 1;
|
2306
|
+
} else {
|
2307
|
+
address4 = null;
|
2308
|
+
var slice3 = null;
|
2309
|
+
if (this._input.length > this._offset) {
|
2310
|
+
slice3 = this._input.substring(this._offset, this._offset + 1);
|
2311
|
+
} else {
|
2312
|
+
slice3 = null;
|
2313
|
+
}
|
2314
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2315
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"\\\\\""};
|
2316
|
+
}
|
2317
|
+
}
|
2318
|
+
if (address4) {
|
2319
|
+
elements2.push(address4);
|
2320
|
+
text2 += address4.textValue;
|
2321
|
+
var address5 = null;
|
2322
|
+
var slice4 = null;
|
2323
|
+
if (this._input.length > this._offset) {
|
2324
|
+
slice4 = this._input.substring(this._offset, this._offset + 1);
|
2325
|
+
} else {
|
2326
|
+
slice4 = null;
|
2327
|
+
}
|
2328
|
+
var temp0 = slice4;
|
2329
|
+
if (temp0 === null) {
|
2330
|
+
address5 = null;
|
2331
|
+
var slice5 = null;
|
2332
|
+
if (this._input.length > this._offset) {
|
2333
|
+
slice5 = this._input.substring(this._offset, this._offset + 1);
|
2334
|
+
} else {
|
2335
|
+
slice5 = null;
|
2336
|
+
}
|
2337
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2338
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "<any char>"};
|
2339
|
+
}
|
2340
|
+
} else {
|
2341
|
+
var klass2 = this.constructor.SyntaxNode;
|
2342
|
+
var type2 = null;
|
2343
|
+
address5 = new klass2(temp0, this._offset, []);
|
2344
|
+
if (typeof type2 === "object") {
|
2345
|
+
extend(address5, type2);
|
2346
|
+
}
|
2347
|
+
this._offset += 1;
|
2348
|
+
}
|
2349
|
+
if (address5) {
|
2350
|
+
elements2.push(address5);
|
2351
|
+
text2 += address5.textValue;
|
2352
|
+
} else {
|
2353
|
+
elements2 = null;
|
2354
|
+
this._offset = index5;
|
2355
|
+
}
|
2356
|
+
} else {
|
2357
|
+
elements2 = null;
|
2358
|
+
this._offset = index5;
|
2359
|
+
}
|
2360
|
+
if (elements2) {
|
2361
|
+
this._offset = index5;
|
2362
|
+
var klass3 = this.constructor.SyntaxNode;
|
2363
|
+
var type3 = null;
|
2364
|
+
address3 = new klass3(text2, this._offset, elements2, labelled1);
|
2365
|
+
if (typeof type3 === "object") {
|
2366
|
+
extend(address3, type3);
|
2367
|
+
}
|
2368
|
+
this._offset += text2.length;
|
2369
|
+
} else {
|
2370
|
+
address3 = null;
|
2371
|
+
}
|
2372
|
+
if (address3) {
|
2373
|
+
} else {
|
2374
|
+
this._offset = index4;
|
2375
|
+
var slice6 = null;
|
2376
|
+
if (this._input.length > this._offset) {
|
2377
|
+
slice6 = this._input.substring(this._offset, this._offset + 1);
|
2378
|
+
} else {
|
2379
|
+
slice6 = null;
|
2380
|
+
}
|
2381
|
+
if (slice6 && /^[^']/.test(slice6)) {
|
2382
|
+
var klass4 = this.constructor.SyntaxNode;
|
2383
|
+
var type4 = null;
|
2384
|
+
address3 = new klass4(slice6, this._offset, []);
|
2385
|
+
if (typeof type4 === "object") {
|
2386
|
+
extend(address3, type4);
|
2387
|
+
}
|
2388
|
+
this._offset += 1;
|
2389
|
+
} else {
|
2390
|
+
address3 = null;
|
2391
|
+
var slice7 = null;
|
2392
|
+
if (this._input.length > this._offset) {
|
2393
|
+
slice7 = this._input.substring(this._offset, this._offset + 1);
|
2394
|
+
} else {
|
2395
|
+
slice7 = null;
|
2396
|
+
}
|
2397
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2398
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[^']"};
|
2399
|
+
}
|
2400
|
+
}
|
2401
|
+
if (address3) {
|
2402
|
+
} else {
|
2403
|
+
this._offset = index4;
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
if (address3) {
|
2407
|
+
elements1.push(address3);
|
2408
|
+
text1 += address3.textValue;
|
2409
|
+
remaining0 -= 1;
|
2410
|
+
}
|
2411
|
+
}
|
2412
|
+
if (remaining0 <= 0) {
|
2413
|
+
this._offset = index3;
|
2414
|
+
var klass5 = this.constructor.SyntaxNode;
|
2415
|
+
var type5 = null;
|
2416
|
+
address2 = new klass5(text1, this._offset, elements1);
|
2417
|
+
if (typeof type5 === "object") {
|
2418
|
+
extend(address2, type5);
|
2419
|
+
}
|
2420
|
+
this._offset += text1.length;
|
2421
|
+
} else {
|
2422
|
+
address2 = null;
|
2423
|
+
}
|
2424
|
+
if (address2) {
|
2425
|
+
elements0.push(address2);
|
2426
|
+
text0 += address2.textValue;
|
2427
|
+
var address6 = null;
|
2428
|
+
var slice8 = null;
|
2429
|
+
if (this._input.length > this._offset) {
|
2430
|
+
slice8 = this._input.substring(this._offset, this._offset + 1);
|
2431
|
+
} else {
|
2432
|
+
slice8 = null;
|
2433
|
+
}
|
2434
|
+
if (slice8 === "'") {
|
2435
|
+
var klass6 = this.constructor.SyntaxNode;
|
2436
|
+
var type6 = null;
|
2437
|
+
address6 = new klass6("'", this._offset, []);
|
2438
|
+
if (typeof type6 === "object") {
|
2439
|
+
extend(address6, type6);
|
2440
|
+
}
|
2441
|
+
this._offset += 1;
|
2442
|
+
} else {
|
2443
|
+
address6 = null;
|
2444
|
+
var slice9 = null;
|
2445
|
+
if (this._input.length > this._offset) {
|
2446
|
+
slice9 = this._input.substring(this._offset, this._offset + 1);
|
2447
|
+
} else {
|
2448
|
+
slice9 = null;
|
2449
|
+
}
|
2450
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2451
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"'\""};
|
2452
|
+
}
|
2453
|
+
}
|
2454
|
+
if (address6) {
|
2455
|
+
elements0.push(address6);
|
2456
|
+
text0 += address6.textValue;
|
2457
|
+
} else {
|
2458
|
+
elements0 = null;
|
2459
|
+
this._offset = index2;
|
2460
|
+
}
|
2461
|
+
} else {
|
2462
|
+
elements0 = null;
|
2463
|
+
this._offset = index2;
|
2464
|
+
}
|
2465
|
+
} else {
|
2466
|
+
elements0 = null;
|
2467
|
+
this._offset = index2;
|
2468
|
+
}
|
2469
|
+
if (elements0) {
|
2470
|
+
this._offset = index2;
|
2471
|
+
var klass7 = this.constructor.SyntaxNode;
|
2472
|
+
var type7 = null;
|
2473
|
+
address0 = new klass7(text0, this._offset, elements0, labelled0);
|
2474
|
+
if (typeof type7 === "object") {
|
2475
|
+
extend(address0, type7);
|
2476
|
+
}
|
2477
|
+
this._offset += text0.length;
|
2478
|
+
} else {
|
2479
|
+
address0 = null;
|
2480
|
+
}
|
2481
|
+
if (address0) {
|
2482
|
+
var type8 = find(this.constructor, "String");
|
2483
|
+
if (typeof type8 === "object") {
|
2484
|
+
extend(address0, type8);
|
2485
|
+
}
|
2486
|
+
} else {
|
2487
|
+
this._offset = index1;
|
2488
|
+
var index6 = this._offset, elements3 = [], labelled2 = {}, text3 = "";
|
2489
|
+
var address7 = null;
|
2490
|
+
var slice10 = null;
|
2491
|
+
if (this._input.length > this._offset) {
|
2492
|
+
slice10 = this._input.substring(this._offset, this._offset + 1);
|
2493
|
+
} else {
|
2494
|
+
slice10 = null;
|
2495
|
+
}
|
2496
|
+
if (slice10 === "\"") {
|
2497
|
+
var klass8 = this.constructor.SyntaxNode;
|
2498
|
+
var type9 = null;
|
2499
|
+
address7 = new klass8("\"", this._offset, []);
|
2500
|
+
if (typeof type9 === "object") {
|
2501
|
+
extend(address7, type9);
|
2502
|
+
}
|
2503
|
+
this._offset += 1;
|
2504
|
+
} else {
|
2505
|
+
address7 = null;
|
2506
|
+
var slice11 = null;
|
2507
|
+
if (this._input.length > this._offset) {
|
2508
|
+
slice11 = this._input.substring(this._offset, this._offset + 1);
|
2509
|
+
} else {
|
2510
|
+
slice11 = null;
|
2511
|
+
}
|
2512
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2513
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"\\\"\""};
|
2514
|
+
}
|
2515
|
+
}
|
2516
|
+
if (address7) {
|
2517
|
+
elements3.push(address7);
|
2518
|
+
text3 += address7.textValue;
|
2519
|
+
var address8 = null;
|
2520
|
+
var remaining1 = 0, index7 = this._offset, elements4 = [], text4 = "", address9 = true;
|
2521
|
+
while (address9) {
|
2522
|
+
var index8 = this._offset;
|
2523
|
+
var index9 = this._offset, elements5 = [], labelled3 = {}, text5 = "";
|
2524
|
+
var address10 = null;
|
2525
|
+
var slice12 = null;
|
2526
|
+
if (this._input.length > this._offset) {
|
2527
|
+
slice12 = this._input.substring(this._offset, this._offset + 1);
|
2528
|
+
} else {
|
2529
|
+
slice12 = null;
|
2530
|
+
}
|
2531
|
+
if (slice12 === "\\") {
|
2532
|
+
var klass9 = this.constructor.SyntaxNode;
|
2533
|
+
var type10 = null;
|
2534
|
+
address10 = new klass9("\\", this._offset, []);
|
2535
|
+
if (typeof type10 === "object") {
|
2536
|
+
extend(address10, type10);
|
2537
|
+
}
|
2538
|
+
this._offset += 1;
|
2539
|
+
} else {
|
2540
|
+
address10 = null;
|
2541
|
+
var slice13 = null;
|
2542
|
+
if (this._input.length > this._offset) {
|
2543
|
+
slice13 = this._input.substring(this._offset, this._offset + 1);
|
2544
|
+
} else {
|
2545
|
+
slice13 = null;
|
2546
|
+
}
|
2547
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2548
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"\\\\\""};
|
2549
|
+
}
|
2550
|
+
}
|
2551
|
+
if (address10) {
|
2552
|
+
elements5.push(address10);
|
2553
|
+
text5 += address10.textValue;
|
2554
|
+
var address11 = null;
|
2555
|
+
var slice14 = null;
|
2556
|
+
if (this._input.length > this._offset) {
|
2557
|
+
slice14 = this._input.substring(this._offset, this._offset + 1);
|
2558
|
+
} else {
|
2559
|
+
slice14 = null;
|
2560
|
+
}
|
2561
|
+
var temp1 = slice14;
|
2562
|
+
if (temp1 === null) {
|
2563
|
+
address11 = null;
|
2564
|
+
var slice15 = null;
|
2565
|
+
if (this._input.length > this._offset) {
|
2566
|
+
slice15 = this._input.substring(this._offset, this._offset + 1);
|
2567
|
+
} else {
|
2568
|
+
slice15 = null;
|
2569
|
+
}
|
2570
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2571
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "<any char>"};
|
2572
|
+
}
|
2573
|
+
} else {
|
2574
|
+
var klass10 = this.constructor.SyntaxNode;
|
2575
|
+
var type11 = null;
|
2576
|
+
address11 = new klass10(temp1, this._offset, []);
|
2577
|
+
if (typeof type11 === "object") {
|
2578
|
+
extend(address11, type11);
|
2579
|
+
}
|
2580
|
+
this._offset += 1;
|
2581
|
+
}
|
2582
|
+
if (address11) {
|
2583
|
+
elements5.push(address11);
|
2584
|
+
text5 += address11.textValue;
|
2585
|
+
} else {
|
2586
|
+
elements5 = null;
|
2587
|
+
this._offset = index9;
|
2588
|
+
}
|
2589
|
+
} else {
|
2590
|
+
elements5 = null;
|
2591
|
+
this._offset = index9;
|
2592
|
+
}
|
2593
|
+
if (elements5) {
|
2594
|
+
this._offset = index9;
|
2595
|
+
var klass11 = this.constructor.SyntaxNode;
|
2596
|
+
var type12 = null;
|
2597
|
+
address9 = new klass11(text5, this._offset, elements5, labelled3);
|
2598
|
+
if (typeof type12 === "object") {
|
2599
|
+
extend(address9, type12);
|
2600
|
+
}
|
2601
|
+
this._offset += text5.length;
|
2602
|
+
} else {
|
2603
|
+
address9 = null;
|
2604
|
+
}
|
2605
|
+
if (address9) {
|
2606
|
+
} else {
|
2607
|
+
this._offset = index8;
|
2608
|
+
var slice16 = null;
|
2609
|
+
if (this._input.length > this._offset) {
|
2610
|
+
slice16 = this._input.substring(this._offset, this._offset + 1);
|
2611
|
+
} else {
|
2612
|
+
slice16 = null;
|
2613
|
+
}
|
2614
|
+
if (slice16 && /^[^"]/.test(slice16)) {
|
2615
|
+
var klass12 = this.constructor.SyntaxNode;
|
2616
|
+
var type13 = null;
|
2617
|
+
address9 = new klass12(slice16, this._offset, []);
|
2618
|
+
if (typeof type13 === "object") {
|
2619
|
+
extend(address9, type13);
|
2620
|
+
}
|
2621
|
+
this._offset += 1;
|
2622
|
+
} else {
|
2623
|
+
address9 = null;
|
2624
|
+
var slice17 = null;
|
2625
|
+
if (this._input.length > this._offset) {
|
2626
|
+
slice17 = this._input.substring(this._offset, this._offset + 1);
|
2627
|
+
} else {
|
2628
|
+
slice17 = null;
|
2629
|
+
}
|
2630
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2631
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "[^\"]"};
|
2632
|
+
}
|
2633
|
+
}
|
2634
|
+
if (address9) {
|
2635
|
+
} else {
|
2636
|
+
this._offset = index8;
|
2637
|
+
}
|
2638
|
+
}
|
2639
|
+
if (address9) {
|
2640
|
+
elements4.push(address9);
|
2641
|
+
text4 += address9.textValue;
|
2642
|
+
remaining1 -= 1;
|
2643
|
+
}
|
2644
|
+
}
|
2645
|
+
if (remaining1 <= 0) {
|
2646
|
+
this._offset = index7;
|
2647
|
+
var klass13 = this.constructor.SyntaxNode;
|
2648
|
+
var type14 = null;
|
2649
|
+
address8 = new klass13(text4, this._offset, elements4);
|
2650
|
+
if (typeof type14 === "object") {
|
2651
|
+
extend(address8, type14);
|
2652
|
+
}
|
2653
|
+
this._offset += text4.length;
|
2654
|
+
} else {
|
2655
|
+
address8 = null;
|
2656
|
+
}
|
2657
|
+
if (address8) {
|
2658
|
+
elements3.push(address8);
|
2659
|
+
text3 += address8.textValue;
|
2660
|
+
var address12 = null;
|
2661
|
+
var slice18 = null;
|
2662
|
+
if (this._input.length > this._offset) {
|
2663
|
+
slice18 = this._input.substring(this._offset, this._offset + 1);
|
2664
|
+
} else {
|
2665
|
+
slice18 = null;
|
2666
|
+
}
|
2667
|
+
if (slice18 === "\"") {
|
2668
|
+
var klass14 = this.constructor.SyntaxNode;
|
2669
|
+
var type15 = null;
|
2670
|
+
address12 = new klass14("\"", this._offset, []);
|
2671
|
+
if (typeof type15 === "object") {
|
2672
|
+
extend(address12, type15);
|
2673
|
+
}
|
2674
|
+
this._offset += 1;
|
2675
|
+
} else {
|
2676
|
+
address12 = null;
|
2677
|
+
var slice19 = null;
|
2678
|
+
if (this._input.length > this._offset) {
|
2679
|
+
slice19 = this._input.substring(this._offset, this._offset + 1);
|
2680
|
+
} else {
|
2681
|
+
slice19 = null;
|
2682
|
+
}
|
2683
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2684
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\"\\\"\""};
|
2685
|
+
}
|
2686
|
+
}
|
2687
|
+
if (address12) {
|
2688
|
+
elements3.push(address12);
|
2689
|
+
text3 += address12.textValue;
|
2690
|
+
} else {
|
2691
|
+
elements3 = null;
|
2692
|
+
this._offset = index6;
|
2693
|
+
}
|
2694
|
+
} else {
|
2695
|
+
elements3 = null;
|
2696
|
+
this._offset = index6;
|
2697
|
+
}
|
2698
|
+
} else {
|
2699
|
+
elements3 = null;
|
2700
|
+
this._offset = index6;
|
2701
|
+
}
|
2702
|
+
if (elements3) {
|
2703
|
+
this._offset = index6;
|
2704
|
+
var klass15 = this.constructor.SyntaxNode;
|
2705
|
+
var type16 = null;
|
2706
|
+
address0 = new klass15(text3, this._offset, elements3, labelled2);
|
2707
|
+
if (typeof type16 === "object") {
|
2708
|
+
extend(address0, type16);
|
2709
|
+
}
|
2710
|
+
this._offset += text3.length;
|
2711
|
+
} else {
|
2712
|
+
address0 = null;
|
2713
|
+
}
|
2714
|
+
if (address0) {
|
2715
|
+
var type17 = find(this.constructor, "String");
|
2716
|
+
if (typeof type17 === "object") {
|
2717
|
+
extend(address0, type17);
|
2718
|
+
}
|
2719
|
+
} else {
|
2720
|
+
this._offset = index1;
|
2721
|
+
}
|
2722
|
+
}
|
2723
|
+
return this._nodeCache["string"][index0] = address0;
|
2724
|
+
},
|
2725
|
+
__consume__space: function(input) {
|
2726
|
+
var address0 = null, index0 = this._offset;
|
2727
|
+
this._nodeCache["space"] = this._nodeCache["space"] || {};
|
2728
|
+
var cached = this._nodeCache["space"][index0];
|
2729
|
+
if (cached) {
|
2730
|
+
this._offset += cached.textValue.length;
|
2731
|
+
return cached;
|
2732
|
+
}
|
2733
|
+
var remaining0 = 0, index1 = this._offset, elements0 = [], text0 = "", address1 = true;
|
2734
|
+
while (address1) {
|
2735
|
+
var slice0 = null;
|
2736
|
+
if (this._input.length > this._offset) {
|
2737
|
+
slice0 = this._input.substring(this._offset, this._offset + 1);
|
2738
|
+
} else {
|
2739
|
+
slice0 = null;
|
2740
|
+
}
|
2741
|
+
if (slice0 === " ") {
|
2742
|
+
var klass0 = this.constructor.SyntaxNode;
|
2743
|
+
var type0 = null;
|
2744
|
+
address1 = new klass0(" ", this._offset, []);
|
2745
|
+
if (typeof type0 === "object") {
|
2746
|
+
extend(address1, type0);
|
2747
|
+
}
|
2748
|
+
this._offset += 1;
|
2749
|
+
} else {
|
2750
|
+
address1 = null;
|
2751
|
+
var slice1 = null;
|
2752
|
+
if (this._input.length > this._offset) {
|
2753
|
+
slice1 = this._input.substring(this._offset, this._offset + 1);
|
2754
|
+
} else {
|
2755
|
+
slice1 = null;
|
2756
|
+
}
|
2757
|
+
if (!this.error || this.error.offset <= this._offset) {
|
2758
|
+
this.error = this.constructor.lastError = {input: this._input, offset: this._offset, expected: "\" \""};
|
2759
|
+
}
|
2760
|
+
}
|
2761
|
+
if (address1) {
|
2762
|
+
elements0.push(address1);
|
2763
|
+
text0 += address1.textValue;
|
2764
|
+
remaining0 -= 1;
|
2765
|
+
}
|
2766
|
+
}
|
2767
|
+
if (remaining0 <= 0) {
|
2768
|
+
this._offset = index1;
|
2769
|
+
var klass1 = this.constructor.SyntaxNode;
|
2770
|
+
var type1 = null;
|
2771
|
+
address0 = new klass1(text0, this._offset, elements0);
|
2772
|
+
if (typeof type1 === "object") {
|
2773
|
+
extend(address0, type1);
|
2774
|
+
}
|
2775
|
+
this._offset += text0.length;
|
2776
|
+
} else {
|
2777
|
+
address0 = null;
|
2778
|
+
}
|
2779
|
+
return this._nodeCache["space"][index0] = address0;
|
2780
|
+
}
|
2781
|
+
};
|
2782
|
+
|
2783
|
+
var Parser = function(input) {
|
2784
|
+
this._input = input;
|
2785
|
+
this._offset = 0;
|
2786
|
+
this._nodeCache = {};
|
2787
|
+
};
|
2788
|
+
|
2789
|
+
Parser.prototype.parse = function() {
|
2790
|
+
var result = this.__consume__union_expression();
|
2791
|
+
if (result && this._offset === this._input.length) {
|
2792
|
+
return result;
|
2793
|
+
}
|
2794
|
+
if (!(this.error)) {
|
2795
|
+
this.error = {input: this._input, offset: this._offset, expected: "<EOF>"};
|
2796
|
+
}
|
2797
|
+
var message = formatError(this.error);
|
2798
|
+
var error = new Error(message);
|
2799
|
+
throw error;
|
2800
|
+
};
|
2801
|
+
|
2802
|
+
Parser.parse = function(input) {
|
2803
|
+
var parser = new Parser(input);
|
2804
|
+
return parser.parse();
|
2805
|
+
};
|
2806
|
+
|
2807
|
+
extend(Parser.prototype, Grammar);
|
2808
|
+
|
2809
|
+
var SyntaxNode = function(textValue, offset, elements, properties) {
|
2810
|
+
this.textValue = textValue;
|
2811
|
+
this.offset = offset;
|
2812
|
+
this.elements = elements || [];
|
2813
|
+
if (!properties) return;
|
2814
|
+
for (var key in properties) this[key] = properties[key];
|
2815
|
+
};
|
2816
|
+
|
2817
|
+
SyntaxNode.prototype.forEach = function(block, context) {
|
2818
|
+
for (var i = 0, n = this.elements.length; i < n; i++) {
|
2819
|
+
block.call(context, this.elements[i], i);
|
2820
|
+
}
|
2821
|
+
};
|
2822
|
+
|
2823
|
+
Parser.SyntaxNode = SyntaxNode;
|
2824
|
+
|
2825
|
+
if (typeof require === "function" && typeof exports === "object") {
|
2826
|
+
exports.Grammar = Grammar;
|
2827
|
+
exports.Parser = Parser;
|
2828
|
+
exports.parse = Parser.parse;
|
2829
|
+
|
2830
|
+
if (typeof Pathology !== "undefined") {
|
2831
|
+
Pathology.XPath = Grammar;
|
2832
|
+
Pathology.XPathParser = Parser;
|
2833
|
+
Pathology.XPathParser.formatError = formatError;
|
2834
|
+
}
|
2835
|
+
} else {
|
2836
|
+
var namespace = this;
|
2837
|
+
namespace = namespace.Pathology = namespace.Pathology || {};
|
2838
|
+
Pathology.XPath = Grammar;
|
2839
|
+
Pathology.XPathParser = Parser;
|
2840
|
+
Pathology.XPathParser.formatError = formatError;
|
2841
|
+
}
|
2842
|
+
})();
|
2843
|
+
|
2844
|
+
|
2845
|
+
Pathology.XPathParser.And = {
|
2846
|
+
evaluate: function(context, root) {
|
2847
|
+
return Pathology.atomize(this.left, context, root) &&
|
2848
|
+
Pathology.atomize(this.right, context, root);
|
2849
|
+
}
|
2850
|
+
};
|
2851
|
+
|
2852
|
+
|
2853
|
+
Pathology.XPathParser.Atom = {
|
2854
|
+
evaluate: function(context, root) {
|
2855
|
+
var expression = this.expression.in_parens || this.expression;
|
2856
|
+
return expression.evaluate(context, root);
|
2857
|
+
}
|
2858
|
+
};
|
2859
|
+
|
2860
|
+
|
2861
|
+
Pathology.Axis = function(name) {
|
2862
|
+
this.name = name;
|
2863
|
+
};
|
2864
|
+
|
2865
|
+
Pathology.Axis.prototype.walk = function(context, block, scope) {
|
2866
|
+
var children = context.childNodes,
|
2867
|
+
attributes = Pathology.array(context.attributes),
|
2868
|
+
sibling;
|
2869
|
+
|
2870
|
+
if (context.checked)
|
2871
|
+
attributes.push({ nodeName: 'checked',
|
2872
|
+
nodeValue: true,
|
2873
|
+
nodeType: XPathResult.STRING_TYPE
|
2874
|
+
});
|
2875
|
+
|
2876
|
+
if (context.selected)
|
2877
|
+
attributes.push({ nodeName: 'selected',
|
2878
|
+
nodeValue: true,
|
2879
|
+
nodeType: XPathResult.STRING_TYPE
|
2880
|
+
});
|
2881
|
+
|
2882
|
+
switch (this.name) {
|
2883
|
+
case 'attribute':
|
2884
|
+
for (var i = 0, n = attributes.length; i < n; i++) {
|
2885
|
+
block.call(scope, attributes[i]);
|
2886
|
+
}
|
2887
|
+
break;
|
2888
|
+
|
2889
|
+
case 'child':
|
2890
|
+
for (var i = 0, n = children.length; i < n; i++) {
|
2891
|
+
block.call(scope, children[i]);
|
2892
|
+
}
|
2893
|
+
break;
|
2894
|
+
|
2895
|
+
case 'descendant-or-self':
|
2896
|
+
block.call(scope, context);
|
2897
|
+
for (var i = 0, n = children.length; i < n; i++) {
|
2898
|
+
this.walk(children[i], block, scope);
|
2899
|
+
}
|
2900
|
+
break;
|
2901
|
+
|
2902
|
+
case 'following-sibling':
|
2903
|
+
sibling = context.nextSibling;
|
2904
|
+
while (sibling) {
|
2905
|
+
block.call(scope, sibling);
|
2906
|
+
sibling = sibling.nextSibling;
|
2907
|
+
}
|
2908
|
+
break;
|
2909
|
+
|
2910
|
+
case 'parent':
|
2911
|
+
block.call(scope, context.parentNode);
|
2912
|
+
break;
|
2913
|
+
|
2914
|
+
case 'self':
|
2915
|
+
block.call(scope, context);
|
2916
|
+
break;
|
2917
|
+
}
|
2918
|
+
};
|
2919
|
+
|
2920
|
+
Pathology.Axis.SHORTHANDS = {
|
2921
|
+
'@' : 'attribute',
|
2922
|
+
'..': 'parent',
|
2923
|
+
'.' : 'self',
|
2924
|
+
'/' : 'descendant-or-self',
|
2925
|
+
'' : 'child'
|
2926
|
+
};
|
2927
|
+
|
2928
|
+
Pathology.Axis.fromAST = function(node) {
|
2929
|
+
var name = node.axis_name
|
2930
|
+
? node.axis_name.textValue
|
2931
|
+
: node.textValue;
|
2932
|
+
|
2933
|
+
return new this(this.SHORTHANDS[name] || name);
|
2934
|
+
};
|
2935
|
+
|
2936
|
+
|
2937
|
+
Pathology.XPathParser.Comparison = {
|
2938
|
+
evaluate: function(context, root) {
|
2939
|
+
// TODO make this symmetric
|
2940
|
+
var comparator = this.comparator.textValue,
|
2941
|
+
left = this.left.evaluate(context, root),
|
2942
|
+
right = Pathology.atomize(this.right, context, root),
|
2943
|
+
viable = false,
|
2944
|
+
array = (right instanceof Array),
|
2945
|
+
node;
|
2946
|
+
|
2947
|
+
if (left._nodes) {
|
2948
|
+
for (var i = 0, n = left._nodes.length; i < n; i++) {
|
2949
|
+
node = left._nodes[i];
|
2950
|
+
if (comparator === '=') {
|
2951
|
+
viable = viable || (array ? Pathology.indexOf(right, node.nodeValue) >= 0 : (node.nodeValue === right || node.innerHTML === right));
|
2952
|
+
} else if (comparator === '!=') {
|
2953
|
+
viable = viable || (array ? Pathology.indexOf(right, node.nodeValue) < 0 : (node.nodeValue !== right && node.innerHTML !== right));
|
2954
|
+
}
|
2955
|
+
}
|
2956
|
+
return viable;
|
2957
|
+
|
2958
|
+
} else {
|
2959
|
+
switch (comparator) {
|
2960
|
+
case '=': return array ? Pathology.indexOf(right, left.nodeValue) >= 0 : left == right;
|
2961
|
+
case '!=': return array ? Pathology.indexOf(right, node.nodeValue) < 0 : left != right;
|
2962
|
+
}
|
2963
|
+
}
|
2964
|
+
}
|
2965
|
+
};
|
2966
|
+
|
2967
|
+
|
2968
|
+
Pathology.XPathParser.FunctionCall = {
|
2969
|
+
getArguments: function(context, root) {
|
2970
|
+
var args = [],
|
2971
|
+
rest = this.function_args.rest;
|
2972
|
+
|
2973
|
+
if (this.function_args.first && this.function_args.first.evaluate) {
|
2974
|
+
args.push(this.function_args.first.evaluate(context, root));
|
2975
|
+
}
|
2976
|
+
if (rest) {
|
2977
|
+
for (var i = 0, n = rest.elements.length; i < n; i++)
|
2978
|
+
args.push(rest.elements[i].expression.evaluate(context, root));
|
2979
|
+
}
|
2980
|
+
return args;
|
2981
|
+
},
|
2982
|
+
|
2983
|
+
evaluate: function(context, root) {
|
2984
|
+
var args = this.getArguments(context, root),
|
2985
|
+
proc = this.REGISTER[this.function_name.textValue];
|
2986
|
+
|
2987
|
+
return proc.apply(context, args);
|
2988
|
+
},
|
2989
|
+
|
2990
|
+
REGISTER: {
|
2991
|
+
'concat': function() {
|
2992
|
+
var string = '';
|
2993
|
+
for (var i = 0, n = arguments.length; i < n; i++)
|
2994
|
+
string += arguments[i].makeString ? arguments[i].makeString() : arguments[i];
|
2995
|
+
return string;
|
2996
|
+
},
|
2997
|
+
|
2998
|
+
'contains': function(haystack, needle) {
|
2999
|
+
if (!haystack) return false;
|
3000
|
+
if (haystack.makeString) haystack = haystack.makeString();
|
3001
|
+
|
3002
|
+
return haystack.toString().indexOf(needle) >= 0;
|
3003
|
+
},
|
3004
|
+
|
3005
|
+
'normalize-space': function(string) {
|
3006
|
+
if (string.makeString) string = string.makeString();
|
3007
|
+
|
3008
|
+
return string.toString().replace(/^\s*/g, '')
|
3009
|
+
.replace(/\s*$/g, '')
|
3010
|
+
.replace(/\s+/g, ' ');
|
3011
|
+
},
|
3012
|
+
|
3013
|
+
'name': function() {
|
3014
|
+
return this.nodeName.toLowerCase();
|
3015
|
+
},
|
3016
|
+
|
3017
|
+
'not': function(value) {
|
3018
|
+
if (value && value.atomize) value = value.atomize();
|
3019
|
+
if (typeof value === 'string') return false;
|
3020
|
+
return !value;
|
3021
|
+
},
|
3022
|
+
|
3023
|
+
'string': function(value) {
|
3024
|
+
return value.atomize().innerText;
|
3025
|
+
},
|
3026
|
+
|
3027
|
+
'text': function() {
|
3028
|
+
return document.evaluate('/text()', this, null, XPathResult.ANY_TYPE, null);
|
3029
|
+
}
|
3030
|
+
}
|
3031
|
+
};
|
3032
|
+
|
3033
|
+
|
3034
|
+
Pathology.XPathParser.LocationPath = {
|
3035
|
+
eachStep: function(block, scope) {
|
3036
|
+
var list = [this.head].concat(this.rest.elements);
|
3037
|
+
for (var i = 0, n = list.length; i < n; i++)
|
3038
|
+
block.call(scope, list[i]);
|
3039
|
+
},
|
3040
|
+
|
3041
|
+
evaluate: function(context, root, resultType, result) {
|
3042
|
+
result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
|
3043
|
+
resultType = resultType || XPathResult.ANY_TYPE;
|
3044
|
+
|
3045
|
+
var intermediate = new Pathology.XPathResult(resultType),
|
3046
|
+
startNode = this.head.isRelative() ? context : root,
|
3047
|
+
steps = [this.head].concat(this.rest.elements),
|
3048
|
+
step,
|
3049
|
+
nextStage,
|
3050
|
+
i, j, n, m;
|
3051
|
+
|
3052
|
+
intermediate.push(startNode);
|
3053
|
+
|
3054
|
+
for (i = 0, n = steps.length; i < n; i++) {
|
3055
|
+
step = steps[i];
|
3056
|
+
nextStage = new Pathology.XPathResult(resultType);
|
3057
|
+
for (j = 0, m = intermediate._nodes.length; j < m; j++) {
|
3058
|
+
step.evaluate(intermediate._nodes[j], root, resultType, nextStage);
|
3059
|
+
}
|
3060
|
+
intermediate = nextStage;
|
3061
|
+
}
|
3062
|
+
|
3063
|
+
for (i = 0, n = intermediate._nodes.length; i < n; i++)
|
3064
|
+
result.push(intermediate._nodes[i]);
|
3065
|
+
|
3066
|
+
return result;
|
3067
|
+
}
|
3068
|
+
};
|
3069
|
+
|
3070
|
+
|
3071
|
+
Pathology.XPathParser.LocationStep = {
|
3072
|
+
isRelative: function() {
|
3073
|
+
return this.elements[0].textValue !== '/';
|
3074
|
+
},
|
3075
|
+
|
3076
|
+
evaluate: function(context, root, resultType, result) {
|
3077
|
+
var axis = this.selector.axis,
|
3078
|
+
test = this.selector.test,
|
3079
|
+
levels = [[]];
|
3080
|
+
|
3081
|
+
Pathology.Axis.fromAST(axis).walk(context, function(node) {
|
3082
|
+
if (!test || !test.evaluate) return result.push(node);
|
3083
|
+
test.evaluate(node, this.predicates, root, resultType, levels, result);
|
3084
|
+
}, this);
|
3085
|
+
}
|
3086
|
+
};
|
3087
|
+
|
3088
|
+
|
3089
|
+
Pathology.XPathParser.NodeTest = {
|
3090
|
+
evaluate: function(context, predicates, root, resultType, levels, result) {
|
3091
|
+
var name = this.elements[0].condition_name,
|
3092
|
+
tagName = tagName = this.elements[0].textValue.toLowerCase();
|
3093
|
+
|
3094
|
+
var first = {
|
3095
|
+
expression: {
|
3096
|
+
evaluate: function() {
|
3097
|
+
if (name && name.textValue === 'node') {
|
3098
|
+
return true;
|
3099
|
+
} else if (name && name.textValue === 'text') {
|
3100
|
+
if (context.nodeType !== XPathResult.BOOLEAN_TYPE) return false;
|
3101
|
+
} else {
|
3102
|
+
if (tagName === '*') {
|
3103
|
+
if (context.nodeType !== 1) return false;
|
3104
|
+
} else {
|
3105
|
+
if (!context.nodeName) return false;
|
3106
|
+
if (context.nodeName.toLowerCase() !== tagName) return false;
|
3107
|
+
}
|
3108
|
+
}
|
3109
|
+
return true;
|
3110
|
+
}
|
3111
|
+
},
|
3112
|
+
subscript: this.subscript
|
3113
|
+
};
|
3114
|
+
|
3115
|
+
predicates = [first].concat(predicates.elements);
|
3116
|
+
var accepted, predicate;
|
3117
|
+
|
3118
|
+
for (var i = 0, n = predicates.length; i < n; i++) {
|
3119
|
+
levels[i] = levels[i] || [];
|
3120
|
+
predicate = predicates[i];
|
3121
|
+
|
3122
|
+
accepted = Pathology.atomize(predicate.expression, context, root);
|
3123
|
+
if (typeof accepted === 'string') accepted = true;
|
3124
|
+
if (!accepted) return;
|
3125
|
+
|
3126
|
+
levels[i].push(context);
|
3127
|
+
|
3128
|
+
if (predicate.subscript.integer) {
|
3129
|
+
if (predicate.subscript.integer.evaluate() !== levels[i].length) return;
|
3130
|
+
}
|
3131
|
+
}
|
3132
|
+
|
3133
|
+
result.push(context);
|
3134
|
+
}
|
3135
|
+
};
|
3136
|
+
|
3137
|
+
|
3138
|
+
Pathology.XPathParser.Or = {
|
3139
|
+
evaluate: function(context, root) {
|
3140
|
+
return Pathology.atomize(this.left, context, root) ||
|
3141
|
+
Pathology.atomize(this.right, context, root);
|
3142
|
+
}
|
3143
|
+
};
|
3144
|
+
|
3145
|
+
|
3146
|
+
Pathology.XPathParser.Integer = {
|
3147
|
+
evaluate: function(context, root) {
|
3148
|
+
return parseInt(this.textValue, 10);
|
3149
|
+
}
|
3150
|
+
};
|
3151
|
+
|
3152
|
+
|
3153
|
+
Pathology.XPathParser.String = {
|
3154
|
+
evaluate: function(context, root) {
|
3155
|
+
return eval(this.textValue);
|
3156
|
+
}
|
3157
|
+
};
|
3158
|
+
|
3159
|
+
|
3160
|
+
Pathology.XPathParser.Union = {
|
3161
|
+
evaluate: function(context, root, resultType, result) {
|
3162
|
+
result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
|
3163
|
+
resultType = resultType || XPathResult.ANY_TYPE;
|
3164
|
+
|
3165
|
+
this.head.evaluate(context, root, resultType, result);
|
3166
|
+
|
3167
|
+
var sections = this.rest.elements;
|
3168
|
+
for (var i = 0, n = sections.length; i < n; i++)
|
3169
|
+
sections[i].location_path.evaluate(context, root, resultType, result);
|
3170
|
+
|
3171
|
+
return result;
|
3172
|
+
}
|
3173
|
+
};
|
3174
|
+
|