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] naming indexes, adding documentation to parser
author
Ben Vogt <[email protected]>
date
2017-08-19 19:07:29
stats
2 file(s) changed, 374 insertions(+), 302 deletions(-)
files
src/Parser/Parser.ts
src/Parser/Rules.ts
  1diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
  2index 98c6c41..a659733 100644
  3--- a/src/Parser/Parser.ts
  4+++ b/src/Parser/Parser.ts
  5@@ -2,7 +2,7 @@ import {
  6   RULES,
  7 
  8   // WHITE_SPACE_RULE_INDEX,
  9-  // DOUBLE_QUOTES_RULE_INDEX,
 10+  DOUBLE_QUOTES_RULE_INDEX,
 11   SINGLE_QUOTES_RULE_INDEX,
 12   FORMULA_NAME_RULE_INDEX,
 13   DATE_RULE_INDEX,
 14@@ -28,53 +28,16 @@ import {
 15   CARET_SIGN_RULE_INDEX,
 16   OPEN_PAREN_RULE_INDEX,
 17   CLOSE_PAREN_RULE_INDEX,
 18-  // GREATER_THAN_SIGN_RULE_INDEX,
 19+  GREATER_THAN_SIGN_RULE_INDEX,
 20   LESS_THAN_SIGN_RULE_INDEX,
 21   NOT_RULE_INDEX,
 22   OPEN_DOUBLE_QUOTE_INDEX,
 23   OPEN_SINGLE_QUITE_INDEX,
 24   EXCLAMATION_POINT_RULE_INDEX,
 25-  // EQUALS_SIGN_RULE_INDEX,
 26+  EQUALS_SIGN_RULE_INDEX,
 27   PERCENT_SIGN_RULE_INDEX,
 28-  // HASH_SIGN_RULE_INDEX,
 29-  END_OF_STRING_RULE_INDEX,
 30-  // INDEX0,
 31-  INDEX1,
 32-  // INDEX2,
 33-  // INDEX3,
 34-  INDEX4,
 35-  INDEX5,
 36-  INDEX6,
 37-  INDEX7,
 38-  INDEX8,
 39-  INDEX9,
 40-  INDEX10,
 41-  INDEX11,
 42-  INDEX12,
 43-  INDEX13,
 44-  INDEX14,
 45-  INDEX15,
 46-  INDEX16,
 47-  INDEX17,
 48-  INDEX18,
 49-  INDEX19,
 50-  INDEX20,
 51-  INDEX21,
 52-  INDEX22,
 53-  INDEX23,
 54-  INDEX24,
 55-  INDEX25,
 56-  INDEX26,
 57-  INDEX27,
 58-  INDEX28,
 59-  INDEX29,
 60-  INDEX30,
 61-  INDEX31,
 62-  INDEX32,
 63-  INDEX33,
 64-  INDEX34,
 65-  INDEX35,
 66-  INDEX36
 67+  HASH_SIGN_RULE_INDEX,
 68+  END_OF_STRING_RULE_INDEX
 69 } from "./Rules";
 70 import {
 71   ObjectFromPairs
 72@@ -107,42 +70,143 @@ let Parser = (function () {
 73     for (obj = obj || {}, l = k.length; l--; obj[k[l]] = v) {}
 74     return obj;
 75   };
 76-  const $V0 = [INDEX1, INDEX4];
 77-  const $V1 = [INDEX1, INDEX5];
 78-  const $V2 = [INDEX1, INDEX7];
 79-  const $V3 = [INDEX1, INDEX10];
 80-  const $V4 = [INDEX1, INDEX8];
 81-  const $V5 = [INDEX1, INDEX9];
 82-  const $V6 = [INDEX1, INDEX11];
 83-  const $V7 = [INDEX1, INDEX16];
 84-  const $V8 = [INDEX1, INDEX17];
 85-  const $V9 = [INDEX1, INDEX14];
 86-  const $Va = [INDEX1, INDEX15];
 87-  const $Vb = [INDEX1, INDEX18];
 88-  const $Vc = [INDEX1, INDEX20];
 89-  const $Vd = [INDEX1, INDEX21];
 90-  const $Ve = [INDEX1, INDEX22];
 91-  const $Vf = [INDEX1, INDEX23];
 92-  const $Vg = [INDEX1, INDEX24];
 93-  const $Vh = [INDEX1, INDEX25];
 94-  const $Vi = [INDEX1, INDEX26];
 95-  const $Vj = [INDEX1, INDEX27];
 96-  const $Vk = [INDEX1, INDEX28];
 97-  const $Vl = [INDEX1, INDEX29];
 98-  const $Vm = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31];
 99-  const $Vn = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX33];
100-  const $Vo = [INDEX1, 38]; // index 38?
101-  const $Vp = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX35, 38]; // index 38?
102-  const $Vq = [INDEX5, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX30, INDEX31];
103-  const $Vr = [INDEX5, INDEX12, INDEX15, INDEX16, INDEX17, INDEX18, INDEX30, INDEX31];
104-  const $Vs = [INDEX5, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX30, INDEX31];
105-  const $Vt = [INDEX15, INDEX30, INDEX31];
106-  const $Vu = [INDEX5, INDEX11, INDEX12, INDEX13, INDEX15, INDEX16, INDEX17, INDEX18, INDEX19, INDEX20, INDEX21, INDEX22, INDEX30, INDEX31, INDEX32, INDEX36];
107+  const $V0 = [DOUBLE_QUOTES_RULE_INDEX, DATE_RULE_INDEX];
108+  const $V1 = [DOUBLE_QUOTES_RULE_INDEX, TIME_RULE_INDEX];
109+  const $V2 = [DOUBLE_QUOTES_RULE_INDEX, A1_CELL_RULE_INDEX];
110+  const $V3 = [DOUBLE_QUOTES_RULE_INDEX, SIMPLE_VARIABLE_RILE_INDEX];
111+  const $V4 = [DOUBLE_QUOTES_RULE_INDEX, FORMULA_NAME_SIMPLE_RULE_INDEX];
112+  const $V5 = [DOUBLE_QUOTES_RULE_INDEX, VARIABLE_RULE_INDEX];
113+  const $V6 = [DOUBLE_QUOTES_RULE_INDEX, INTEGER_RULE_INDEX];
114+  const $V7 = [DOUBLE_QUOTES_RULE_INDEX, PERIOD_RULE_INDEX];
115+  const $V8 = [DOUBLE_QUOTES_RULE_INDEX, COLON_RULE_INDEX];
116+  const $V9 = [DOUBLE_QUOTES_RULE_INDEX, AMPERSAND_SIGN_RULE_INDEX];
117+  const $Va = [DOUBLE_QUOTES_RULE_INDEX, SINGLE_WHITESPACE_RULE_INDEX];
118+  const $Vb = [DOUBLE_QUOTES_RULE_INDEX, SEMI_COLON_RULE_INDEX];
119+  const $Vc = [DOUBLE_QUOTES_RULE_INDEX, ASTERISK_RULE_INDEX];
120+  const $Vd = [DOUBLE_QUOTES_RULE_INDEX, FORWARD_SLASH_RULE_INDEX];
121+  const $Ve = [DOUBLE_QUOTES_RULE_INDEX, MINUS_SIGN_RULE_INDEX];
122+  const $Vf = [DOUBLE_QUOTES_RULE_INDEX, PLUS_SIGN_RULE_INDEX];
123+  const $Vg = [DOUBLE_QUOTES_RULE_INDEX, CARET_SIGN_RULE_INDEX];
124+  const $Vh = [DOUBLE_QUOTES_RULE_INDEX, OPEN_PAREN_RULE_INDEX];
125+  const $Vi = [DOUBLE_QUOTES_RULE_INDEX, CLOSE_PAREN_RULE_INDEX];
126+  const $Vj = [DOUBLE_QUOTES_RULE_INDEX, GREATER_THAN_SIGN_RULE_INDEX];
127+  const $Vk = [DOUBLE_QUOTES_RULE_INDEX, LESS_THAN_SIGN_RULE_INDEX];
128+  const $Vl = [DOUBLE_QUOTES_RULE_INDEX, NOT_RULE_INDEX];
129+  const $Vm = [
130+    TIME_RULE_INDEX,
131+    INTEGER_RULE_INDEX,
132+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
133+    DOLLAR_SIGN_RULE_INDEX,
134+    SINGLE_WHITESPACE_RULE_INDEX,
135+    PERIOD_RULE_INDEX,
136+    COLON_RULE_INDEX,
137+    SEMI_COLON_RULE_INDEX,
138+    COMMA_RULE_INDEX,
139+    ASTERISK_RULE_INDEX,
140+    FORWARD_SLASH_RULE_INDEX,
141+    MINUS_SIGN_RULE_INDEX,
142+    OPEN_DOUBLE_QUOTE_INDEX,
143+    OPEN_SINGLE_QUITE_INDEX
144+  ];
145+  const $Vn = [
146+    TIME_RULE_INDEX,
147+    INTEGER_RULE_INDEX,
148+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
149+    DOLLAR_SIGN_RULE_INDEX,
150+    SINGLE_WHITESPACE_RULE_INDEX,
151+    PERIOD_RULE_INDEX,
152+    COLON_RULE_INDEX,
153+    SEMI_COLON_RULE_INDEX,
154+    COMMA_RULE_INDEX,
155+    ASTERISK_RULE_INDEX,
156+    FORWARD_SLASH_RULE_INDEX,
157+    MINUS_SIGN_RULE_INDEX,
158+    OPEN_DOUBLE_QUOTE_INDEX,
159+    OPEN_SINGLE_QUITE_INDEX,
160+    EQUALS_SIGN_RULE_INDEX
161+  ];
162+  const $Vo = [DOUBLE_QUOTES_RULE_INDEX, 38]; // index 38?
163+  const $Vp = [
164+    TIME_RULE_INDEX,
165+    INTEGER_RULE_INDEX,
166+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
167+    DOLLAR_SIGN_RULE_INDEX,
168+    SINGLE_WHITESPACE_RULE_INDEX,
169+    PERIOD_RULE_INDEX,
170+    COLON_RULE_INDEX,
171+    SEMI_COLON_RULE_INDEX,
172+    COMMA_RULE_INDEX,
173+    ASTERISK_RULE_INDEX,
174+    FORWARD_SLASH_RULE_INDEX,
175+    MINUS_SIGN_RULE_INDEX,
176+    OPEN_DOUBLE_QUOTE_INDEX,
177+    OPEN_SINGLE_QUITE_INDEX,
178+    HASH_SIGN_RULE_INDEX,
179+    38 // index 38?
180+  ];
181+  const $Vq = [
182+    TIME_RULE_INDEX,
183+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
184+    DOLLAR_SIGN_RULE_INDEX,
185+    SINGLE_WHITESPACE_RULE_INDEX,
186+    PERIOD_RULE_INDEX,
187+    COLON_RULE_INDEX,
188+    SEMI_COLON_RULE_INDEX,
189+    COMMA_RULE_INDEX,
190+    OPEN_DOUBLE_QUOTE_INDEX,
191+    OPEN_SINGLE_QUITE_INDEX
192+  ];
193+  const $Vr = [
194+    TIME_RULE_INDEX,
195+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
196+    SINGLE_WHITESPACE_RULE_INDEX,
197+    PERIOD_RULE_INDEX,
198+    COLON_RULE_INDEX,
199+    SEMI_COLON_RULE_INDEX,
200+    OPEN_DOUBLE_QUOTE_INDEX,
201+    OPEN_SINGLE_QUITE_INDEX
202+  ];
203+  const $Vs = [
204+    TIME_RULE_INDEX,
205+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
206+    DOLLAR_SIGN_RULE_INDEX,
207+    SINGLE_WHITESPACE_RULE_INDEX,
208+    PERIOD_RULE_INDEX,
209+    COLON_RULE_INDEX,
210+    SEMI_COLON_RULE_INDEX,
211+    COMMA_RULE_INDEX,
212+    ASTERISK_RULE_INDEX,
213+    FORWARD_SLASH_RULE_INDEX,
214+    OPEN_DOUBLE_QUOTE_INDEX,
215+    OPEN_SINGLE_QUITE_INDEX
216+  ];
217+  const $Vt = [
218+    SINGLE_WHITESPACE_RULE_INDEX,
219+    OPEN_DOUBLE_QUOTE_INDEX,
220+    OPEN_SINGLE_QUITE_INDEX
221+  ];
222+  const $Vu = [
223+    TIME_RULE_INDEX,
224+    INTEGER_RULE_INDEX,
225+    OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
226+    DOLLAR_SIGN_RULE_INDEX,
227+    SINGLE_WHITESPACE_RULE_INDEX,
228+    PERIOD_RULE_INDEX,
229+    COLON_RULE_INDEX,
230+    SEMI_COLON_RULE_INDEX,
231+    COMMA_RULE_INDEX,
232+    ASTERISK_RULE_INDEX,
233+    FORWARD_SLASH_RULE_INDEX,
234+    MINUS_SIGN_RULE_INDEX,
235+    OPEN_DOUBLE_QUOTE_INDEX,
236+    OPEN_SINGLE_QUITE_INDEX,
237+    EXCLAMATION_POINT_RULE_INDEX,
238+    END_OF_STRING_RULE_INDEX
239+  ];
240   let parser = {
241     lexer: undefined,
242     Parser: undefined,
243-    trace: function trace() {
244-    },
245+    trace: function trace() {},
246     yy: {},
247     symbols_: {
248       "error": 2,
249@@ -260,107 +324,107 @@ let Parser = (function () {
250       [2, 3],
251       [2, 4]
252     ],
253-    performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
254-      /* this == yyval */
255+    performAction: function anonymous(yytext, yyleng, yylineno, yy, actionIndexToPerform /* action[1] */, virtualStack /* vstack */) {
256+      // For context, this function is only called with `call` or `apply`, so `this` is `yyval`.
257 
258-      let $0 = $$.length - 1;
259-      switch (yystate) {
260+      let $0 = virtualStack.length - 1;
261+      switch (actionIndexToPerform) {
262         case 1:
263-          return $$[$0 - 1];
264+          return virtualStack[$0 - 1];
265         case 2:
266-          this.$ = yy.handler.helper.callVariable.call(this, $$[$0]);
267+          this.$ = yy.handler.helper.callVariable.call(this, virtualStack[$0]);
268           break;
269         case 3:
270-          this.$ = yy.handler.time.call(yy.obj, $$[$0], true);
271+          this.$ = yy.handler.time.call(yy.obj, virtualStack[$0], true);
272           break;
273         case 4:
274-          this.$ = yy.handler.time.call(yy.obj, $$[$0]);
275+          this.$ = yy.handler.time.call(yy.obj, virtualStack[$0]);
276           break;
277         case 5:
278-          this.$ = yy.handler.helper.number($$[$0]);
279+          this.$ = yy.handler.helper.number(virtualStack[$0]);
280           break;
281         case 6:
282-          this.$ = yy.handler.helper.string($$[$0]);
283+          this.$ = yy.handler.helper.string(virtualStack[$0]);
284           break;
285         case 7:
286-          this.$ = yy.handler.helper.specialMatch('&', $$[$0 - 2], $$[$0]);
287+          this.$ = yy.handler.helper.specialMatch('&', virtualStack[$0 - 2], virtualStack[$0]);
288           break;
289         case 8:
290-          this.$ = yy.handler.helper.logicMatch('=', $$[$0 - 2], $$[$0]);
291+          this.$ = yy.handler.helper.logicMatch('=', virtualStack[$0 - 2], virtualStack[$0]);
292           break;
293         case 9:
294-          this.$ = yy.handler.helper.mathMatch('+', $$[$0 - 2], $$[$0]);
295+          this.$ = yy.handler.helper.mathMatch('+', virtualStack[$0 - 2], virtualStack[$0]);
296           break;
297         case 10:
298-          this.$ = yy.handler.helper.number($$[$0 - 1]);
299+          this.$ = yy.handler.helper.number(virtualStack[$0 - 1]);
300           break;
301         case 11:
302-          this.$ = yy.handler.helper.logicMatch('<=', $$[$0 - 3], $$[$0]);
303+          this.$ = yy.handler.helper.logicMatch('<=', virtualStack[$0 - 3], virtualStack[$0]);
304           break;
305         case 12:
306-          this.$ = yy.handler.helper.logicMatch('>=', $$[$0 - 3], $$[$0]);
307+          this.$ = yy.handler.helper.logicMatch('>=', virtualStack[$0 - 3], virtualStack[$0]);
308           break;
309         case 13:
310-          this.$ = yy.handler.helper.logicMatch('<>', $$[$0 - 3], $$[$0]);
311+          this.$ = yy.handler.helper.logicMatch('<>', virtualStack[$0 - 3], virtualStack[$0]);
312           break;
313         case 14:
314-          this.$ = yy.handler.helper.logicMatch('NOT', $$[$0 - 2], $$[$0]);
315+          this.$ = yy.handler.helper.logicMatch('NOT', virtualStack[$0 - 2], virtualStack[$0]);
316           break;
317         case 15:
318-          this.$ = yy.handler.helper.logicMatch('>', $$[$0 - 2], $$[$0]);
319+          this.$ = yy.handler.helper.logicMatch('>', virtualStack[$0 - 2], virtualStack[$0]);
320           break;
321         case 16:
322-          this.$ = yy.handler.helper.logicMatch('<', $$[$0 - 2], $$[$0]);
323+          this.$ = yy.handler.helper.logicMatch('<', virtualStack[$0 - 2], virtualStack[$0]);
324           break;
325         case 17:
326-          this.$ = yy.handler.helper.mathMatch('-', $$[$0 - 2], $$[$0]);
327+          this.$ = yy.handler.helper.mathMatch('-', virtualStack[$0 - 2], virtualStack[$0]);
328           break;
329         case 18:
330-          this.$ = yy.handler.helper.mathMatch('*', $$[$0 - 2], $$[$0]);
331+          this.$ = yy.handler.helper.mathMatch('*', virtualStack[$0 - 2], virtualStack[$0]);
332           break;
333         case 19:
334-          this.$ = yy.handler.helper.mathMatch('/', $$[$0 - 2], $$[$0]);
335+          this.$ = yy.handler.helper.mathMatch('/', virtualStack[$0 - 2], virtualStack[$0]);
336           break;
337         case 20:
338-          this.$ = yy.handler.helper.mathMatch('^', $$[$0 - 2], $$[$0]);
339+          this.$ = yy.handler.helper.mathMatch('^', virtualStack[$0 - 2], virtualStack[$0]);
340           break;
341         case 21:
342-          this.$ = yy.handler.helper.numberInverted($$[$0]);
343+          this.$ = yy.handler.helper.numberInverted(virtualStack[$0]);
344           if (isNaN(this.$)) {
345             this.$ = 0;
346           }
347           break;
348         case 22:
349-          this.$ = yy.handler.helper.number($$[$0]);
350+          this.$ = yy.handler.helper.number(virtualStack[$0]);
351           if (isNaN(this.$)) {
352             this.$ = 0;
353           }
354           break;
355         case 23:
356           // console.log("message from parser: 'calling function with no args': ", $$[$0 - 2]);
357-          this.$ = yy.handler.helper.callFunction.call(this, $$[$0 - 2], '');
358+          this.$ = yy.handler.helper.callFunction.call(this, virtualStack[$0 - 2], '');
359           break;
360         case 24:
361           // console.log("message from parser: 'calling function w/ args': ", $$[$0 - 3], $$[$0 - 1]);
362-          this.$ = yy.handler.helper.callFunction.call(this, $$[$0 - 3], $$[$0 - 1]);
363+          this.$ = yy.handler.helper.callFunction.call(this, virtualStack[$0 - 3], virtualStack[$0 - 1]);
364           break;
365         case 28:
366-          this.$ = yy.handler.helper.fixedCellValue.call(yy.obj, $$[$0]);
367+          this.$ = yy.handler.helper.fixedCellValue.call(yy.obj, virtualStack[$0]);
368           break;
369         case 29:
370-          this.$ = yy.handler.helper.fixedCellRangeValue.call(yy.obj, $$[$0 - 2], $$[$0]);
371+          this.$ = yy.handler.helper.fixedCellRangeValue.call(yy.obj, virtualStack[$0 - 2], virtualStack[$0]);
372           break;
373         case 30:
374-          this.$ = yy.handler.helper.cellValue.call(yy.obj, $$[$0]);
375+          this.$ = yy.handler.helper.cellValue.call(yy.obj, virtualStack[$0]);
376           break;
377         case 31:
378-          this.$ = yy.handler.helper.cellRangeValue.call(yy.obj, $$[$0 - 2], $$[$0]);
379+          this.$ = yy.handler.helper.cellRangeValue.call(yy.obj, virtualStack[$0 - 2], virtualStack[$0]);
380           break;
381         case 32:
382-          if (yy.handler.utils.isArray($$[$0])) {
383-            this.$ = $$[$0];
384+          if (yy.handler.utils.isArray(virtualStack[$0])) {
385+            this.$ = virtualStack[$0];
386           } else {
387-            this.$ = [$$[$0]];
388+            this.$ = [virtualStack[$0]];
389           }
390           break;
391         case 33:
392@@ -373,57 +437,75 @@ let Parser = (function () {
393           break;
394         case 34:
395         case 35:
396-          $$[$0 - 2].push($$[$0]);
397-          this.$ = $$[$0 - 2];
398+          virtualStack[$0 - 2].push(virtualStack[$0]);
399+          this.$ = virtualStack[$0 - 2];
400           break;
401         case 36:
402-          this.$ = [$$[$0]];
403+          this.$ = [virtualStack[$0]];
404           break;
405         case 37:
406-          this.$ = (yy.handler.utils.isArray($$[$0 - 2]) ? $$[$0 - 2] : [$$[$0 - 2]]);
407-          this.$.push($$[$0]);
408+          this.$ = (yy.handler.utils.isArray(virtualStack[$0 - 2]) ? virtualStack[$0 - 2] : [virtualStack[$0 - 2]]);
409+          this.$.push(virtualStack[$0]);
410           break;
411         case 38:
412-          this.$ = $$[$0];
413+          this.$ = virtualStack[$0];
414           break;
415         case 39:
416-          this.$ = parseFloat($$[$0 - 2] + '.' + $$[$0]) * 1;
417+          this.$ = parseFloat(virtualStack[$0 - 2] + '.' + virtualStack[$0]);
418           break;
419         case 40:
420-          this.$ = $$[$0 - 1] * 0.01;
421+          this.$ = virtualStack[$0 - 1] * 0.01;
422           break;
423         case 41:
424         case 42:
425-          this.$ = $$[$0 - 2] + $$[$0 - 1] + $$[$0];
426+          this.$ = virtualStack[$0 - 2] + virtualStack[$0 - 1] + virtualStack[$0];
427           break;
428       }
429     },
430     /**
431      * The `table` is an array of objects that map {@link RULES} to LexActions and tokens. Eg:
432+     *  { '2': 13,            SINGLE_QUOTES_RULE:
433+          '3': 1,
434+          '4': 2,
435+          '6': 3,
436+          '7': [ 1, 4 ],
437+          '8': [ 1, 5 ],
438+          '9': 6,
439+          '10': [ 1, 7 ],
440+          '13': [ 1, 10 ],
441+          '14': [ 1, 8 ],
442+          '19': [ 1, 9 ],
443+          '23': [ 1, 11 ],
444+          '25': 12,
445+          '26': [ 1, 16 ],
446+          '28': [ 1, 17 ],
447+          '32': [ 1, 14 ],
448+          '34': [ 1, 15 ],
449+          '36': [ 1, 18 ] }
450      */
451     table: [
452       ObjectFromPairs.of([
453         SINGLE_QUOTES_RULE_INDEX, 13,
454         FORMULA_NAME_RULE_INDEX, 1,
455         DATE_RULE_INDEX, 2,
456-        INDEX6, 3,
457-        INDEX7, $V0,
458-        INDEX8, $V1,
459-        INDEX9, 6,
460-        INDEX10, $V2,
461-        INDEX13, $V3,
462-        INDEX14, $V4,
463-        INDEX19, $V5,
464-        INDEX23, $V6,
465-        INDEX25, 12,
466-        INDEX26, $V7,
467-        INDEX28, $V8,
468-        INDEX32, $V9,
469-        INDEX34, $Va,
470-        INDEX36, $Vb
471+        $_A1_CELL_RULE_INDEX, 3,
472+        A1_CELL_RULE_INDEX, $V0,
473+        FORMULA_NAME_SIMPLE_RULE_INDEX, $V1,
474+        VARIABLE_RULE_INDEX, 6,
475+        SIMPLE_VARIABLE_RILE_INDEX, $V2,
476+        DOLLAR_SIGN_RULE_INDEX, $V3,
477+        AMPERSAND_SIGN_RULE_INDEX, $V4,
478+        COMMA_RULE_INDEX, $V5,
479+        PLUS_SIGN_RULE_INDEX, $V6,
480+        OPEN_PAREN_RULE_INDEX, 12,
481+        CLOSE_PAREN_RULE_INDEX, $V7,
482+        LESS_THAN_SIGN_RULE_INDEX, $V8,
483+        EXCLAMATION_POINT_RULE_INDEX, $V9,
484+        PERCENT_SIGN_RULE_INDEX, $Va,
485+        END_OF_STRING_RULE_INDEX, $Vb
486       ]),
487       ObjectFromPairs.of([
488-        INDEX1, [3]
489+        DOUBLE_QUOTES_RULE_INDEX, [3]
490       ]),
491       ObjectFromPairs.of([
492         TIME_RULE_INDEX, [LexActions.SHIFT, 19],
493@@ -438,10 +520,10 @@ let Parser = (function () {
494         FORWARD_SLASH_RULE_INDEX, $Vk,
495         MINUS_SIGN_RULE_INDEX, $Vl
496       ]),
497-      extendRules($Vm, [LexActions.REDUCE, 2], ObjectFromPairs.of([INDEX33, [LexActions.SHIFT, 30]])),
498+      extendRules($Vm, [LexActions.REDUCE, 2], ObjectFromPairs.of([EQUALS_SIGN_RULE_INDEX, [LexActions.SHIFT, 30]])),
499       extendRules($Vm, [LexActions.REDUCE, 3]),
500       extendRules($Vm, [LexActions.REDUCE, 4]),
501-      extendRules($Vm, [LexActions.REDUCE, 5], ObjectFromPairs.of([INDEX35, [LexActions.SHIFT, 31]])),
502+      extendRules($Vm, [LexActions.REDUCE, 5], ObjectFromPairs.of([HASH_SIGN_RULE_INDEX, [LexActions.SHIFT, 31]])),
503       extendRules($Vm, [LexActions.REDUCE, 6]),
504       ObjectFromPairs.of([
505         SINGLE_QUOTES_RULE_INDEX, 13,
506@@ -505,12 +587,12 @@ let Parser = (function () {
507       ]),
508       extendRules($Vm, [LexActions.REDUCE, 25]),
509       extendRules($Vm, [LexActions.REDUCE, 26], ObjectFromPairs.of([LexActions.REDUCE, 36, 32, [LexActions.SHIFT, 37], 36, $Vb])),
510-      extendRules($Vn, [LexActions.REDUCE, 36], ObjectFromPairs.of([INDEX36, $Vo])),
511-      extendRules($Vp, [LexActions.REDUCE, 38], ObjectFromPairs.of([INDEX33, [LexActions.SHIFT, 39]])),
512-      extendRules($Vm, [LexActions.REDUCE, 28], ObjectFromPairs.of([INDEX27, [LexActions.SHIFT, 40]])),
513-      extendRules($Vm, [LexActions.REDUCE, 30], ObjectFromPairs.of([INDEX27, [LexActions.SHIFT, 41]])),
514-      ObjectFromPairs.of([INDEX32, [LexActions.SHIFT, 42]]),
515-      ObjectFromPairs.of([INDEX1, [LexActions.ACCEPT, 1]]),
516+      extendRules($Vn, [LexActions.REDUCE, 36], ObjectFromPairs.of([END_OF_STRING_RULE_INDEX, $Vo])),
517+      extendRules($Vp, [LexActions.REDUCE, 38], ObjectFromPairs.of([EQUALS_SIGN_RULE_INDEX, [LexActions.SHIFT, 39]])),
518+      extendRules($Vm, [LexActions.REDUCE, 28], ObjectFromPairs.of([GREATER_THAN_SIGN_RULE_INDEX, [LexActions.SHIFT, 40]])),
519+      extendRules($Vm, [LexActions.REDUCE, 30], ObjectFromPairs.of([GREATER_THAN_SIGN_RULE_INDEX, [LexActions.SHIFT, 41]])),
520+      ObjectFromPairs.of([EXCLAMATION_POINT_RULE_INDEX, [LexActions.SHIFT, 42]]),
521+      ObjectFromPairs.of([DOUBLE_QUOTES_RULE_INDEX, [LexActions.ACCEPT, 1]]),
522       ObjectFromPairs.of([
523         SINGLE_QUOTES_RULE_INDEX, 13,
524         DATE_RULE_INDEX, 43,
525@@ -720,16 +802,16 @@ let Parser = (function () {
526         MINUS_SIGN_RULE_INDEX, $Vl
527       ]),
528       extendRules($Vq, [LexActions.REDUCE, 21], ObjectFromPairs.of([
529-        INDEX11, $Vc,
530-        INDEX20, $Vj,
531-        INDEX21, $Vk,
532-        INDEX22, $Vl
533+        INTEGER_RULE_INDEX, $Vc,
534+        ASTERISK_RULE_INDEX, $Vj,
535+        FORWARD_SLASH_RULE_INDEX, $Vk,
536+        MINUS_SIGN_RULE_INDEX, $Vl
537       ])),
538       extendRules($Vq, [LexActions.REDUCE, 22], ObjectFromPairs.of([
539-        INDEX11, $Vc,
540-        INDEX20, $Vj,
541-        INDEX21, $Vk,
542-        INDEX22, $Vl])
543+        INTEGER_RULE_INDEX, $Vc,
544+        ASTERISK_RULE_INDEX, $Vj,
545+        FORWARD_SLASH_RULE_INDEX, $Vk,
546+        MINUS_SIGN_RULE_INDEX, $Vl])
547       ),
548       ObjectFromPairs.of([
549         SINGLE_QUOTES_RULE_INDEX, 13,
550@@ -754,11 +836,11 @@ let Parser = (function () {
551         END_OF_STRING_RULE_INDEX, $Vb
552       ]),
553       extendRules($Vm, [LexActions.REDUCE, 27]),
554-      ObjectFromPairs.of([INDEX36, $Vo]),
555-      ObjectFromPairs.of([INDEX32, [LexActions.SHIFT, 62]]),
556-      ObjectFromPairs.of([INDEX34, [LexActions.SHIFT, 63]]),
557-      ObjectFromPairs.of([INDEX26, [LexActions.SHIFT, 64]]),
558-      ObjectFromPairs.of([INDEX28, [LexActions.SHIFT, 65]]),
559+      ObjectFromPairs.of([END_OF_STRING_RULE_INDEX, $Vo]),
560+      ObjectFromPairs.of([EXCLAMATION_POINT_RULE_INDEX, [LexActions.SHIFT, 62]]),
561+      ObjectFromPairs.of([PERCENT_SIGN_RULE_INDEX, [LexActions.SHIFT, 63]]),
562+      ObjectFromPairs.of([CLOSE_PAREN_RULE_INDEX, [LexActions.SHIFT, 64]]),
563+      ObjectFromPairs.of([LESS_THAN_SIGN_RULE_INDEX, [LexActions.SHIFT, 65]]),
564       ObjectFromPairs.of([37, [LexActions.SHIFT, 66]]),
565       extendRules($Vm, [LexActions.REDUCE, 7]),
566       extendRules([5, 12, 15, 30, 31], [LexActions.REDUCE, 8], ObjectFromPairs.of([
567@@ -773,10 +855,10 @@ let Parser = (function () {
568         MINUS_SIGN_RULE_INDEX, $Vl
569       ])),
570       extendRules($Vq, [LexActions.REDUCE, 9], ObjectFromPairs.of([
571-        INDEX11, $Vc,
572-        INDEX20, $Vj,
573-        INDEX21, $Vk,
574-        INDEX22, $Vl
575+        INTEGER_RULE_INDEX, $Vc,
576+        ASTERISK_RULE_INDEX, $Vj,
577+        FORWARD_SLASH_RULE_INDEX, $Vk,
578+        MINUS_SIGN_RULE_INDEX, $Vl
579       ])),
580       ObjectFromPairs.of([
581         SINGLE_QUOTES_RULE_INDEX, 13,
582@@ -1058,8 +1140,7 @@ let Parser = (function () {
583       }
584 
585       function lex() {
586-        let token;
587-        token = lexer.lex() || EOF;
588+        let token = lexer.lex() || EOF;
589         // if token isn't its numeric value, convert
590         if (typeof token !== 'number') {
591           token = self.symbols_[token] || token;
592@@ -1067,10 +1148,19 @@ let Parser = (function () {
593         return token;
594       }
595 
596-      let symbol, preErrorSymbol, state, action, r, yyval = {
597-        $: undefined,
598-        _$: undefined
599-      }, p, len, newState, expected;
600+      let symbol,
601+        preErrorSymbol,
602+        state,
603+        action,
604+        result,
605+        yyval = {
606+          $: undefined,
607+          _$: undefined
608+        },
609+        p,
610+        len,
611+        newState,
612+        expected;
613       while (true) {
614         // retrieve state number from top of stack
615         state = stack[stack.length - 1];
616@@ -1079,7 +1169,7 @@ let Parser = (function () {
617         if (this.defaultActions[state]) {
618           action = this.defaultActions[state];
619         } else {
620-          if (symbol === null || typeof symbol == 'undefined') {
621+          if (typeof symbol == 'undefined'|| symbol === null) {
622             symbol = lex();
623           }
624           // read action for current state and first input
625@@ -1177,7 +1267,7 @@ let Parser = (function () {
626 
627         // LexActions are always:
628         //   Shift: continue to process tokens.
629-        //   Reduce: enough tokens have been gathered for use to reduce input through evaluation.
630+        //   Reduce: enough tokens have been gathered to reduce input through evaluation.
631         //   Accept: return.
632         switch (action[0]) {
633           case LexActions.SHIFT: // Shift
634@@ -1216,10 +1306,10 @@ let Parser = (function () {
635             if (ranges) {
636               yyval._$.range = [locationStack[locationStack.length - (len || 1)].range[0], locationStack[locationStack.length - 1].range[1]];
637             }
638-            r = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], semanticValueStack, locationStack].concat(args));
639+            result = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], semanticValueStack, locationStack].concat(args));
640 
641-            if (typeof r !== 'undefined') {
642-              return r;
643+            if (typeof result !== 'undefined') {
644+              return result;
645             }
646 
647             // pop off stack
648@@ -1246,10 +1336,8 @@ let Parser = (function () {
649     }
650   };
651 
652-
653-  let lexer = (function () {
654-    let lexer = ({
655-
656+  parser.lexer = (function () {
657+    return ({
658       EOF: 1,
659 
660       parseError: function parseError(str, hash) {
661@@ -1313,23 +1401,23 @@ let Parser = (function () {
662         this.yytext = this.yytext.substr(0, this.yytext.length - len);
663         //this.yyleng -= len;
664         this.offset -= len;
665-        var oldLines = this.match.split(/(?:\r\n?|\n)/g);
666+        let oldLines = this.match.split(/(?:\r\n?|\n)/g);
667         this.match = this.match.substr(0, this.match.length - 1);
668         this.matched = this.matched.substr(0, this.matched.length - 1);
669 
670         if (lines.length - 1) {
671           this.yylineno -= lines.length - 1;
672         }
673-        var r = this.yylloc.range;
674+        let r = this.yylloc.range;
675 
676         this.yylloc = {
677           first_line: this.yylloc.first_line,
678           last_line: this.yylineno + 1,
679           first_column: this.yylloc.first_column,
680           last_column: lines ?
681-          (lines.length === oldLines.length ? this.yylloc.first_column : 0)
682-          + oldLines[oldLines.length - lines.length].length - lines[0].length :
683-          this.yylloc.first_column - len
684+            (lines.length === oldLines.length ? this.yylloc.first_column : 0)
685+            + oldLines[oldLines.length - lines.length].length - lines[0].length :
686+            this.yylloc.first_column - len
687         };
688 
689         if (this.options.ranges) {
690@@ -1367,13 +1455,13 @@ let Parser = (function () {
691 
692       // displays already matched input, i.e. for error messages
693       pastInput: function () {
694-        var past = this.matched.substr(0, this.matched.length - this.match.length);
695+        let past = this.matched.substr(0, this.matched.length - this.match.length);
696         return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, "");
697       },
698 
699       // displays upcoming input, i.e. for error messages
700       upcomingInput: function () {
701-        var next = this.match;
702+        let next = this.match;
703         if (next.length < 20) {
704           next += this._input.substr(0, 20 - next.length);
705         }
706@@ -1382,14 +1470,14 @@ let Parser = (function () {
707 
708       // displays the character position where the lexing error occurred, i.e. for error messages
709       showPosition: function () {
710-        var pre = this.pastInput();
711-        var c = new Array(pre.length + 1).join("-");
712+        let pre = this.pastInput();
713+        let c = new Array(pre.length + 1).join("-");
714         return pre + this.upcomingInput() + "\n" + c + "^";
715       },
716 
717       // test the lexed token: return FALSE when not a match, otherwise return token
718       test_match: function (match, indexed_rule) {
719-        var token,
720+        let token,
721           lines,
722           backup;
723 
724@@ -1429,8 +1517,8 @@ let Parser = (function () {
725           last_line: this.yylineno + 1,
726           first_column: this.yylloc.last_column,
727           last_column: lines ?
728-          lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
729-          this.yylloc.last_column + match[0].length
730+            lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
731+            this.yylloc.last_column + match[0].length
732         };
733         this.yytext += match[0];
734         this.match += match[0];
735@@ -1451,7 +1539,7 @@ let Parser = (function () {
736           return token;
737         } else if (this._backtrack) {
738           // recover context
739-          for (var k in backup) {
740+          for (let k in backup) {
741             this[k] = backup[k];
742           }
743           return false; // rule action called reject() implying the next rule should be tested instead.
744@@ -1468,7 +1556,7 @@ let Parser = (function () {
745           this.done = true;
746         }
747 
748-        var token,
749+        let token,
750           match,
751           tempMatch,
752           index;
753@@ -1476,8 +1564,8 @@ let Parser = (function () {
754           this.yytext = '';
755           this.match = '';
756         }
757-        var rules = this._currentRules();
758-        for (var i = 0; i < rules.length; i++) {
759+        let rules = this._currentRules();
760+        for (let i = 0; i < rules.length; i++) {
761           tempMatch = this._input.match(this.rules[rules[i]]);
762           if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
763             match = tempMatch;
764@@ -1488,7 +1576,8 @@ let Parser = (function () {
765                 return token;
766               } else if (this._backtrack) {
767                 match = false;
768-                continue; // rule action called reject() implying a rule mis-match.
769+                // rule action called reject() implying a rule mis-match.
770+                // implied `continue`
771               } else {
772                 // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
773                 return false;
774@@ -1519,7 +1608,7 @@ let Parser = (function () {
775 
776       // return next match that has a token
777       lex: function lex() {
778-        var r = this.next();
779+        let r = this.next();
780         if (r) {
781           return r;
782         } else {
783@@ -1534,7 +1623,7 @@ let Parser = (function () {
784 
785       // pop the previously active lexer condition state off the condition stack
786       popState: function popState() {
787-        var n = this.conditionStack.length - 1;
788+        let n = this.conditionStack.length - 1;
789         if (n > 0) {
790           return this.conditionStack.pop();
791         } else {
792@@ -1570,8 +1659,12 @@ let Parser = (function () {
793       stateStackSize: function stateStackSize() {
794         return this.conditionStack.length;
795       },
796-      options: {},
797-      performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
798+      options: {
799+        // backtrack_lexer?
800+        // ranges?
801+        // flex?
802+      },
803+      performAction: function anonymous(yy, yy_, $avoiding_name_collisions) {
804         switch ($avoiding_name_collisions) {
805           case 0:
806             // skip whitespace
807@@ -1604,7 +1697,8 @@ let Parser = (function () {
808             return 34;
809           case 12:
810             return 29;
811-          case 13:/* skip whitespace */
812+          case 13:
813+            // skip whitespace
814             break;
815           case 14:
816             return 11;
817@@ -1701,9 +1795,7 @@ let Parser = (function () {
818         }
819       }
820     });
821-    return lexer;
822   })();
823-  parser.lexer = lexer;
824   function Parser() {
825     this.yy = {};
826   }
827diff --git a/src/Parser/Rules.ts b/src/Parser/Rules.ts
828index f71ad41..99ca32e 100644
829--- a/src/Parser/Rules.ts
830+++ b/src/Parser/Rules.ts
831@@ -120,45 +120,6 @@ const PERCENT_SIGN_RULE_INDEX = RULES.indexOf(PERCENT_SIGN_RULE);
832 const HASH_SIGN_RULE_INDEX = RULES.indexOf(HASH_SIGN_RULE);
833 const END_OF_STRING_RULE_INDEX = RULES.indexOf(END_OF_STRING_RULE);
834 
835-
836-const INDEX0 = RULES.indexOf(WHITE_SPACE_RULE);
837-const INDEX1 = RULES.indexOf(DOUBLE_QUOTES_RULE);
838-const INDEX2 = RULES.indexOf(SINGLE_QUOTES_RULE);
839-const INDEX3 = RULES.indexOf(FORMULA_NAME_RULE);
840-const INDEX4 = RULES.indexOf(DATE_RULE);
841-const INDEX5 = RULES.indexOf(TIME_RULE);
842-const INDEX6 = RULES.indexOf($_A1_CELL_RULE);
843-const INDEX7 = RULES.indexOf(A1_CELL_RULE);
844-const INDEX8 = RULES.indexOf(FORMULA_NAME_SIMPLE_RULE);
845-const INDEX9 = RULES.indexOf(VARIABLE_RULE);
846-const INDEX10 = RULES.indexOf(SIMPLE_VARIABLE_RILE);
847-const INDEX11 = RULES.indexOf(INTEGER_RULE);
848-const INDEX12 = RULES.indexOf(OPEN_AND_CLOSE_OF_ARRAY_RULE);
849-const INDEX13 = RULES.indexOf(DOLLAR_SIGN_RULE);
850-const INDEX14 = RULES.indexOf(AMPERSAND_SIGN_RULE);
851-const INDEX15 = RULES.indexOf(SINGLE_WHITESPACE_RULE);
852-const INDEX16 = RULES.indexOf(PERIOD_RULE);
853-const INDEX17 = RULES.indexOf(COLON_RULE);
854-const INDEX18 = RULES.indexOf(SEMI_COLON_RULE);
855-const INDEX19 = RULES.indexOf(COMMA_RULE);
856-const INDEX20 = RULES.indexOf(ASTERISK_RULE);
857-const INDEX21 = RULES.indexOf(FORWARD_SLASH_RULE);
858-const INDEX22 = RULES.indexOf(MINUS_SIGN_RULE);
859-const INDEX23 = RULES.indexOf(PLUS_SIGN_RULE);
860-const INDEX24 = RULES.indexOf(CARET_SIGN_RULE);
861-const INDEX25 = RULES.indexOf(OPEN_PAREN_RULE);
862-const INDEX26 = RULES.indexOf(CLOSE_PAREN_RULE);
863-const INDEX27 = RULES.indexOf(GREATER_THAN_SIGN_RULE);
864-const INDEX28 = RULES.indexOf(LESS_THAN_SIGN_RULE);
865-const INDEX29 = RULES.indexOf(NOT_RULE);
866-const INDEX30 = RULES.indexOf(OPEN_DOUBLE_QUOTE);
867-const INDEX31 = RULES.indexOf(OPEN_SINGLE_QUITE);
868-const INDEX32 = RULES.indexOf(EXCLAMATION_POINT_RULE);
869-const INDEX33 = RULES.indexOf(EQUALS_SIGN_RULE);
870-const INDEX34 = RULES.indexOf(PERCENT_SIGN_RULE);
871-const INDEX35 = RULES.indexOf(HASH_SIGN_RULE);
872-const INDEX36 = RULES.indexOf(END_OF_STRING_RULE);
873-
874 export {
875   RULES,
876 
877@@ -199,42 +160,4 @@ export {
878   PERCENT_SIGN_RULE_INDEX,
879   HASH_SIGN_RULE_INDEX,
880   END_OF_STRING_RULE_INDEX,
881-
882-  INDEX0,
883-  INDEX1,
884-  INDEX2,
885-  INDEX3,
886-  INDEX4,
887-  INDEX5,
888-  INDEX6,
889-  INDEX7,
890-  INDEX8,
891-  INDEX9,
892-  INDEX10,
893-  INDEX11,
894-  INDEX12,
895-  INDEX13,
896-  INDEX14,
897-  INDEX15,
898-  INDEX16,
899-  INDEX17,
900-  INDEX18,
901-  INDEX19,
902-  INDEX20,
903-  INDEX21,
904-  INDEX22,
905-  INDEX23,
906-  INDEX24,
907-  INDEX25,
908-  INDEX26,
909-  INDEX27,
910-  INDEX28,
911-  INDEX29,
912-  INDEX30,
913-  INDEX31,
914-  INDEX32,
915-  INDEX33,
916-  INDEX34,
917-  INDEX35,
918-  INDEX36
919 }
920\ No newline at end of file