1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | var parser = (function(){
|
75 | var parser = {trace: function trace() { },
|
76 | yy: {},
|
77 | symbols_: {"error":2,"JSON_PATH":3,"DOLLAR":4,"PATH_COMPONENTS":5,"LEADING_CHILD_MEMBER_EXPRESSION":6,"PATH_COMPONENT":7,"MEMBER_COMPONENT":8,"SUBSCRIPT_COMPONENT":9,"CHILD_MEMBER_COMPONENT":10,"DESCENDANT_MEMBER_COMPONENT":11,"DOT":12,"MEMBER_EXPRESSION":13,"DOT_DOT":14,"STAR":15,"IDENTIFIER":16,"SCRIPT_EXPRESSION":17,"INTEGER":18,"END":19,"CHILD_SUBSCRIPT_COMPONENT":20,"DESCENDANT_SUBSCRIPT_COMPONENT":21,"[":22,"SUBSCRIPT":23,"]":24,"SUBSCRIPT_EXPRESSION":25,"SUBSCRIPT_EXPRESSION_LIST":26,"SUBSCRIPT_EXPRESSION_LISTABLE":27,",":28,"STRING_LITERAL":29,"ARRAY_SLICE":30,"FILTER_EXPRESSION":31,"QQ_STRING":32,"Q_STRING":33,"$accept":0,"$end":1},
|
78 | terminals_: {2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},
|
79 | productions_: [0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],
|
80 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */
|
81 | /**/) {
|
82 |
|
83 | if (!yy.ast) {
|
84 | yy.ast = _ast;
|
85 | _ast.initialize();
|
86 | }
|
87 |
|
88 | var $0 = $$.length - 1;
|
89 | switch (yystate) {
|
90 | case 1:yy.ast.set({ expression: { type: "root", value: $$[$0] } }); yy.ast.unshift(); return yy.ast.yield()
|
91 | break;
|
92 | case 2:yy.ast.set({ expression: { type: "root", value: $$[$0-1] } }); yy.ast.unshift(); return yy.ast.yield()
|
93 | break;
|
94 | case 3:yy.ast.unshift(); return yy.ast.yield()
|
95 | break;
|
96 | case 4:yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $$[$0-1] }}); yy.ast.unshift(); return yy.ast.yield()
|
97 | break;
|
98 | case 5:
|
99 | break;
|
100 | case 6:
|
101 | break;
|
102 | case 7:yy.ast.set({ operation: "member" }); yy.ast.push()
|
103 | break;
|
104 | case 8:yy.ast.set({ operation: "subscript" }); yy.ast.push()
|
105 | break;
|
106 | case 9:yy.ast.set({ scope: "child" })
|
107 | break;
|
108 | case 10:yy.ast.set({ scope: "descendant" })
|
109 | break;
|
110 | case 11:
|
111 | break;
|
112 | case 12:yy.ast.set({ scope: "child", operation: "member" })
|
113 | break;
|
114 | case 13:
|
115 | break;
|
116 | case 14:yy.ast.set({ expression: { type: "wildcard", value: $$[$0] } })
|
117 | break;
|
118 | case 15:yy.ast.set({ expression: { type: "identifier", value: $$[$0] } })
|
119 | break;
|
120 | case 16:yy.ast.set({ expression: { type: "script_expression", value: $$[$0] } })
|
121 | break;
|
122 | case 17:yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($$[$0]) } })
|
123 | break;
|
124 | case 18:
|
125 | break;
|
126 | case 19:yy.ast.set({ scope: "child" })
|
127 | break;
|
128 | case 20:yy.ast.set({ scope: "descendant" })
|
129 | break;
|
130 | case 21:
|
131 | break;
|
132 | case 22:
|
133 | break;
|
134 | case 23:
|
135 | break;
|
136 | case 24:$$[$0].length > 1? yy.ast.set({ expression: { type: "union", value: $$[$0] } }) : this.$ = $$[$0]
|
137 | break;
|
138 | case 25:this.$ = [$$[$0]]
|
139 | break;
|
140 | case 26:this.$ = $$[$0-2].concat($$[$0])
|
141 | break;
|
142 | case 27:this.$ = { expression: { type: "numeric_literal", value: parseInt($$[$0]) } }; yy.ast.set(this.$)
|
143 | break;
|
144 | case 28:this.$ = { expression: { type: "string_literal", value: $$[$0] } }; yy.ast.set(this.$)
|
145 | break;
|
146 | case 29:this.$ = { expression: { type: "slice", value: $$[$0] } }; yy.ast.set(this.$)
|
147 | break;
|
148 | case 30:this.$ = { expression: { type: "wildcard", value: $$[$0] } }; yy.ast.set(this.$)
|
149 | break;
|
150 | case 31:this.$ = { expression: { type: "script_expression", value: $$[$0] } }; yy.ast.set(this.$)
|
151 | break;
|
152 | case 32:this.$ = { expression: { type: "filter_expression", value: $$[$0] } }; yy.ast.set(this.$)
|
153 | break;
|
154 | case 33:this.$ = $$[$0]
|
155 | break;
|
156 | case 34:this.$ = $$[$0]
|
157 | break;
|
158 | }
|
159 | },
|
160 | table: [{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],
|
161 | defaultActions: {27:[2,23],29:[2,30],30:[2,31],31:[2,32]},
|
162 | parseError: function parseError(str, hash) {
|
163 | if (hash.recoverable) {
|
164 | this.trace(str);
|
165 | } else {
|
166 | throw new Error(str);
|
167 | }
|
168 | },
|
169 | parse: function parse(input) {
|
170 | var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
171 | var args = lstack.slice.call(arguments, 1);
|
172 | this.lexer.setInput(input);
|
173 | this.lexer.yy = this.yy;
|
174 | this.yy.lexer = this.lexer;
|
175 | this.yy.parser = this;
|
176 | if (typeof this.lexer.yylloc == 'undefined') {
|
177 | this.lexer.yylloc = {};
|
178 | }
|
179 | var yyloc = this.lexer.yylloc;
|
180 | lstack.push(yyloc);
|
181 | var ranges = this.lexer.options && this.lexer.options.ranges;
|
182 | if (typeof this.yy.parseError === 'function') {
|
183 | this.parseError = this.yy.parseError;
|
184 | } else {
|
185 | this.parseError = Object.getPrototypeOf(this).parseError;
|
186 | }
|
187 | function popStack(n) {
|
188 | stack.length = stack.length - 2 * n;
|
189 | vstack.length = vstack.length - n;
|
190 | lstack.length = lstack.length - n;
|
191 | }
|
192 | function lex() {
|
193 | var token;
|
194 | token = self.lexer.lex() || EOF;
|
195 | if (typeof token !== 'number') {
|
196 | token = self.symbols_[token] || token;
|
197 | }
|
198 | return token;
|
199 | }
|
200 | var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
201 | while (true) {
|
202 | state = stack[stack.length - 1];
|
203 | if (this.defaultActions[state]) {
|
204 | action = this.defaultActions[state];
|
205 | } else {
|
206 | if (symbol === null || typeof symbol == 'undefined') {
|
207 | symbol = lex();
|
208 | }
|
209 | action = table[state] && table[state][symbol];
|
210 | }
|
211 | if (typeof action === 'undefined' || !action.length || !action[0]) {
|
212 | var errStr = '';
|
213 | expected = [];
|
214 | for (p in table[state]) {
|
215 | if (this.terminals_[p] && p > TERROR) {
|
216 | expected.push('\'' + this.terminals_[p] + '\'');
|
217 | }
|
218 | }
|
219 | if (this.lexer.showPosition) {
|
220 | errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + this.lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
221 | } else {
|
222 | errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
223 | }
|
224 | this.parseError(errStr, {
|
225 | text: this.lexer.match,
|
226 | token: this.terminals_[symbol] || symbol,
|
227 | line: this.lexer.yylineno,
|
228 | loc: yyloc,
|
229 | expected: expected
|
230 | });
|
231 | }
|
232 | if (action[0] instanceof Array && action.length > 1) {
|
233 | throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
234 | }
|
235 | switch (action[0]) {
|
236 | case 1:
|
237 | stack.push(symbol);
|
238 | vstack.push(this.lexer.yytext);
|
239 | lstack.push(this.lexer.yylloc);
|
240 | stack.push(action[1]);
|
241 | symbol = null;
|
242 | if (!preErrorSymbol) {
|
243 | yyleng = this.lexer.yyleng;
|
244 | yytext = this.lexer.yytext;
|
245 | yylineno = this.lexer.yylineno;
|
246 | yyloc = this.lexer.yylloc;
|
247 | if (recovering > 0) {
|
248 | recovering--;
|
249 | }
|
250 | } else {
|
251 | symbol = preErrorSymbol;
|
252 | preErrorSymbol = null;
|
253 | }
|
254 | break;
|
255 | case 2:
|
256 | len = this.productions_[action[1]][1];
|
257 | yyval.$ = vstack[vstack.length - len];
|
258 | yyval._$ = {
|
259 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
260 | last_line: lstack[lstack.length - 1].last_line,
|
261 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
262 | last_column: lstack[lstack.length - 1].last_column
|
263 | };
|
264 | if (ranges) {
|
265 | yyval._$.range = [
|
266 | lstack[lstack.length - (len || 1)].range[0],
|
267 | lstack[lstack.length - 1].range[1]
|
268 | ];
|
269 | }
|
270 | r = this.performAction.apply(yyval, [
|
271 | yytext,
|
272 | yyleng,
|
273 | yylineno,
|
274 | this.yy,
|
275 | action[1],
|
276 | vstack,
|
277 | lstack
|
278 | ].concat(args));
|
279 | if (typeof r !== 'undefined') {
|
280 | return r;
|
281 | }
|
282 | if (len) {
|
283 | stack = stack.slice(0, -1 * len * 2);
|
284 | vstack = vstack.slice(0, -1 * len);
|
285 | lstack = lstack.slice(0, -1 * len);
|
286 | }
|
287 | stack.push(this.productions_[action[1]][0]);
|
288 | vstack.push(yyval.$);
|
289 | lstack.push(yyval._$);
|
290 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
291 | stack.push(newState);
|
292 | break;
|
293 | case 3:
|
294 | return true;
|
295 | }
|
296 | }
|
297 | return true;
|
298 | }};
|
299 | var _ast = {
|
300 |
|
301 | initialize: function() {
|
302 | this._nodes = [];
|
303 | this._node = {};
|
304 | this._stash = [];
|
305 | },
|
306 |
|
307 | set: function(props) {
|
308 | for (var k in props) this._node[k] = props[k];
|
309 | return this._node;
|
310 | },
|
311 |
|
312 | node: function(obj) {
|
313 | if (arguments.length) this._node = obj;
|
314 | return this._node;
|
315 | },
|
316 |
|
317 | push: function() {
|
318 | this._nodes.push(this._node);
|
319 | this._node = {};
|
320 | },
|
321 |
|
322 | unshift: function() {
|
323 | this._nodes.unshift(this._node);
|
324 | this._node = {};
|
325 | },
|
326 |
|
327 | yield: function() {
|
328 | var _nodes = this._nodes;
|
329 | this.initialize();
|
330 | return _nodes;
|
331 | }
|
332 | };
|
333 |
|
334 | var lexer = (function(){
|
335 | var lexer = {
|
336 |
|
337 | EOF:1,
|
338 |
|
339 | parseError:function parseError(str, hash) {
|
340 | if (this.yy.parser) {
|
341 | this.yy.parser.parseError(str, hash);
|
342 | } else {
|
343 | throw new Error(str);
|
344 | }
|
345 | },
|
346 |
|
347 |
|
348 | setInput:function (input) {
|
349 | this._input = input;
|
350 | this._more = this._backtrack = this.done = false;
|
351 | this.yylineno = this.yyleng = 0;
|
352 | this.yytext = this.matched = this.match = '';
|
353 | this.conditionStack = ['INITIAL'];
|
354 | this.yylloc = {
|
355 | first_line: 1,
|
356 | first_column: 0,
|
357 | last_line: 1,
|
358 | last_column: 0
|
359 | };
|
360 | if (this.options.ranges) {
|
361 | this.yylloc.range = [0,0];
|
362 | }
|
363 | this.offset = 0;
|
364 | return this;
|
365 | },
|
366 |
|
367 |
|
368 | input:function () {
|
369 | var ch = this._input[0];
|
370 | this.yytext += ch;
|
371 | this.yyleng++;
|
372 | this.offset++;
|
373 | this.match += ch;
|
374 | this.matched += ch;
|
375 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
376 | if (lines) {
|
377 | this.yylineno++;
|
378 | this.yylloc.last_line++;
|
379 | } else {
|
380 | this.yylloc.last_column++;
|
381 | }
|
382 | if (this.options.ranges) {
|
383 | this.yylloc.range[1]++;
|
384 | }
|
385 |
|
386 | this._input = this._input.slice(1);
|
387 | return ch;
|
388 | },
|
389 |
|
390 |
|
391 | unput:function (ch) {
|
392 | var len = ch.length;
|
393 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
394 |
|
395 | this._input = ch + this._input;
|
396 | this.yytext = this.yytext.substr(0, this.yytext.length - len - 1);
|
397 |
|
398 | this.offset -= len;
|
399 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
400 | this.match = this.match.substr(0, this.match.length - 1);
|
401 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
402 |
|
403 | if (lines.length - 1) {
|
404 | this.yylineno -= lines.length - 1;
|
405 | }
|
406 | var r = this.yylloc.range;
|
407 |
|
408 | this.yylloc = {
|
409 | first_line: this.yylloc.first_line,
|
410 | last_line: this.yylineno + 1,
|
411 | first_column: this.yylloc.first_column,
|
412 | last_column: lines ?
|
413 | (lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
414 | + oldLines[oldLines.length - lines.length].length - lines[0].length :
|
415 | this.yylloc.first_column - len
|
416 | };
|
417 |
|
418 | if (this.options.ranges) {
|
419 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
420 | }
|
421 | this.yyleng = this.yytext.length;
|
422 | return this;
|
423 | },
|
424 |
|
425 |
|
426 | more:function () {
|
427 | this._more = true;
|
428 | return this;
|
429 | },
|
430 |
|
431 |
|
432 | reject:function () {
|
433 | if (this.options.backtrack_lexer) {
|
434 | this._backtrack = true;
|
435 | } else {
|
436 | return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
437 | text: "",
|
438 | token: null,
|
439 | line: this.yylineno
|
440 | });
|
441 |
|
442 | }
|
443 | return this;
|
444 | },
|
445 |
|
446 |
|
447 | less:function (n) {
|
448 | this.unput(this.match.slice(n));
|
449 | },
|
450 |
|
451 |
|
452 | pastInput:function () {
|
453 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
454 | return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
455 | },
|
456 |
|
457 |
|
458 | upcomingInput:function () {
|
459 | var next = this.match;
|
460 | if (next.length < 20) {
|
461 | next += this._input.substr(0, 20-next.length);
|
462 | }
|
463 | return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
464 | },
|
465 |
|
466 |
|
467 | showPosition:function () {
|
468 | var pre = this.pastInput();
|
469 | var c = new Array(pre.length + 1).join("-");
|
470 | return pre + this.upcomingInput() + "\n" + c + "^";
|
471 | },
|
472 |
|
473 |
|
474 | test_match:function (match, indexed_rule) {
|
475 | var token,
|
476 | lines,
|
477 | backup;
|
478 |
|
479 | if (this.options.backtrack_lexer) {
|
480 |
|
481 | backup = {
|
482 | yylineno: this.yylineno,
|
483 | yylloc: {
|
484 | first_line: this.yylloc.first_line,
|
485 | last_line: this.last_line,
|
486 | first_column: this.yylloc.first_column,
|
487 | last_column: this.yylloc.last_column
|
488 | },
|
489 | yytext: this.yytext,
|
490 | match: this.match,
|
491 | matches: this.matches,
|
492 | matched: this.matched,
|
493 | yyleng: this.yyleng,
|
494 | offset: this.offset,
|
495 | _more: this._more,
|
496 | _input: this._input,
|
497 | yy: this.yy,
|
498 | conditionStack: this.conditionStack.slice(0),
|
499 | done: this.done
|
500 | };
|
501 | if (this.options.ranges) {
|
502 | backup.yylloc.range = this.yylloc.range.slice(0);
|
503 | }
|
504 | }
|
505 |
|
506 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
507 | if (lines) {
|
508 | this.yylineno += lines.length;
|
509 | }
|
510 | this.yylloc = {
|
511 | first_line: this.yylloc.last_line,
|
512 | last_line: this.yylineno + 1,
|
513 | first_column: this.yylloc.last_column,
|
514 | last_column: lines ?
|
515 | lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
516 | this.yylloc.last_column + match[0].length
|
517 | };
|
518 | this.yytext += match[0];
|
519 | this.match += match[0];
|
520 | this.matches = match;
|
521 | this.yyleng = this.yytext.length;
|
522 | if (this.options.ranges) {
|
523 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
524 | }
|
525 | this._more = false;
|
526 | this._backtrack = false;
|
527 | this._input = this._input.slice(match[0].length);
|
528 | this.matched += match[0];
|
529 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
530 | if (this.done && this._input) {
|
531 | this.done = false;
|
532 | }
|
533 | if (token) {
|
534 | return token;
|
535 | } else if (this._backtrack) {
|
536 |
|
537 | for (var k in backup) {
|
538 | this[k] = backup[k];
|
539 | }
|
540 | return false;
|
541 | }
|
542 | return false;
|
543 | },
|
544 |
|
545 |
|
546 | next:function () {
|
547 | if (this.done) {
|
548 | return this.EOF;
|
549 | }
|
550 | if (!this._input) {
|
551 | this.done = true;
|
552 | }
|
553 |
|
554 | var token,
|
555 | match,
|
556 | tempMatch,
|
557 | index;
|
558 | if (!this._more) {
|
559 | this.yytext = '';
|
560 | this.match = '';
|
561 | }
|
562 | var rules = this._currentRules();
|
563 | for (var i = 0; i < rules.length; i++) {
|
564 | tempMatch = this._input.match(this.rules[rules[i]]);
|
565 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
566 | match = tempMatch;
|
567 | index = i;
|
568 | if (this.options.backtrack_lexer) {
|
569 | token = this.test_match(tempMatch, rules[i]);
|
570 | if (token !== false) {
|
571 | return token;
|
572 | } else if (this._backtrack) {
|
573 | match = false;
|
574 | continue;
|
575 | } else {
|
576 |
|
577 | return false;
|
578 | }
|
579 | } else if (!this.options.flex) {
|
580 | break;
|
581 | }
|
582 | }
|
583 | }
|
584 | if (match) {
|
585 | token = this.test_match(match, rules[index]);
|
586 | if (token !== false) {
|
587 | return token;
|
588 | }
|
589 |
|
590 | return false;
|
591 | }
|
592 | if (this._input === "") {
|
593 | return this.EOF;
|
594 | } else {
|
595 | return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
596 | text: "",
|
597 | token: null,
|
598 | line: this.yylineno
|
599 | });
|
600 | }
|
601 | },
|
602 |
|
603 |
|
604 | lex:function lex() {
|
605 | var r = this.next();
|
606 | if (r) {
|
607 | return r;
|
608 | } else {
|
609 | return this.lex();
|
610 | }
|
611 | },
|
612 |
|
613 |
|
614 | begin:function begin(condition) {
|
615 | this.conditionStack.push(condition);
|
616 | },
|
617 |
|
618 |
|
619 | popState:function popState() {
|
620 | var n = this.conditionStack.length - 1;
|
621 | if (n > 0) {
|
622 | return this.conditionStack.pop();
|
623 | } else {
|
624 | return this.conditionStack[0];
|
625 | }
|
626 | },
|
627 |
|
628 |
|
629 | _currentRules:function _currentRules() {
|
630 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
631 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
632 | } else {
|
633 | return this.conditions["INITIAL"].rules;
|
634 | }
|
635 | },
|
636 |
|
637 |
|
638 | topState:function topState(n) {
|
639 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
640 | if (n >= 0) {
|
641 | return this.conditionStack[n];
|
642 | } else {
|
643 | return "INITIAL";
|
644 | }
|
645 | },
|
646 |
|
647 |
|
648 | pushState:function pushState(condition) {
|
649 | this.begin(condition);
|
650 | },
|
651 |
|
652 |
|
653 | stateStackSize:function stateStackSize() {
|
654 | return this.conditionStack.length;
|
655 | },
|
656 | options: {},
|
657 | performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START
|
658 | /**/) {
|
659 |
|
660 | var YYSTATE=YY_START;
|
661 | switch($avoiding_name_collisions) {
|
662 | case 0:return 4
|
663 | break;
|
664 | case 1:return 14
|
665 | break;
|
666 | case 2:return 12
|
667 | break;
|
668 | case 3:return 15
|
669 | break;
|
670 | case 4:return 16
|
671 | break;
|
672 | case 5:return 22
|
673 | break;
|
674 | case 6:return 24
|
675 | break;
|
676 | case 7:return 28
|
677 | break;
|
678 | case 8:return 30
|
679 | break;
|
680 | case 9:return 18
|
681 | break;
|
682 | case 10:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 32;
|
683 | break;
|
684 | case 11:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 33;
|
685 | break;
|
686 | case 12:return 17
|
687 | break;
|
688 | case 13:return 31
|
689 | break;
|
690 | }
|
691 | },
|
692 | rules: [/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],
|
693 | conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}}
|
694 | };
|
695 | return lexer;
|
696 | })();
|
697 | parser.lexer = lexer;
|
698 | function Parser () {
|
699 | this.yy = {};
|
700 | }
|
701 | Parser.prototype = parser;parser.Parser = Parser;
|
702 | return new Parser;
|
703 | })();
|
704 |
|
705 |
|
706 | if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
707 | exports.parser = parser;
|
708 | exports.Parser = parser.Parser;
|
709 | exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
710 | exports.main = function commonjsMain(args) {
|
711 | if (!args[1]) {
|
712 | console.log('Usage: '+args[0]+' FILE');
|
713 | process.exit(1);
|
714 | }
|
715 | var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
716 | return exports.parser.parse(source);
|
717 | };
|
718 | if (typeof module !== 'undefined' && require.main === module) {
|
719 | exports.main(process.argv.slice(1));
|
720 | }
|
721 | }
|