spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[Parser,Rules] continuing process of renaming parser variables. no functional changes.
author
Ben Vogt <[email protected]>
date
2017-08-19 00:32:12
stats
2 file(s) changed, 225 insertions(+), 101 deletions(-)
files
src/Parser/Parser.ts
src/Parser/Rules.ts
  1diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
  2index cbb35f1..bee00c7 100644
  3--- a/src/Parser/Parser.ts
  4+++ b/src/Parser/Parser.ts
  5@@ -37,7 +37,44 @@ import {
  6   EQUALS_SIGN_RULE_INDEX,
  7   PERCENT_SIGN_RULE_INDEX,
  8   HASH_SIGN_RULE_INDEX,
  9-  END_OF_STRING_RULE_INDEX
 10+  END_OF_STRING_RULE_INDEX,
 11+  INDEX0,
 12+  INDEX1,
 13+  INDEX2,
 14+  INDEX3,
 15+  INDEX4,
 16+  INDEX5,
 17+  INDEX6,
 18+  INDEX7,
 19+  INDEX8,
 20+  INDEX9,
 21+  INDEX10,
 22+  INDEX11,
 23+  INDEX12,
 24+  INDEX13,
 25+  INDEX14,
 26+  INDEX15,
 27+  INDEX16,
 28+  INDEX17,
 29+  INDEX18,
 30+  INDEX19,
 31+  INDEX20,
 32+  INDEX21,
 33+  INDEX22,
 34+  INDEX23,
 35+  INDEX24,
 36+  INDEX25,
 37+  INDEX26,
 38+  INDEX27,
 39+  INDEX28,
 40+  INDEX29,
 41+  INDEX30,
 42+  INDEX31,
 43+  INDEX32,
 44+  INDEX33,
 45+  INDEX34,
 46+  INDEX35,
 47+  INDEX36
 48 } from "./Rules";
 49 import {
 50   ObjectFromPairs
 51@@ -117,44 +154,44 @@ import {
 52  recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
 53  }
 54  */
 55-var Parser = (function () {
 56-  var o = function (k, v, o?, l?) {
 57-    for (o = o || {}, l = k.length; l--; o[k[l]] = v) {
 58+let Parser = (function () {
 59+  const extendRules = function (k, v, obj?, l?) {
 60+    for (obj = obj || {}, l = k.length; l--; obj[k[l]] = v) {
 61     }
 62-    return o
 63+    return obj;
 64   };
 65-  const $V0 = [1, 4];
 66-  const $V1 = [1, 5];
 67-  const $V2 = [1, 7];
 68-  const $V3 = [1, 10];
 69-  const $V4 = [1, 8];
 70-  const $V5 = [1, 9];
 71-  const $V6 = [1, 11];
 72-  const $V7 = [1, 16];
 73-  const $V8 = [1, 17];
 74-  const $V9 = [1, 14];
 75-  const $Va = [1, 15];
 76-  const $Vb = [1, 18];
 77-  const $Vc = [1, 20];
 78-  const $Vd = [1, 21];
 79-  const $Ve = [1, 22];
 80-  const $Vf = [1, 23];
 81-  const $Vg = [1, 24];
 82-  const $Vh = [1, 25];
 83-  const $Vi = [1, 26];
 84-  const $Vj = [1, 27];
 85-  const $Vk = [1, 28];
 86-  const $Vl = [1, 29];
 87-  const $Vm = [5, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31];
 88-  const $Vn = [5, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31, 33];
 89-  const $Vo = [1, 38];
 90-  const $Vp = [5, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31, 35, 38];
 91-  const $Vq = [5, 12, 13, 15, 16, 17, 18, 19, 30, 31];
 92-  const $Vr = [5, 12, 15, 16, 17, 18, 30, 31];
 93-  const $Vs = [5, 12, 13, 15, 16, 17, 18, 19, 20, 21, 30, 31];
 94-  const $Vt = [15, 30, 31];
 95-  const $Vu = [5, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31, 32, 36];
 96-  var parser = {
 97+  const $V0 = [INDEX1, INDEX4];
 98+  const $V1 = [INDEX1, INDEX5];
 99+  const $V2 = [INDEX1, INDEX7];
100+  const $V3 = [INDEX1, INDEX10];
101+  const $V4 = [INDEX1, INDEX8];
102+  const $V5 = [INDEX1, INDEX9];
103+  const $V6 = [INDEX1, INDEX11];
104+  const $V7 = [INDEX1, INDEX16];
105+  const $V8 = [INDEX1, INDEX17];
106+  const $V9 = [INDEX1, INDEX14];
107+  const $Va = [INDEX1, INDEX15];
108+  const $Vb = [INDEX1, INDEX18];
109+  const $Vc = [INDEX1, INDEX20];
110+  const $Vd = [INDEX1, INDEX21];
111+  const $Ve = [INDEX1, INDEX22];
112+  const $Vf = [INDEX1, INDEX23];
113+  const $Vg = [INDEX1, INDEX24];
114+  const $Vh = [INDEX1, INDEX25];
115+  const $Vi = [INDEX1, INDEX26];
116+  const $Vj = [INDEX1, INDEX27];
117+  const $Vk = [INDEX1, INDEX28];
118+  const $Vl = [INDEX1, INDEX29];
119+  const $Vm = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31];
120+  const $Vn = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX33];
121+  const $Vo = [INDEX1, 38];
122+  const $Vp = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX35, 38];
123+  const $Vq = [INDEX5, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX30, INDEX31];
124+  const $Vr = [INDEX5, INDEX12, INDEX15, INDEX16, INDEX17, INDEX18, INDEX30, INDEX31];
125+  const $Vs = [INDEX5, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX30, INDEX31];
126+  const $Vt = [INDEX15, INDEX30, INDEX31];
127+  const $Vu = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX32, INDEX36];
128+  let parser = {
129     lexer: undefined,
130     Parser: undefined,
131     trace: function trace() {
132@@ -279,7 +316,7 @@ var Parser = (function () {
133     performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
134       /* this == yyval */
135 
136-      var $0 = $$.length - 1;
137+      let $0 = $$.length - 1;
138       switch (yystate) {
139         case 1:
140           return $$[$0 - 1];
141@@ -348,8 +385,7 @@ var Parser = (function () {
142           }
143           break;
144         case 22:
145-          var n1 = yy.handler.helper.number($$[$0]);
146-          this.$ = n1;
147+          this.$ = yy.handler.helper.number($$[$0]);
148           if (isNaN(this.$)) {
149             this.$ = 0;
150           }
151@@ -382,7 +418,7 @@ var Parser = (function () {
152           }
153           break;
154         case 33:
155-          var result = [],
156+          let result = [],
157             arr = eval("[" + yytext + "]");
158           arr.forEach(function (item) {
159             result.push(item);
160@@ -421,23 +457,25 @@ var Parser = (function () {
161         SINGLE_QUOTES_RULE_INDEX, 13,
162         FORMULA_NAME_RULE_INDEX, 1,
163         DATE_RULE_INDEX, 2,
164-        6, 3,
165-        7, $V0,
166-        8, $V1,
167-        9, 6,
168-        10, $V2,
169-        13, $V3,
170-        14, $V4,
171-        19, $V5,
172-        23, $V6,
173-        25, 12,
174-        26, $V7,
175-        28, $V8,
176-        32, $V9,
177-        34, $Va,
178-        36, $Vb
179+        INDEX6, 3,
180+        INDEX7, $V0,
181+        INDEX8, $V1,
182+        INDEX9, 6,
183+        INDEX10, $V2,
184+        INDEX13, $V3,
185+        INDEX14, $V4,
186+        INDEX19, $V5,
187+        INDEX23, $V6,
188+        INDEX25, 12,
189+        INDEX26, $V7,
190+        INDEX28, $V8,
191+        INDEX32, $V9,
192+        INDEX34, $Va,
193+        INDEX36, $Vb
194+      ]),
195+      ObjectFromPairs.of([
196+        INDEX1, [3]
197       ]),
198-      {1: [3]},
199       ObjectFromPairs.of([
200         TIME_RULE_INDEX, [1, 19],
201         INTEGER_RULE_INDEX, $Vc,
202@@ -451,11 +489,11 @@ var Parser = (function () {
203         FORWARD_SLASH_RULE_INDEX, $Vk,
204         MINUS_SIGN_RULE_INDEX, $Vl
205       ]),
206-      o($Vm, [2, 2], {33: [1, 30]}),
207-      o($Vm, [2, 3]),
208-      o($Vm, [2, 4]),
209-      o($Vm, [2, 5], {35: [1, 31]}),
210-      o($Vm, [2, 6]),
211+      extendRules($Vm, [2, 2], ObjectFromPairs.of([INDEX33, [1, 30]])),
212+      extendRules($Vm, [2, 3]),
213+      extendRules($Vm, [2, 4]),
214+      extendRules($Vm, [2, 5], ObjectFromPairs.of([INDEX35, [1, 31]])),
215+      extendRules($Vm, [2, 6]),
216       ObjectFromPairs.of([
217         SINGLE_QUOTES_RULE_INDEX, 13,
218         DATE_RULE_INDEX, 32,
219@@ -516,12 +554,14 @@ var Parser = (function () {
220       ObjectFromPairs.of([
221         AMPERSAND_SIGN_RULE_INDEX, [1, 35]
222       ]),
223-      o($Vm, [2, 25]),
224-      o($Vm, [2, 26], ObjectFromPairs.of([2, 36, 32, [1, 37], 36, $Vb])),
225-      o($Vn, [2, 36], {36: $Vo}),
226-      o($Vp, [2, 38], {33: [1, 39]}),
227-      o($Vm, [2, 28], {27: [1, 40]}),
228-      o($Vm, [2, 30], {27: [1, 41]}), {32: [1, 42]}, {1: [2, 1]},
229+      extendRules($Vm, [2, 25]),
230+      extendRules($Vm, [2, 26], ObjectFromPairs.of([2, 36, 32, [1, 37], 36, $Vb])),
231+      extendRules($Vn, [2, 36], ObjectFromPairs.of([INDEX36, $Vo])),
232+      extendRules($Vp, [2, 38], ObjectFromPairs.of([INDEX33, [1, 39]])),
233+      extendRules($Vm, [2, 28], ObjectFromPairs.of([INDEX27, [1, 40]])),
234+      extendRules($Vm, [2, 30], ObjectFromPairs.of([INDEX27, [1, 41]])),
235+      ObjectFromPairs.of([INDEX32, [1, 42]]),
236+      ObjectFromPairs.of([INDEX1, [2, 1]]),
237       ObjectFromPairs.of([
238         SINGLE_QUOTES_RULE_INDEX, 13,
239         DATE_RULE_INDEX, 43,
240@@ -715,8 +755,8 @@ var Parser = (function () {
241         PERCENT_SIGN_RULE_INDEX, $Va,
242         END_OF_STRING_RULE_INDEX, $Vb
243       ]),
244-      ObjectFromPairs.of([32, [1, 56]]),
245-      o($Vp, [2, 40]),
246+      ObjectFromPairs.of([ [1, 56]]),
247+      extendRules($Vp, [2, 40]),
248       ObjectFromPairs.of([
249         INTEGER_RULE_INDEX, $Vc,
250         OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX, $Vd,
251@@ -730,17 +770,17 @@ var Parser = (function () {
252         FORWARD_SLASH_RULE_INDEX, $Vk,
253         MINUS_SIGN_RULE_INDEX, $Vl
254       ]),
255-      o($Vq, [2, 21], ObjectFromPairs.of([
256-        11, $Vc,
257-        20, $Vj,
258-        21, $Vk,
259-        22, $Vl
260+      extendRules($Vq, [2, 21], ObjectFromPairs.of([
261+        INDEX11, $Vc,
262+        INDEX20, $Vj,
263+        INDEX21, $Vk,
264+        INDEX22, $Vl
265       ])),
266-      o($Vq, [2, 22], ObjectFromPairs.of([
267-        11, $Vc,
268-        20, $Vj,
269-        21, $Vk,
270-        22, $Vl])
271+      extendRules($Vq, [2, 22], ObjectFromPairs.of([
272+        INDEX11, $Vc,
273+        INDEX20, $Vj,
274+        INDEX21, $Vk,
275+        INDEX22, $Vl])
276       ),
277       ObjectFromPairs.of([
278         SINGLE_QUOTES_RULE_INDEX, 13,
279@@ -764,15 +804,15 @@ var Parser = (function () {
280         PERCENT_SIGN_RULE_INDEX, $Va,
281         END_OF_STRING_RULE_INDEX, $Vb
282       ]),
283-      o($Vm, [2, 27]),
284-      ObjectFromPairs.of([36, $Vo]),
285-      ObjectFromPairs.of([32, [1, 62]]),
286-      ObjectFromPairs.of([34, [1, 63]]),
287-      ObjectFromPairs.of([26, [1, 64]]),
288-      ObjectFromPairs.of([28, [1, 65]]),
289+      extendRules($Vm, [2, 27]),
290+      ObjectFromPairs.of([INDEX36, $Vo]),
291+      ObjectFromPairs.of([INDEX32, [1, 62]]),
292+      ObjectFromPairs.of([INDEX34, [1, 63]]),
293+      ObjectFromPairs.of([INDEX26, [1, 64]]),
294+      ObjectFromPairs.of([INDEX28, [1, 65]]),
295       ObjectFromPairs.of([37, [1, 66]]),
296-      o($Vm, [2, 7]),
297-      o([5, 12, 15, 30, 31], [2, 8], ObjectFromPairs.of([
298+      extendRules($Vm, [2, 7]),
299+      extendRules([5, 12, 15, 30, 31], [2, 8], ObjectFromPairs.of([
300         INTEGER_RULE_INDEX, $Vc,
301         DOLLAR_SIGN_RULE_INDEX, $Ve,
302         PERIOD_RULE_INDEX, $Vf,
303@@ -783,7 +823,12 @@ var Parser = (function () {
304         FORWARD_SLASH_RULE_INDEX, $Vk,
305         MINUS_SIGN_RULE_INDEX, $Vl
306       ])),
307-      o($Vq, [2, 9], {11: $Vc, 20: $Vj, 21: $Vk, 22: $Vl}),
308+      extendRules($Vq, [2, 9], ObjectFromPairs.of([
309+        INDEX11, $Vc,
310+        INDEX20, $Vj,
311+        INDEX21, $Vk,
312+        INDEX22, $Vl
313+      ])),
314       ObjectFromPairs.of([
315         SINGLE_QUOTES_RULE_INDEX, 13,
316         DATE_RULE_INDEX, 67,
317@@ -822,7 +867,7 @@ var Parser = (function () {
318         PERCENT_SIGN_RULE_INDEX, $Va,
319         END_OF_STRING_RULE_INDEX, $Vb
320       ]),
321-      o($Vr, [2, 16], ObjectFromPairs.of([
322+      extendRules($Vr, [2, 16], ObjectFromPairs.of([
323         INTEGER_RULE_INDEX, $Vc,
324         DOLLAR_SIGN_RULE_INDEX, $Ve,
325         COMMA_RULE_INDEX, $Vi,
326@@ -849,7 +894,7 @@ var Parser = (function () {
327         PERCENT_SIGN_RULE_INDEX, $Va,
328         END_OF_STRING_RULE_INDEX, $Vb
329       ]),
330-      o($Vr, [2, 15], ObjectFromPairs.of([
331+      extendRules($Vr, [2, 15], ObjectFromPairs.of([
332         INTEGER_RULE_INDEX, $Vc,
333         DOLLAR_SIGN_RULE_INDEX, $Ve,
334         COMMA_RULE_INDEX, $Vi,
335@@ -857,7 +902,7 @@ var Parser = (function () {
336         FORWARD_SLASH_RULE_INDEX, $Vk,
337         MINUS_SIGN_RULE_INDEX, $Vl
338       ])),
339-      o([5, 12, 15, 18, 30, 31], [2, 14], ObjectFromPairs.of([
340+      extendRules([5, 12, 15, 18, 30, 31], [2, 14], ObjectFromPairs.of([
341         INTEGER_RULE_INDEX, $Vc,
342         DOLLAR_SIGN_RULE_INDEX, $Ve,
343         PERIOD_RULE_INDEX, $Vf,
344@@ -867,30 +912,30 @@ var Parser = (function () {
345         FORWARD_SLASH_RULE_INDEX, $Vk,
346         MINUS_SIGN_RULE_INDEX, $Vl
347       ])),
348-      o($Vq, [2, 17], ObjectFromPairs.of([
349+      extendRules($Vq, [2, 17], ObjectFromPairs.of([
350         INTEGER_RULE_INDEX, $Vc,
351         ASTERISK_RULE_INDEX, $Vj,
352         FORWARD_SLASH_RULE_INDEX, $Vk,
353         MINUS_SIGN_RULE_INDEX, $Vl
354       ])),
355-      o($Vs, [2, 18], ObjectFromPairs.of([
356+      extendRules($Vs, [2, 18], ObjectFromPairs.of([
357         INTEGER_RULE_INDEX, $Vc,
358         MINUS_SIGN_RULE_INDEX, $Vl
359       ])),
360-      o($Vs, [2, 19], ObjectFromPairs.of([
361+      extendRules($Vs, [2, 19], ObjectFromPairs.of([
362         INTEGER_RULE_INDEX, $Vc,
363         MINUS_SIGN_RULE_INDEX, $Vl
364       ])),
365-      o([5, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31], [2, 20], ObjectFromPairs.of([INTEGER_RULE_INDEX, $Vc])),
366-      o($Vn, [2, 37]),
367-      o($Vm, [2, 10]),
368-      o($Vm, [2, 23]),
369+      extendRules([5, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 30, 31], [2, 20], ObjectFromPairs.of([INTEGER_RULE_INDEX, $Vc])),
370+      extendRules($Vn, [2, 37]),
371+      extendRules($Vm, [2, 10]),
372+      extendRules($Vm, [2, 23]),
373       ObjectFromPairs.of([
374         SINGLE_WHITESPACE_RULE_INDEX, [1, 70],
375         OPEN_DOUBLE_QUOTE_INDEX, [1, 71],
376         OPEN_SINGLE_QUITE_INDEX, [1, 72]
377       ]),
378-      o($Vt, [2, 32], ObjectFromPairs.of([
379+      extendRules($Vt, [2, 32], ObjectFromPairs.of([
380         INTEGER_RULE_INDEX, $Vc,
381         OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX, $Vd,
382         DOLLAR_SIGN_RULE_INDEX, $Ve,
383@@ -902,12 +947,12 @@ var Parser = (function () {
384         FORWARD_SLASH_RULE_INDEX, $Vk,
385         MINUS_SIGN_RULE_INDEX, $Vl
386       ])),
387-      o($Vt, [2, 33]), {37: [1, 73]}, // index 37?
388-      o($Vp, [2, 39]),
389-      o($Vm, [2, 29]),
390-      o($Vm, [2, 31]),
391-      o($Vu, [2, 41]),
392-      o($Vr, [2, 11], ObjectFromPairs.of([
393+      extendRules($Vt, [2, 33]), ObjectFromPairs.of([37, [1, 73]]), // index 37?
394+      extendRules($Vp, [2, 39]),
395+      extendRules($Vm, [2, 29]),
396+      extendRules($Vm, [2, 31]),
397+      extendRules($Vu, [2, 41]),
398+      extendRules($Vr, [2, 11], ObjectFromPairs.of([
399         INTEGER_RULE_INDEX, $Vc,
400         DOLLAR_SIGN_RULE_INDEX, $Ve,
401         COMMA_RULE_INDEX, $Vi,
402@@ -915,7 +960,7 @@ var Parser = (function () {
403         FORWARD_SLASH_RULE_INDEX, $Vk,
404         MINUS_SIGN_RULE_INDEX, $Vl
405       ])),
406-      o($Vr, [2, 13], ObjectFromPairs.of([
407+      extendRules($Vr, [2, 13], ObjectFromPairs.of([
408         11, $Vc,
409         13, $Ve,
410         19, $Vi,
411@@ -923,7 +968,7 @@ var Parser = (function () {
412         21, $Vk,
413         22, $Vl
414       ])),
415-      o($Vr, [2, 12], ObjectFromPairs.of([
416+      extendRules($Vr, [2, 12], ObjectFromPairs.of([
417         INTEGER_RULE_INDEX, $Vc,
418         DOLLAR_SIGN_RULE_INDEX, $Ve,
419         COMMA_RULE_INDEX, $Vi,
420@@ -931,7 +976,7 @@ var Parser = (function () {
421         FORWARD_SLASH_RULE_INDEX, $Vk,
422         MINUS_SIGN_RULE_INDEX, $Vl
423       ])),
424-      o($Vm, [2, 24]),
425+      extendRules($Vm, [2, 24]),
426       ObjectFromPairs.of([
427         SINGLE_QUOTES_RULE_INDEX, 13,
428         DATE_RULE_INDEX, 74,
429@@ -970,8 +1015,8 @@ var Parser = (function () {
430         PERCENT_SIGN_RULE_INDEX, $Va,
431         END_OF_STRING_RULE_INDEX, $Vb
432       ]),
433-      o($Vu, [2, 42]),
434-      o($Vt, [2, 34], ObjectFromPairs.of([
435+      extendRules($Vu, [2, 42]),
436+      extendRules($Vt, [2, 34], ObjectFromPairs.of([
437         INTEGER_RULE_INDEX, $Vc,
438         OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX, $Vd,
439         DOLLAR_SIGN_RULE_INDEX, $Ve,
440@@ -983,7 +1028,7 @@ var Parser = (function () {
441         FORWARD_SLASH_RULE_INDEX, $Vk,
442         MINUS_SIGN_RULE_INDEX, $Vl
443       ])),
444-      o($Vt, [2, 35], ObjectFromPairs.of([
445+      extendRules($Vt, [2, 35], ObjectFromPairs.of([
446         INTEGER_RULE_INDEX, $Vc,
447         OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX, $Vd,
448         DOLLAR_SIGN_RULE_INDEX, $Ve,
449@@ -1064,7 +1109,7 @@ var Parser = (function () {
450         return token;
451       }
452 
453-      var symbol, preErrorSymbol, state, action, a, r, yyval = {
454+      let symbol, preErrorSymbol, state, action, r, yyval = {
455         $: undefined,
456         _$: undefined
457       }, p, len, newState, expected;
458@@ -1085,14 +1130,14 @@ var Parser = (function () {
459 
460         // handle parse error
461         if (typeof action === 'undefined' || !action.length || !action[0]) {
462-          var error_rule_depth;
463-          var errStr = '';
464+          let error_rule_depth;
465+          let errStr = '';
466 
467           // Return the rule stack depth where the nearest error rule can be found.
468           // Return FALSE when no error recovery rule was found.
469           this.locateNearestErrorRecoveryRule = function(state) {
470-            var stack_probe = stack.length - 1;
471-            var depth = 0;
472+            let stack_probe = stack.length - 1;
473+            let depth = 0;
474 
475             // try to recover from error
476             for (; ;) {
477@@ -1107,7 +1152,7 @@ var Parser = (function () {
478               state = stack[stack_probe];
479               ++depth;
480             }
481-          }
482+          };
483 
484           if (!recovering) {
485             // first see if there's any chance at hitting an error recovery rule:
486diff --git a/src/Parser/Rules.ts b/src/Parser/Rules.ts
487index f0c3d51..f71ad41 100644
488--- a/src/Parser/Rules.ts
489+++ b/src/Parser/Rules.ts
490@@ -121,6 +121,44 @@ const HASH_SIGN_RULE_INDEX = RULES.indexOf(HASH_SIGN_RULE);
491 const END_OF_STRING_RULE_INDEX = RULES.indexOf(END_OF_STRING_RULE);
492 
493 
494+const INDEX0 = RULES.indexOf(WHITE_SPACE_RULE);
495+const INDEX1 = RULES.indexOf(DOUBLE_QUOTES_RULE);
496+const INDEX2 = RULES.indexOf(SINGLE_QUOTES_RULE);
497+const INDEX3 = RULES.indexOf(FORMULA_NAME_RULE);
498+const INDEX4 = RULES.indexOf(DATE_RULE);
499+const INDEX5 = RULES.indexOf(TIME_RULE);
500+const INDEX6 = RULES.indexOf($_A1_CELL_RULE);
501+const INDEX7 = RULES.indexOf(A1_CELL_RULE);
502+const INDEX8 = RULES.indexOf(FORMULA_NAME_SIMPLE_RULE);
503+const INDEX9 = RULES.indexOf(VARIABLE_RULE);
504+const INDEX10 = RULES.indexOf(SIMPLE_VARIABLE_RILE);
505+const INDEX11 = RULES.indexOf(INTEGER_RULE);
506+const INDEX12 = RULES.indexOf(OPEN_AND_CLOSE_OF_ARRAY_RULE);
507+const INDEX13 = RULES.indexOf(DOLLAR_SIGN_RULE);
508+const INDEX14 = RULES.indexOf(AMPERSAND_SIGN_RULE);
509+const INDEX15 = RULES.indexOf(SINGLE_WHITESPACE_RULE);
510+const INDEX16 = RULES.indexOf(PERIOD_RULE);
511+const INDEX17 = RULES.indexOf(COLON_RULE);
512+const INDEX18 = RULES.indexOf(SEMI_COLON_RULE);
513+const INDEX19 = RULES.indexOf(COMMA_RULE);
514+const INDEX20 = RULES.indexOf(ASTERISK_RULE);
515+const INDEX21 = RULES.indexOf(FORWARD_SLASH_RULE);
516+const INDEX22 = RULES.indexOf(MINUS_SIGN_RULE);
517+const INDEX23 = RULES.indexOf(PLUS_SIGN_RULE);
518+const INDEX24 = RULES.indexOf(CARET_SIGN_RULE);
519+const INDEX25 = RULES.indexOf(OPEN_PAREN_RULE);
520+const INDEX26 = RULES.indexOf(CLOSE_PAREN_RULE);
521+const INDEX27 = RULES.indexOf(GREATER_THAN_SIGN_RULE);
522+const INDEX28 = RULES.indexOf(LESS_THAN_SIGN_RULE);
523+const INDEX29 = RULES.indexOf(NOT_RULE);
524+const INDEX30 = RULES.indexOf(OPEN_DOUBLE_QUOTE);
525+const INDEX31 = RULES.indexOf(OPEN_SINGLE_QUITE);
526+const INDEX32 = RULES.indexOf(EXCLAMATION_POINT_RULE);
527+const INDEX33 = RULES.indexOf(EQUALS_SIGN_RULE);
528+const INDEX34 = RULES.indexOf(PERCENT_SIGN_RULE);
529+const INDEX35 = RULES.indexOf(HASH_SIGN_RULE);
530+const INDEX36 = RULES.indexOf(END_OF_STRING_RULE);
531+
532 export {
533   RULES,
534 
535@@ -160,5 +198,43 @@ export {
536   EQUALS_SIGN_RULE_INDEX,
537   PERCENT_SIGN_RULE_INDEX,
538   HASH_SIGN_RULE_INDEX,
539-  END_OF_STRING_RULE_INDEX
540+  END_OF_STRING_RULE_INDEX,
541+
542+  INDEX0,
543+  INDEX1,
544+  INDEX2,
545+  INDEX3,
546+  INDEX4,
547+  INDEX5,
548+  INDEX6,
549+  INDEX7,
550+  INDEX8,
551+  INDEX9,
552+  INDEX10,
553+  INDEX11,
554+  INDEX12,
555+  INDEX13,
556+  INDEX14,
557+  INDEX15,
558+  INDEX16,
559+  INDEX17,
560+  INDEX18,
561+  INDEX19,
562+  INDEX20,
563+  INDEX21,
564+  INDEX22,
565+  INDEX23,
566+  INDEX24,
567+  INDEX25,
568+  INDEX26,
569+  INDEX27,
570+  INDEX28,
571+  INDEX29,
572+  INDEX30,
573+  INDEX31,
574+  INDEX32,
575+  INDEX33,
576+  INDEX34,
577+  INDEX35,
578+  INDEX36
579 }
580\ No newline at end of file