spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[ParserConstants] even more state enumeration
author
Ben Vogt <[email protected]>
date
2017-12-20 04:25:22
stats
5 file(s) changed, 324 insertions(+), 319 deletions(-)
files
src/Parser/Parser.ts
src/Parser/ParserConstants.ts
src/Sheet.ts
tests.sh
tests/SheetBasicTests.ts
  1diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
  2index bc0aefc..e427509 100644
  3--- a/src/Parser/Parser.ts
  4+++ b/src/Parser/Parser.ts
  5@@ -131,16 +131,16 @@ let Parser = (function () {
  6             this.$ = sharedStateYY.handler.callFunction.call(this, virtualStack[vsl - 3], virtualStack[vsl - 1]);
  7             break;
  8           case ReduceActions.FIXED_CELL_VAL:
  9-            this.$ = sharedStateYY.handler.fixedCellValue(sharedStateYY.obj, virtualStack[vsl]);
 10+            this.$ = sharedStateYY.handler.fixedCellValue(sharedStateYY.originCellId, virtualStack[vsl]);
 11             break;
 12           case ReduceActions.FIXED_CELL_RANGE_VAL:
 13-            this.$ = sharedStateYY.handler.fixedCellRangeValue(sharedStateYY.obj, virtualStack[vsl - 2], virtualStack[vsl]);
 14+            this.$ = sharedStateYY.handler.fixedCellRangeValue(sharedStateYY.originCellId, virtualStack[vsl - 2], virtualStack[vsl]);
 15             break;
 16           case ReduceActions.CELL_VALUE:
 17-            this.$ = sharedStateYY.handler.cellValue(sharedStateYY.obj, virtualStack[vsl]);
 18+            this.$ = sharedStateYY.handler.cellValue(sharedStateYY.originCellId, virtualStack[vsl]);
 19             break;
 20           case ReduceActions.CELL_RANGE_VALUE:
 21-            this.$ = sharedStateYY.handler.cellRangeValue(sharedStateYY.obj, virtualStack[vsl - 2], virtualStack[vsl]);
 22+            this.$ = sharedStateYY.handler.cellRangeValue(sharedStateYY.originCellId, virtualStack[vsl - 2], virtualStack[vsl]);
 23             break;
 24           case ReduceActions.ENSURE_IS_ARRAY:
 25             if (isArray(virtualStack[vsl])) {
 26@@ -671,26 +671,6 @@ let Parser = (function () {
 27         return this;
 28       },
 29 
 30-      // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
 31-      reject: function () {
 32-        if (this.options.backtrack_lexer) {
 33-          this._backtrack = true;
 34-        } else {
 35-          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(), {
 36-            text: "",
 37-            token: null,
 38-            line: this.yylineno
 39-          });
 40-
 41-        }
 42-        return this;
 43-      },
 44-
 45-      // retain first n characters of the match
 46-      less: function (n) {
 47-        this.unput(this.match.slice(n));
 48-      },
 49-
 50       // displays already matched input, i.e. for error messages
 51       pastInput: function () {
 52         let past = this.matched.substr(0, this.matched.length - this.match.length);
 53@@ -999,8 +979,8 @@ let Parser = (function () {
 54 /**
 55  * Creates a new FormulaParser, which parses formulas, and does minimal error handling.
 56  *
 57- * @param handler should be this instance. Needs access to helper.fixedCellValue, helper.cellValue,
 58- * helper.cellRangeValue, and helper.fixedCellRangeValue
 59+ * @param handler should be a Sheet, since the parser needs access to fixedCellValue, cellValue, cellRangeValue, and
 60+ * fixedCellRangeValue
 61  * @returns formula parser instance for use with parser.js
 62  * @constructor
 63  */
 64diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
 65index c2a6abb..b319c65 100644
 66--- a/src/Parser/ParserConstants.ts
 67+++ b/src/Parser/ParserConstants.ts
 68@@ -352,9 +352,22 @@ const SYMBOL_INDEX_TO_NAME = symbolIndexToName;
 69 
 70 const enum State {
 71   START = 0,
 72+  FOLLOW_EXPRESSIONS = 1,
 73+  FOLLOW_EXPRESSION = 2,
 74+  FOLLOW_VARIABLE_SEQUENCE = 3,
 75   START_NUMBER = 6,
 76   START_STRING = 7,
 77   LEFT_PAREN = 8,
 78+  PREFIX_UNARY_MINUS = 9,
 79+  PREFIX_UNARY_PLUS = 10,
 80+  FUNCTION = 11,
 81+  FOLLOWS_CELL = 12,
 82+  ERROR = 13,
 83+  FOLLOW_VARIABLE = 14,
 84+  FOLLOW_NUMBER_UPPER = 15,
 85+  FIXED_CELL = 16,
 86+  FOLLOW_CELL_UPPER = 17,
 87+  FOLLOW_POUND = 18,
 88   EOF_AND_RETURN_LAST = 19,
 89   NUMBER_FOLLOWED_BY_AMPERSAND = 20,
 90   START_EQUALS = 21,
 91@@ -365,9 +378,20 @@ const enum State {
 92   NUMBER_FOLLOWED_BY_ASTERISK = 27,
 93   NUMBER_FOLLOWED_BY_SLASH = 28,
 94   NUMBER_FOLLOWED_BY_CARROT = 29,
 95+  EXPRESSION_FOLLOWING_LEFT_PAREN = 32,
 96+  EXPRESSION_FOLLOWING_PREFIX_UNARY_MINUS = 33,
 97+  EXPRESSION_FOLLOWING_PREFIX_UNARY_PLUS = 34,
 98+  FOLLOW_FUNCTION_THEN_LEFT_PAREN = 35,
 99+  FOLLOW_ERROR_ERROR = 36,
100+  FOLLOW_POUND_VARIABLE = 42,
101+  NUMBER_AMPERSAND_EXPRESSION = 43,
102+  START_EQUALS_EXPRESSION = 44,
103   ADD_TWO_NUMBERS = 45,
104   LESS_THAN_EQUALS = 46,
105+  LESSTHAN_GREATERTHAN = 47,
106+  LESSTHAN_EXPRESSION = 48,
107   GREATER_THAN_EQUALS = 49,
108+  GREATERTHAN_EXPRESSION = 50,
109   SUBTRACT_TWO_NUMBERS = 52,
110   MULTIPLY_TWO_NUMBERS = 53,
111   DIVIDE_TWO_NUMBERS = 54,
112@@ -388,27 +412,27 @@ const enum State {
113 let table = [];
114 // All functions in the spreadsheet start with a 0-token.
115 table[State.START] = ObjectBuilder
116-  .add(Symbol.ERROR, 13)
117-  .add(Symbol.EXPRESSIONS, 1)
118-  .add(Symbol.EXPRESSION, 2)
119-  .add(Symbol.VARIABLE_SEQUENCE, 3)
120+  .add(Symbol.ERROR, State.ERROR)
121+  .add(Symbol.EXPRESSIONS, State.FOLLOW_EXPRESSIONS)
122+  .add(Symbol.EXPRESSION, State.FOLLOW_EXPRESSION)
123+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
124   .add(Symbol.NUMBER, State.START_NUMBER)
125   .add(Symbol.STRING, [SHIFT, State.START_STRING])
126-  .add(Symbol.PLUS, [SHIFT, 10])
127+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
128   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
129-  .add(Symbol.MINUS, [SHIFT, 9])
130-  .add(Symbol.FUNCTION, [SHIFT, 11])
131-  .add(Symbol.CELL, 12)
132-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
133-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
134-  .add(Symbol.VARIABLE, [SHIFT, 14])
135-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
136-  .add(Symbol.POUND, [SHIFT, 18])
137-  .build();
138-table[1] = ObjectBuilder
139+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
140+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
141+  .add(Symbol.CELL, State.FOLLOWS_CELL)
142+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
143+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
144+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
145+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
146+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
147+  .build();
148+table[State.FOLLOW_EXPRESSIONS] = ObjectBuilder
149   .add(Symbol.END, [ACCEPT])
150   .build();
151-table[2] = ObjectBuilder
152+table[State.FOLLOW_EXPRESSION] = ObjectBuilder
153   .add(Symbol.EOF, [SHIFT, State.EOF_AND_RETURN_LAST])
154   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
155   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
156@@ -420,7 +444,7 @@ table[2] = ObjectBuilder
157   .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
158   .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
159   .build();
160-table[3] = ObjectBuilder
161+table[State.FOLLOW_VARIABLE_SEQUENCE] = ObjectBuilder
162   .add(Symbol.EOF, [REDUCE, ReduceActions.CALL_VARIABLE])
163   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.CALL_VARIABLE])
164   .add(Symbol.EQUALS, [REDUCE, ReduceActions.CALL_VARIABLE])
165@@ -468,60 +492,60 @@ table[State.START_STRING] = ObjectBuilder
166   .add(Symbol.COMMA, [REDUCE, ReduceActions.AS_STRING])
167   .build();
168 table[State.LEFT_PAREN] = ObjectBuilder
169-  .add(Symbol.ERROR, 13)
170-  .add(Symbol.EXPRESSION, 32)
171-  .add(Symbol.VARIABLE_SEQUENCE, 3)
172+  .add(Symbol.ERROR, State.ERROR)
173+  .add(Symbol.EXPRESSION, State.EXPRESSION_FOLLOWING_LEFT_PAREN)
174+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
175   .add(Symbol.NUMBER, State.START_NUMBER)
176   .add(Symbol.STRING, [SHIFT, State.START_STRING])
177-  .add(Symbol.PLUS, [SHIFT, 10])
178+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
179   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
180-  .add(Symbol.MINUS, [SHIFT, 9])
181-  .add(Symbol.FUNCTION, [SHIFT, 11])
182-  .add(Symbol.CELL, 12)
183-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
184-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
185-  .add(Symbol.VARIABLE, [SHIFT, 14])
186-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
187-  .add(Symbol.POUND, [SHIFT, 18])
188-  .build();
189-table[9] = ObjectBuilder
190-  .add(Symbol.ERROR, 13)
191-  .add(Symbol.EXPRESSION, 33)
192-  .add(Symbol.VARIABLE_SEQUENCE, 3)
193+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
194+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
195+  .add(Symbol.CELL, State.FOLLOWS_CELL)
196+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
197+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
198+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
199+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
200+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
201+  .build();
202+table[State.PREFIX_UNARY_MINUS] = ObjectBuilder
203+  .add(Symbol.ERROR, State.ERROR)
204+  .add(Symbol.EXPRESSION, State.EXPRESSION_FOLLOWING_PREFIX_UNARY_MINUS)
205+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
206   .add(Symbol.NUMBER, State.START_NUMBER)
207   .add(Symbol.STRING, [SHIFT, State.START_STRING])
208-  .add(Symbol.PLUS, [SHIFT, 10])
209+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
210   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
211-  .add(Symbol.MINUS, [SHIFT, 9])
212-  .add(Symbol.FUNCTION, [SHIFT, 11])
213-  .add(Symbol.CELL, 12)
214-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
215-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
216-  .add(Symbol.VARIABLE, [SHIFT, 14])
217-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
218-  .add(Symbol.POUND, [SHIFT, 18])
219-  .build();
220-table[10] = ObjectBuilder
221-  .add(Symbol.ERROR, 13)
222-  .add(Symbol.EXPRESSION, 34)
223-  .add(Symbol.VARIABLE_SEQUENCE, 3)
224+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
225+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
226+  .add(Symbol.CELL, State.FOLLOWS_CELL)
227+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
228+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
229+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
230+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
231+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
232+  .build();
233+table[State.PREFIX_UNARY_PLUS] = ObjectBuilder
234+  .add(Symbol.ERROR, State.ERROR)
235+  .add(Symbol.EXPRESSION, State.EXPRESSION_FOLLOWING_PREFIX_UNARY_PLUS)
236+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
237   .add(Symbol.NUMBER, State.START_NUMBER)
238   .add(Symbol.STRING, [SHIFT, State.START_STRING])
239-  .add(Symbol.PLUS, [SHIFT, 10])
240+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
241   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
242-  .add(Symbol.MINUS, [SHIFT, 9])
243-  .add(Symbol.FUNCTION, [SHIFT, 11])
244-  .add(Symbol.CELL, 12)
245-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
246-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
247-  .add(Symbol.VARIABLE, [SHIFT, 14])
248-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
249-  .add(Symbol.POUND, [SHIFT, 18])
250-  .build();
251-table[11] = ObjectBuilder
252-  .add(Symbol.LEFT_PAREN, [SHIFT, 35])
253-  .build();
254-table[12] = ObjectBuilder
255+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
256+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
257+  .add(Symbol.CELL, State.FOLLOWS_CELL)
258+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
259+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
260+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
261+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
262+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
263+  .build();
264+table[State.FUNCTION] = ObjectBuilder
265+  .add(Symbol.LEFT_PAREN, [SHIFT, State.FOLLOW_FUNCTION_THEN_LEFT_PAREN])
266+  .build();
267+table[State.FOLLOWS_CELL] = ObjectBuilder
268   .add(Symbol.EOF, [REDUCE, ReduceActions.I25])
269   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.I25])
270   .add(Symbol.EQUALS, [REDUCE, ReduceActions.I25])
271@@ -536,8 +560,8 @@ table[12] = ObjectBuilder
272   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.I25])
273   .add(Symbol.COMMA, [REDUCE, ReduceActions.I25])
274   .build();
275-table[13] = ObjectBuilder
276-  .add(Symbol.ERROR, 36)
277+table[State.ERROR] = ObjectBuilder
278+  .add(Symbol.ERROR, State.FOLLOW_ERROR_ERROR)
279   .add(Symbol.EOF, [REDUCE, ReduceActions.I26])
280   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.I26])
281   .add(Symbol.EQUALS, [REDUCE, ReduceActions.I26])
282@@ -554,7 +578,7 @@ table[13] = ObjectBuilder
283   .add(Symbol.VARIABLE, [SHIFT, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
284   .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
285   .build();
286-table[14] = ObjectBuilder
287+table[State.FOLLOW_VARIABLE] = ObjectBuilder
288   .add(Symbol.EOF, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
289   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
290   .add(Symbol.EQUALS, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
291@@ -568,10 +592,10 @@ table[14] = ObjectBuilder
292   .add(Symbol.CARROT, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
293   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
294   .add(Symbol.COMMA, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
295-  .add(33, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
296+  .add(Symbol.DECIMAL, [REDUCE, ReduceActions.WRAP_CURRENT_INDEX_TOKEN_AS_ARRAY])
297   .add(Symbol.POUND, [SHIFT, ReduceActions.REFLEXIVE_REDUCE])
298   .build();
299-table[15] = ObjectBuilder
300+table[State.FOLLOW_NUMBER_UPPER] = ObjectBuilder
301   .add(Symbol.EOF, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
302   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
303   .add(Symbol.EQUALS, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
304@@ -585,11 +609,11 @@ table[15] = ObjectBuilder
305   .add(Symbol.CARROT, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
306   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
307   .add(Symbol.COMMA, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
308-  .add(33, [SHIFT, ReduceActions.REDUCE_FLOAT])
309+  .add(Symbol.DECIMAL, [SHIFT, ReduceActions.REDUCE_FLOAT])
310   .add(Symbol.PERCENT, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
311   .add(38, [REDUCE, ReduceActions.REFLEXIVE_REDUCE])
312   .build();
313-table[16] = ObjectBuilder
314+table[State.FIXED_CELL] = ObjectBuilder
315   .add(Symbol.EOF, [REDUCE, ReduceActions.FIXED_CELL_VAL])
316   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.FIXED_CELL_VAL])
317   .add(Symbol.EQUALS, [REDUCE, ReduceActions.FIXED_CELL_VAL])
318@@ -605,7 +629,7 @@ table[16] = ObjectBuilder
319   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.FIXED_CELL_VAL])
320   .add(Symbol.COMMA, [REDUCE, ReduceActions.FIXED_CELL_VAL])
321   .build();
322-table[17] = ObjectBuilder
323+table[State.FOLLOW_CELL_UPPER] = ObjectBuilder
324   .add(Symbol.EOF, [REDUCE, ReduceActions.CELL_VALUE])
325   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.CELL_VALUE])
326   .add(Symbol.EQUALS, [REDUCE, ReduceActions.CELL_VALUE])
327@@ -621,8 +645,8 @@ table[17] = ObjectBuilder
328   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.CELL_VALUE])
329   .add(Symbol.COMMA, [REDUCE, ReduceActions.CELL_VALUE])
330   .build();
331-table[18] = ObjectBuilder
332-  .add(Symbol.VARIABLE, [SHIFT, 42])
333+table[State.FOLLOW_POUND] = ObjectBuilder
334+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_POUND_VARIABLE])
335   .add(Symbol.EOF, [REDUCE, ReduceActions.AS_ERROR])
336   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.AS_ERROR])
337   .add(Symbol.COMMA, [REDUCE, ReduceActions.AS_ERROR])
338@@ -631,177 +655,177 @@ table[State.EOF_AND_RETURN_LAST] = ObjectBuilder
339   .add(Symbol.END, [REDUCE, ReduceActions.RETURN_LAST])
340   .build();
341 table[State.NUMBER_FOLLOWED_BY_AMPERSAND] = ObjectBuilder
342-  .add(Symbol.ERROR, 13)
343-  .add(Symbol.EXPRESSION, 43)
344-  .add(Symbol.VARIABLE_SEQUENCE, 3)
345+  .add(Symbol.ERROR, State.ERROR)
346+  .add(Symbol.EXPRESSION, State.NUMBER_AMPERSAND_EXPRESSION)
347+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
348   .add(Symbol.NUMBER, State.START_NUMBER)
349   .add(Symbol.STRING, [SHIFT, State.START_STRING])
350-  .add(Symbol.PLUS, [SHIFT, 10])
351+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
352   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
353-  .add(Symbol.MINUS, [SHIFT, 9])
354-  .add(Symbol.FUNCTION, [SHIFT, 11])
355-  .add(Symbol.CELL, 12)
356-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
357-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
358-  .add(Symbol.VARIABLE, [SHIFT, 14])
359-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
360+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
361+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
362+  .add(Symbol.CELL, State.FOLLOWS_CELL)
363+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
364+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
365+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
366+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
367   .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
368   .build();
369 table[State.START_EQUALS] = ObjectBuilder
370-  .add(Symbol.ERROR, 13)
371-  .add(Symbol.EXPRESSION, 44)
372-  .add(Symbol.VARIABLE_SEQUENCE, 3)
373+  .add(Symbol.ERROR, State.ERROR)
374+  .add(Symbol.EXPRESSION, State.START_EQUALS_EXPRESSION)
375+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
376   .add(Symbol.NUMBER, State.START_NUMBER)
377   .add(Symbol.STRING, [SHIFT, State.START_STRING])
378-  .add(Symbol.PLUS, [SHIFT, 10])
379+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
380   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
381-  .add(Symbol.MINUS, [SHIFT, 9])
382-  .add(Symbol.FUNCTION, [SHIFT, 1])
383-  .add(Symbol.CELL, 12)
384-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
385-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
386-  .add(Symbol.VARIABLE, [SHIFT, 14])
387-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
388-  .add(Symbol.POUND, [SHIFT, 18])
389+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
390+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
391+  .add(Symbol.CELL, State.FOLLOWS_CELL)
392+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
393+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
394+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
395+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
396+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
397   .build();
398 table[State.NUMBER_FOLLOWED_BY_PLUS] = ObjectBuilder
399-  .add(Symbol.ERROR, 13)
400-  .add(Symbol.EXPRESSION, 45)
401-  .add(Symbol.VARIABLE_SEQUENCE, 3)
402+  .add(Symbol.ERROR, State.ERROR)
403+  .add(Symbol.EXPRESSION, State.ADD_TWO_NUMBERS)
404+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
405   .add(Symbol.NUMBER, State.START_NUMBER)
406   .add(Symbol.STRING, [SHIFT, State.START_STRING])
407-  .add(Symbol.PLUS, [SHIFT, 10])
408+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
409   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
410-  .add(Symbol.MINUS, [SHIFT, 9])
411-  .add(Symbol.FUNCTION, [SHIFT, 11])
412-  .add(Symbol.CELL, 12)
413-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
414-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
415-  .add(Symbol.VARIABLE, [SHIFT, 14])
416-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
417-  .add(Symbol.POUND, [SHIFT, 18])
418+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
419+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
420+  .add(Symbol.CELL, State.FOLLOWS_CELL)
421+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
422+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
423+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
424+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
425+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
426   .build();
427 table[State.LESS_THAN] = ObjectBuilder
428-  .add(Symbol.ERROR, 13)
429-  .add(Symbol.EXPRESSION, 48)
430-  .add(Symbol.VARIABLE_SEQUENCE, 3)
431+  .add(Symbol.ERROR, State.ERROR)
432+  .add(Symbol.EXPRESSION, State.LESSTHAN_EXPRESSION)
433+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
434   .add(Symbol.NUMBER, State.START_NUMBER)
435   .add(Symbol.STRING, [SHIFT, State.START_STRING])
436   .add(Symbol.EQUALS, [SHIFT, State.LESS_THAN_EQUALS])
437-  .add(Symbol.PLUS, [SHIFT, 10])
438+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
439   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
440-  .add(Symbol.GREATER_THAN, [SHIFT, 47])
441-  .add(Symbol.MINUS, [SHIFT, 9])
442-  .add(Symbol.FUNCTION, [SHIFT, 11])
443-  .add(Symbol.CELL, 12)
444-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
445-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
446-  .add(Symbol.VARIABLE, [SHIFT, 14])
447-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
448-  .add(Symbol.POUND, [SHIFT, 18])
449+  .add(Symbol.GREATER_THAN, [SHIFT, State.LESSTHAN_GREATERTHAN])
450+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
451+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
452+  .add(Symbol.CELL, State.FOLLOWS_CELL)
453+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
454+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
455+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
456+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
457+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
458   .build();
459 table[State.GREATER_THAN] = ObjectBuilder
460-  .add(Symbol.ERROR, 13)
461-  .add(Symbol.EXPRESSION, 50)
462-  .add(Symbol.VARIABLE_SEQUENCE, 3)
463+  .add(Symbol.ERROR, State.ERROR)
464+  .add(Symbol.EXPRESSION, State.GREATERTHAN_EXPRESSION)
465+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
466   .add(Symbol.NUMBER, State.START_NUMBER)
467   .add(Symbol.STRING, [SHIFT, State.START_STRING])
468   .add(Symbol.EQUALS, [SHIFT, State.GREATER_THAN_EQUALS])
469-  .add(Symbol.PLUS, [SHIFT, 10])
470+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
471   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
472-  .add(Symbol.MINUS, [SHIFT, 9])
473-  .add(Symbol.FUNCTION, [SHIFT, 11])
474-  .add(Symbol.CELL, 12)
475-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
476-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
477-  .add(Symbol.VARIABLE, [SHIFT, 14])
478-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
479-  .add(Symbol.POUND, [SHIFT, 18])
480+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
481+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
482+  .add(Symbol.CELL, State.FOLLOWS_CELL)
483+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
484+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
485+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
486+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
487+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
488   .build();
489 table[25] = ObjectBuilder
490-  .add(Symbol.ERROR, 13)
491+  .add(Symbol.ERROR, State.ERROR)
492   .add(Symbol.EXPRESSION, 51)
493-  .add(Symbol.VARIABLE_SEQUENCE, 3)
494+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
495   .add(Symbol.NUMBER, State.START_NUMBER)
496   .add(Symbol.STRING, [SHIFT, State.START_STRING])
497-  .add(Symbol.PLUS, [SHIFT, 10])
498+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
499   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
500-  .add(Symbol.MINUS, [SHIFT, 9])
501-  .add(Symbol.FUNCTION, [SHIFT, 11])
502-  .add(Symbol.CELL, 12)
503-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
504-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
505-  .add(Symbol.VARIABLE, [SHIFT, 14])
506-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
507-  .add(Symbol.POUND, [SHIFT, 18])
508+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
509+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
510+  .add(Symbol.CELL, State.FOLLOWS_CELL)
511+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
512+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
513+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
514+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
515+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
516   .build();
517 table[State.NUMBER_FOLLOWED_BY_MINUS] = ObjectBuilder
518-  .add(Symbol.ERROR, 13)
519+  .add(Symbol.ERROR, State.ERROR)
520   .add(Symbol.EXPRESSION, State.SUBTRACT_TWO_NUMBERS)
521-  .add(Symbol.VARIABLE_SEQUENCE, 3)
522+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
523   .add(Symbol.NUMBER, State.START_NUMBER)
524   .add(Symbol.STRING, [SHIFT, State.START_STRING])
525-  .add(Symbol.PLUS, [SHIFT, 10])
526+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
527   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
528-  .add(Symbol.MINUS, [SHIFT, 9])
529-  .add(Symbol.FUNCTION, [SHIFT, 11])
530-  .add(Symbol.CELL, 12)
531-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
532-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
533-  .add(Symbol.VARIABLE, [SHIFT, 14])
534-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
535-  .add(Symbol.POUND, [SHIFT, 18])
536+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
537+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
538+  .add(Symbol.CELL, State.FOLLOWS_CELL)
539+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
540+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
541+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
542+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
543+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
544   .build();
545 table[State.NUMBER_FOLLOWED_BY_ASTERISK] = ObjectBuilder
546-  .add(Symbol.ERROR, 13)
547+  .add(Symbol.ERROR, State.ERROR)
548   .add(Symbol.EXPRESSION, State.MULTIPLY_TWO_NUMBERS)
549-  .add(Symbol.VARIABLE_SEQUENCE, 3)
550+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
551   .add(Symbol.NUMBER, State.START_NUMBER)
552   .add(Symbol.STRING, [SHIFT, State.START_STRING])
553-  .add(Symbol.PLUS, [SHIFT, 10])
554+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
555   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
556-  .add(Symbol.MINUS, [SHIFT, 9])
557-  .add(Symbol.FUNCTION, [SHIFT, 11])
558-  .add(Symbol.CELL, 12)
559-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
560-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
561-  .add(Symbol.VARIABLE, [SHIFT, 14])
562-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
563-  .add(Symbol.POUND, [SHIFT, 18])
564+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
565+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
566+  .add(Symbol.CELL, State.FOLLOWS_CELL)
567+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
568+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
569+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
570+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
571+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
572   .build();
573 table[State.NUMBER_FOLLOWED_BY_SLASH] = ObjectBuilder
574-  .add(Symbol.ERROR, 13)
575+  .add(Symbol.ERROR, State.ERROR)
576   .add(Symbol.EXPRESSION, State.DIVIDE_TWO_NUMBERS)
577-  .add(Symbol.VARIABLE_SEQUENCE, 3)
578+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
579   .add(Symbol.NUMBER, State.START_NUMBER)
580   .add(Symbol.STRING, [SHIFT, State.START_STRING])
581-  .add(Symbol.PLUS, [SHIFT, 10])
582+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
583   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
584-  .add(Symbol.MINUS, [SHIFT, 9])
585-  .add(Symbol.FUNCTION, [SHIFT, 11])
586-  .add(Symbol.CELL, 12)
587-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
588-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
589-  .add(Symbol.VARIABLE, [SHIFT, 14])
590-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
591-  .add(Symbol.POUND, [SHIFT, 18])
592+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
593+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
594+  .add(Symbol.CELL, State.FOLLOWS_CELL)
595+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
596+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
597+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
598+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
599+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
600   .build();
601 table[State.NUMBER_FOLLOWED_BY_CARROT] = ObjectBuilder
602-  .add(Symbol.ERROR, 13)
603+  .add(Symbol.ERROR, State.ERROR)
604   .add(Symbol.EXPRESSION, State.NUMBER_TO_POWER_OF_OTHER)
605-  .add(Symbol.VARIABLE_SEQUENCE, 3)
606+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
607   .add(Symbol.NUMBER, State.START_NUMBER)
608   .add(Symbol.STRING, [SHIFT, State.START_STRING])
609-  .add(Symbol.PLUS, [SHIFT, 10])
610+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
611   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
612-  .add(Symbol.MINUS, [SHIFT, 9])
613-  .add(Symbol.FUNCTION, [SHIFT, 11])
614-  .add(Symbol.CELL, 12)
615-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
616-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
617-  .add(Symbol.VARIABLE, [SHIFT, 14])
618-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
619-  .add(Symbol.POUND, [SHIFT, 18])
620+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
621+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
622+  .add(Symbol.CELL, State.FOLLOWS_CELL)
623+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
624+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
625+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
626+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
627+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
628   .build();
629 table[ReduceActions.CELL_VALUE] = ObjectBuilder
630   .add(Symbol.VARIABLE, [SHIFT, 56])
631@@ -823,7 +847,7 @@ table[31] = ObjectBuilder
632   .add(Symbol.PERCENT, [REDUCE, ReduceActions.REDUCE_PREV_AS_PERCENT])
633   .add(38, [REDUCE, ReduceActions.REDUCE_PREV_AS_PERCENT])
634   .build();
635-table[32] = ObjectBuilder
636+table[State.EXPRESSION_FOLLOWING_LEFT_PAREN] = ObjectBuilder
637   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
638   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
639   .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
640@@ -835,7 +859,7 @@ table[32] = ObjectBuilder
641   .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
642   .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
643   .build();
644-table[33] = ObjectBuilder
645+table[State.EXPRESSION_FOLLOWING_PREFIX_UNARY_MINUS] = ObjectBuilder
646   .add(Symbol.EOF, [REDUCE, ReduceActions.INVERT_NUM])
647   .add(Symbol.AMPERSAND, [SHIFT, ReduceActions.TO_POWER])
648   .add(Symbol.EQUALS, [REDUCE, ReduceActions.INVERT_NUM])
649@@ -850,7 +874,7 @@ table[33] = ObjectBuilder
650   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.INVERT_NUM])
651   .add(Symbol.COMMA, [REDUCE, ReduceActions.INVERT_NUM])
652   .build();
653-table[34] = ObjectBuilder
654+table[State.EXPRESSION_FOLLOWING_PREFIX_UNARY_PLUS] = ObjectBuilder
655   .add(Symbol.EOF, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
656   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
657   .add(Symbol.EQUALS, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
658@@ -865,27 +889,27 @@ table[34] = ObjectBuilder
659   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
660   .add(Symbol.COMMA, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
661   .build();
662-table[35] = ObjectBuilder
663-  .add(Symbol.ERROR, 13)
664+table[State.FOLLOW_FUNCTION_THEN_LEFT_PAREN] = ObjectBuilder
665+  .add(Symbol.ERROR, State.ERROR)
666   .add(Symbol.EXPRESSION, 60)
667-  .add(Symbol.VARIABLE_SEQUENCE, 3)
668+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
669   .add(Symbol.NUMBER, State.START_NUMBER)
670   .add(Symbol.STRING, [SHIFT, State.START_STRING])
671-  .add(Symbol.PLUS, [SHIFT, 10])
672+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
673   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
674   .add(Symbol.RIGHT_PAREN, [SHIFT, 58])
675-  .add(Symbol.MINUS, [SHIFT, 9])
676-  .add(Symbol.FUNCTION, [SHIFT, 11])
677+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
678+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
679   .add(Symbol.EXP_SEQ, 59)
680-  .add(Symbol.CELL, 12)
681-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
682-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
683+  .add(Symbol.CELL, State.FOLLOWS_CELL)
684+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
685+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
686   .add(Symbol.ARRAY, [SHIFT, 61])
687-  .add(Symbol.VARIABLE, [SHIFT, 14])
688-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
689-  .add(Symbol.POUND, [SHIFT, 18])
690+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
691+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
692+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
693   .build();
694-table[36] = ObjectBuilder
695+table[State.FOLLOW_ERROR_ERROR] = ObjectBuilder
696   .add(Symbol.EOF, [REDUCE, ReduceActions.I27])
697   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.I27])
698   .add(Symbol.EQUALS, [REDUCE, ReduceActions.I27])
699@@ -915,10 +939,10 @@ table[40] = ObjectBuilder
700 table[41] = ObjectBuilder
701   .add(Symbol.CELL_UPPER, [SHIFT, 65])
702   .build();
703-table[42] = ObjectBuilder
704+table[State.FOLLOW_POUND_VARIABLE] = ObjectBuilder
705   .add(Symbol.EXCLAMATION_POINT, [SHIFT, 66])
706   .build();
707-table[43] = ObjectBuilder
708+table[State.NUMBER_AMPERSAND_EXPRESSION] = ObjectBuilder
709   .add(Symbol.EOF, [REDUCE, ReduceActions.AMPERSAND])
710   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.AMPERSAND])
711   .add(Symbol.EQUALS, [REDUCE, ReduceActions.AMPERSAND])
712@@ -933,7 +957,7 @@ table[43] = ObjectBuilder
713   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.AMPERSAND])
714   .add(Symbol.COMMA, [REDUCE, ReduceActions.AMPERSAND])
715   .build();
716-table[44] = ObjectBuilder
717+table[State.START_EQUALS_EXPRESSION] = ObjectBuilder
718   .add(Symbol.EOF, [REDUCE, ReduceActions.EQUALS])
719   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
720   .add(Symbol.EQUALS, [REDUCE, ReduceActions.EQUALS])
721@@ -964,40 +988,40 @@ table[State.ADD_TWO_NUMBERS] = ObjectBuilder
722   .add(Symbol.COMMA, [REDUCE, ReduceActions.PLUS])
723   .build();
724 table[State.LESS_THAN_EQUALS] = ObjectBuilder
725-  .add(Symbol.ERROR, 13)
726+  .add(Symbol.ERROR, State.ERROR)
727   .add(Symbol.EXPRESSION, 67)
728-  .add(Symbol.VARIABLE_SEQUENCE, 3)
729+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
730   .add(Symbol.NUMBER, State.START_NUMBER)
731   .add(Symbol.STRING, [SHIFT, State.START_STRING])
732-  .add(Symbol.PLUS, [SHIFT, 10])
733+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
734   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
735-  .add(Symbol.MINUS, [SHIFT, 9])
736-  .add(Symbol.FUNCTION, [SHIFT, 11])
737-  .add(Symbol.CELL, 12)
738-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
739-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
740-  .add(Symbol.VARIABLE, [SHIFT, 14])
741-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
742-  .add(Symbol.POUND, [SHIFT, 18])
743-  .build();
744-table[47] = ObjectBuilder
745-  .add(Symbol.ERROR, 13)
746+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
747+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
748+  .add(Symbol.CELL, State.FOLLOWS_CELL)
749+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
750+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
751+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
752+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
753+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
754+  .build();
755+table[State.LESSTHAN_GREATERTHAN] = ObjectBuilder
756+  .add(Symbol.ERROR, State.ERROR)
757   .add(Symbol.EXPRESSION, 68)
758-  .add(Symbol.VARIABLE_SEQUENCE, 3)
759+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
760   .add(Symbol.NUMBER, State.START_NUMBER)
761   .add(Symbol.STRING, [SHIFT, State.START_STRING])
762-  .add(Symbol.PLUS, [SHIFT, 10])
763+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
764   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
765-  .add(Symbol.MINUS, [SHIFT, 9])
766-  .add(Symbol.FUNCTION, [SHIFT, 11])
767-  .add(Symbol.CELL, 12)
768-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
769-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
770-  .add(Symbol.VARIABLE, [SHIFT, 14])
771-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
772-  .add(Symbol.POUND, [SHIFT, 18])
773-  .build();
774-table[48] = ObjectBuilder
775+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
776+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
777+  .add(Symbol.CELL, State.FOLLOWS_CELL)
778+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
779+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
780+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
781+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
782+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
783+  .build();
784+table[State.LESSTHAN_EXPRESSION] = ObjectBuilder
785   .add(Symbol.EOF, [REDUCE, ReduceActions.LT])
786   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
787   .add(Symbol.EQUALS, [REDUCE, ReduceActions.LT])
788@@ -1013,23 +1037,23 @@ table[48] = ObjectBuilder
789   .add(Symbol.COMMA, [REDUCE, ReduceActions.LT])
790   .build();
791 table[State.GREATER_THAN_EQUALS] = ObjectBuilder
792-  .add(Symbol.ERROR, 13)
793+  .add(Symbol.ERROR, State.ERROR)
794   .add(Symbol.EXPRESSION, State.COMPARE_TWO_EXPRESSIONS_WITH_GTE)
795-  .add(Symbol.VARIABLE_SEQUENCE, 3)
796+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
797   .add(Symbol.NUMBER, State.START_NUMBER)
798   .add(Symbol.STRING, [SHIFT, State.START_STRING])
799-  .add(Symbol.PLUS, [SHIFT, 10])
800+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
801   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
802-  .add(Symbol.MINUS, [SHIFT, 9])
803-  .add(Symbol.FUNCTION, [SHIFT, 11])
804-  .add(Symbol.CELL, 12)
805-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
806-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
807-  .add(Symbol.VARIABLE, [SHIFT, 14])
808-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
809-  .add(Symbol.POUND, [SHIFT, 18])
810-  .build();
811-table[50] = ObjectBuilder
812+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
813+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
814+  .add(Symbol.CELL, State.FOLLOWS_CELL)
815+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
816+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
817+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
818+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
819+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
820+  .build();
821+table[State.GREATERTHAN_EXPRESSION] = ObjectBuilder
822   .add(Symbol.EOF, [REDUCE, ReduceActions.GT])
823   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
824   .add(Symbol.EQUALS, [REDUCE, ReduceActions.GT])
825@@ -1128,7 +1152,7 @@ table[56] = ObjectBuilder
826   .add(Symbol.CARROT, [REDUCE, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
827   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
828   .add(Symbol.COMMA, [REDUCE, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
829-  .add(33, [REDUCE, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
830+  .add(Symbol.DECIMAL, [REDUCE, ReduceActions.ENSURE_LAST_TWO_IN_ARRAY_AND_PUSH])
831   .build();
832 table[State.CLOSE_PAREN_ON_EXPRESSION] = ObjectBuilder
833   .add(Symbol.EOF, [REDUCE, ReduceActions.LAST_NUMBER])
834@@ -1306,41 +1330,41 @@ table[State.CLOSE_PAREN_ON_FUNCTION] = ObjectBuilder
835   .add(Symbol.COMMA, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
836   .build();
837 table[State.VARIABLE_FOLLOWED_BY_SEMI_COLON] = ObjectBuilder
838-  .add(Symbol.ERROR, 13)
839+  .add(Symbol.ERROR, State.ERROR)
840   .add(Symbol.EXPRESSION, 74)
841-  .add(Symbol.VARIABLE_SEQUENCE, 3)
842+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
843   .add(Symbol.NUMBER, State.START_NUMBER)
844   .add(Symbol.STRING, [SHIFT, State.START_STRING])
845   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
846-  .add(Symbol.PLUS, [SHIFT, 10])
847+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
848   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
849-  .add(Symbol.MINUS, [SHIFT, 9])
850-  .add(Symbol.FUNCTION, [SHIFT, 11])
851-  .add(Symbol.CELL, 12)
852-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
853-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
854-  .add(Symbol.VARIABLE, [SHIFT, 14])
855-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
856-  .add(Symbol.POUND, [SHIFT, 18])
857+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
858+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
859+  .add(Symbol.CELL, State.FOLLOWS_CELL)
860+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
861+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
862+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
863+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
864+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
865   .build();
866 table[State.VARIABLE_FOLLOWED_BY_COMMA] = ObjectBuilder
867-  .add(Symbol.ERROR, 13)
868+  .add(Symbol.ERROR, State.ERROR)
869   .add(Symbol.EXPRESSION, 75)
870-  .add(Symbol.VARIABLE_SEQUENCE, 3)
871+  .add(Symbol.VARIABLE_SEQUENCE, State.FOLLOW_VARIABLE_SEQUENCE)
872   .add(Symbol.NUMBER, State.START_NUMBER)
873   .add(Symbol.STRING, [SHIFT, State.START_STRING])
874   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
875-  .add(Symbol.PLUS, [SHIFT, 10])
876+  .add(Symbol.PLUS, [SHIFT, State.PREFIX_UNARY_PLUS])
877   .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
878-  .add(Symbol.MINUS, [SHIFT, 9])
879-  .add(Symbol.FUNCTION, [SHIFT, 11])
880-  .add(Symbol.CELL, 12)
881-  .add(Symbol.FIXEDCELL, [SHIFT, 16])
882-  .add(Symbol.CELL_UPPER, [SHIFT, 17])
883-  .add(Symbol.VARIABLE, [SHIFT, 14])
884-  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
885+  .add(Symbol.MINUS, [SHIFT, State.PREFIX_UNARY_MINUS])
886+  .add(Symbol.FUNCTION, [SHIFT, State.FUNCTION])
887+  .add(Symbol.CELL, State.FOLLOWS_CELL)
888+  .add(Symbol.FIXEDCELL, [SHIFT, State.FIXED_CELL])
889+  .add(Symbol.CELL_UPPER, [SHIFT, State.FOLLOW_CELL_UPPER])
890+  .add(Symbol.VARIABLE, [SHIFT, State.FOLLOW_VARIABLE])
891+  .add(Symbol.NUMBER_UPPER, [SHIFT, State.FOLLOW_NUMBER_UPPER])
892   .add(Symbol.ARRAY, [SHIFT, 61])
893-  .add(Symbol.POUND, [SHIFT, 18])
894+  .add(Symbol.POUND, [SHIFT, State.FOLLOW_POUND])
895   .build();
896 table[73] = ObjectBuilder
897   .add(Symbol.EOF, [REDUCE, ReduceActions.REDUCE_LAST_THREE_B])
898diff --git a/src/Sheet.ts b/src/Sheet.ts
899index 8d592d8..f39d48a 100644
900--- a/src/Sheet.ts
901+++ b/src/Sheet.ts
902@@ -228,7 +228,7 @@ class Sheet {
903     let error = null;
904 
905     try {
906-      this.parser.yy.obj = cellId;
907+      this.parser.yy.originCellId = cellId;
908       result = this.parser.parse(formula);
909       let deps = this.dataStore.getDependencies(cellId);
910 
911diff --git a/tests.sh b/tests.sh
912index 463d321..4a9af61 100755
913--- a/tests.sh
914+++ b/tests.sh
915@@ -10,5 +10,5 @@ do
916   echo "$(date) Running ${test_file}"
917   node ${test_file}
918 done
919-# node test_output/tests/Parser/ParserTest.js
920+node test_output/tests/SheetBasicTests.js
921 echo "$(date) Tests Done"
922\ No newline at end of file
923diff --git a/tests/SheetBasicTests.ts b/tests/SheetBasicTests.ts
924index 95426bc..9dfa06d 100644
925--- a/tests/SheetBasicTests.ts
926+++ b/tests/SheetBasicTests.ts
927@@ -7,7 +7,10 @@ import {
928   REF_ERROR,
929   VALUE_ERROR
930 } from "../src/Errors";
931-import {assertFormulaEquals, assertFormulaEqualsError, test} from "./Utils/Asserts";
932+import {
933+  assertFormulaEquals, assertFormulaEqualsDependsOnReference, assertFormulaEqualsError,
934+  test
935+} from "./Utils/Asserts";
936 
937 test("Sheet, declare number", function () {
938   assertFormulaEquals('=5', 5);
939@@ -212,3 +215,6 @@ test("Sheet, parse range literal", function(){
940   // assertEqualsArray('=["str", "str"]', ["str", "str"]);
941   // assertEqualsArray('=["str", [1, 2, 3], [1]]', ["str", [1, 2, 3], [1]]);
942 });
943+
944+
945+assertFormulaEqualsDependsOnReference('M1', 10, '=10 + $M$1', 20);