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 enumerations
author
Ben Vogt <[email protected]>
date
2017-12-10 22:52:24
stats
2 file(s) changed, 107 insertions(+), 100 deletions(-)
files
src/Parser/ParserConstants.ts
tests/Parser/ParseEngineTest.ts
  1diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
  2index 7614a6e..398cf6e 100644
  3--- a/src/Parser/ParserConstants.ts
  4+++ b/src/Parser/ParserConstants.ts
  5@@ -363,15 +363,23 @@ const enum State {
  6   START_NUMBER = 6,
  7   START_STRING = 7,
  8   LEFT_PAREN = 8,
  9+  NUMBER_FOLLOWED_BY_AMPERSAND = 20,
 10   START_EQUALS = 21,
 11+  NUMBER_FOLLOWED_BY_PLUS = 22,
 12   LESS_THAN = 23,
 13   GREATER_THAN = 24,
 14+  NUMBER_FOLLOWED_BY_MINUS = 26,
 15+  NUMBER_FOLLOWED_BY_ASTERISK = 27,
 16+  NUMBER_FOLLOWED_BY_SLASH = 28,
 17+  NUMBER_FOLLOWED_BY_CARROT = 29,
 18   ADD_TWO_NUMBERS = 45,
 19   SUBTRACT_TWO_NUMBERS = 52,
 20   MULTIPLY_TWO_NUMBERS = 53,
 21   DIVIDE_TWO_NUMBERS = 54,
 22   NUMBER_TO_POWER_OF_OTHER = 55,
 23-  CLOSE_PAREN_ON_EXPRESSION = 57
 24+  CLOSE_PAREN_ON_EXPRESSION = 57,
 25+  COMPARE_TWO_EXPRESSIONS_WITH_GTE = 69,
 26+  CLOSE_PAREN_ON_FUNCTION = 70
 27 }
 28 
 29 
 30@@ -405,16 +413,16 @@ table[1] = ObjectBuilder
 31   .build();
 32 table[2] = ObjectBuilder
 33   .add(Symbol.EOF, [SHIFT, 19])
 34-  .add(Symbol.AMPERSAND, [SHIFT, 20])
 35+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
 36   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
 37-  .add(Symbol.PLUS, [SHIFT, 22])
 38+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
 39   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
 40   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
 41   .add(Symbol.NOT, [SHIFT, 25])
 42-  .add(Symbol.MINUS, [SHIFT, 26])
 43-  .add(Symbol.ASTERISK, [SHIFT, 27])
 44-  .add(Symbol.DIVIDE, [SHIFT, 28])
 45-  .add(Symbol.CARROT, [SHIFT, 29])
 46+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
 47+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
 48+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
 49+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
 50   .build();
 51 table[3] = ObjectBuilder
 52   .add(Symbol.EOF, [REDUCE, ReduceActions.CALL_VARIABLE])
 53@@ -635,7 +643,7 @@ table[18] = ObjectBuilder
 54 table[19] = ObjectBuilder
 55   .add(Symbol.END, [REDUCE, ReduceActions.RETURN_LAST])
 56   .build();
 57-table[20] = ObjectBuilder
 58+table[State.NUMBER_FOLLOWED_BY_AMPERSAND] = ObjectBuilder
 59   .add(Symbol.ERROR, 13)
 60   .add(Symbol.EXPRESSION, 43)
 61   .add(Symbol.VARIABLE_SEQUENCE, 3)
 62@@ -669,7 +677,7 @@ table[State.START_EQUALS] = ObjectBuilder
 63   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
 64   .add(Symbol.POUND, [SHIFT, 18])
 65   .build();
 66-table[22] = ObjectBuilder
 67+table[State.NUMBER_FOLLOWED_BY_PLUS] = ObjectBuilder
 68   .add(Symbol.ERROR, 13)
 69   .add(Symbol.EXPRESSION, 45)
 70   .add(Symbol.VARIABLE_SEQUENCE, 3)
 71@@ -740,7 +748,7 @@ table[25] = ObjectBuilder
 72   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
 73   .add(Symbol.POUND, [SHIFT, 18])
 74   .build();
 75-table[26] = ObjectBuilder
 76+table[State.NUMBER_FOLLOWED_BY_MINUS] = ObjectBuilder
 77   .add(Symbol.ERROR, 13)
 78   .add(Symbol.EXPRESSION, State.SUBTRACT_TWO_NUMBERS)
 79   .add(Symbol.VARIABLE_SEQUENCE, 3)
 80@@ -757,7 +765,7 @@ table[26] = ObjectBuilder
 81   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
 82   .add(Symbol.POUND, [SHIFT, 18])
 83   .build();
 84-table[27] = ObjectBuilder
 85+table[State.NUMBER_FOLLOWED_BY_ASTERISK] = ObjectBuilder
 86   .add(Symbol.ERROR, 13)
 87   .add(Symbol.EXPRESSION, State.MULTIPLY_TWO_NUMBERS)
 88   .add(Symbol.VARIABLE_SEQUENCE, 3)
 89@@ -774,7 +782,7 @@ table[27] = ObjectBuilder
 90   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
 91   .add(Symbol.POUND, [SHIFT, 18])
 92   .build();
 93-table[28] = ObjectBuilder
 94+table[State.NUMBER_FOLLOWED_BY_SLASH] = ObjectBuilder
 95   .add(Symbol.ERROR, 13)
 96   .add(Symbol.EXPRESSION, State.DIVIDE_TWO_NUMBERS)
 97   .add(Symbol.VARIABLE_SEQUENCE, 3)
 98@@ -791,7 +799,7 @@ table[28] = ObjectBuilder
 99   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
100   .add(Symbol.POUND, [SHIFT, 18])
101   .build();
102-table[29] = ObjectBuilder
103+table[State.NUMBER_FOLLOWED_BY_CARROT] = ObjectBuilder
104   .add(Symbol.ERROR, 13)
105   .add(Symbol.EXPRESSION, State.NUMBER_TO_POWER_OF_OTHER)
106   .add(Symbol.VARIABLE_SEQUENCE, 3)
107@@ -830,17 +838,17 @@ table[31] = ObjectBuilder
108   .add(38, [REDUCE, ReduceActions.REDUCE_PREV_AS_PERCENT])
109   .build();
110 table[32] = ObjectBuilder
111-  .add(Symbol.AMPERSAND, [SHIFT, 20])
112+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
113   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
114-  .add(Symbol.PLUS, [SHIFT, 22])
115+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
116   .add(Symbol.RIGHT_PAREN, [SHIFT, State.CLOSE_PAREN_ON_EXPRESSION])
117   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
118   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
119   .add(Symbol.NOT, [SHIFT, 25])
120-  .add(Symbol.MINUS, [SHIFT, 26])
121-  .add(Symbol.ASTERISK, [SHIFT, 27])
122-  .add(Symbol.DIVIDE, [SHIFT, 28])
123-  .add(Symbol.CARROT, [SHIFT, 29])
124+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
125+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
126+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
127+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
128   .build();
129 table[33] = ObjectBuilder
130   .add(Symbol.EOF, [REDUCE, ReduceActions.INVERT_NUM])
131@@ -860,7 +868,7 @@ table[33] = ObjectBuilder
132   .build();
133 table[34] = ObjectBuilder
134   .add(Symbol.EOF, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
135-  .add(Symbol.AMPERSAND, [SHIFT, 20])
136+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
137   .add(Symbol.EQUALS, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
138   .add(Symbol.PLUS, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
139   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
140@@ -868,9 +876,9 @@ table[34] = ObjectBuilder
141   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
142   .add(Symbol.NOT, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
143   .add(Symbol.MINUS, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
144-  .add(Symbol.ASTERISK, [SHIFT, 27])
145-  .add(Symbol.DIVIDE, [SHIFT, 28])
146-  .add(Symbol.CARROT, [SHIFT, 29])
147+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
148+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
149+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
150   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
151   .add(Symbol.COMMA, [REDUCE, ReduceActions.TO_NUMBER_NAN_AS_ZERO])
152   .build();
153@@ -946,23 +954,23 @@ table[43] = ObjectBuilder
154   .build();
155 table[44] = ObjectBuilder
156   .add(Symbol.EOF, [REDUCE, ReduceActions.EQUALS])
157-  .add(Symbol.AMPERSAND, [SHIFT, 22])
158+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
159   .add(Symbol.EQUALS, [REDUCE, ReduceActions.EQUALS])
160-  .add(Symbol.PLUS, [SHIFT, 22])
161+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
162   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.EQUALS])
163   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
164   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
165   .add(Symbol.NOT, [SHIFT, 25])
166-  .add(Symbol.MINUS, [SHIFT, 26])
167-  .add(Symbol.ASTERISK, [SHIFT, 27])
168-  .add(Symbol.DIVIDE, [SHIFT, 28])
169-  .add(Symbol.CARROT, [SHIFT, 29])
170+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
171+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
172+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
173+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
174   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.EQUALS])
175   .add(Symbol.COMMA, [REDUCE, ReduceActions.EQUALS])
176   .build();
177 table[State.ADD_TWO_NUMBERS] = ObjectBuilder
178   .add(Symbol.EOF, [REDUCE, ReduceActions.PLUS])
179-  .add(Symbol.AMPERSAND, [SHIFT, 20])
180+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
181   .add(Symbol.EQUALS, [REDUCE, ReduceActions.PLUS])
182   .add(Symbol.PLUS, [REDUCE, ReduceActions.PLUS])
183   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.PLUS])
184@@ -970,9 +978,9 @@ table[State.ADD_TWO_NUMBERS] = ObjectBuilder
185   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.PLUS])
186   .add(Symbol.NOT, [REDUCE, ReduceActions.PLUS])
187   .add(Symbol.MINUS, [REDUCE, ReduceActions.PLUS])
188-  .add(Symbol.ASTERISK, [SHIFT, 27])
189-  .add(Symbol.DIVIDE, [SHIFT, 28])
190-  .add(Symbol.CARROT, [SHIFT, 29])
191+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
192+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
193+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
194   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.PLUS])
195   .add(Symbol.COMMA, [REDUCE, ReduceActions.PLUS])
196   .build();
197@@ -1012,23 +1020,23 @@ table[47] = ObjectBuilder
198   .build();
199 table[48] = ObjectBuilder
200   .add(Symbol.EOF, [REDUCE, ReduceActions.LT])
201-  .add(Symbol.AMPERSAND, [SHIFT, 20])
202+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
203   .add(Symbol.EQUALS, [REDUCE, ReduceActions.LT])
204-  .add(Symbol.PLUS, [SHIFT, 22])
205+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
206   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.LT])
207   .add(Symbol.LESS_THAN, [REDUCE, ReduceActions.LT])
208   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.LT])
209   .add(Symbol.NOT, [REDUCE, ReduceActions.LT])
210-  .add(Symbol.MINUS, [SHIFT, 26])
211-  .add(Symbol.ASTERISK, [SHIFT, 27])
212-  .add(Symbol.DIVIDE, [SHIFT, 28])
213-  .add(Symbol.CARROT, [SHIFT, 29])
214+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
215+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
216+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
217+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
218   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.LT])
219   .add(Symbol.COMMA, [REDUCE, ReduceActions.LT])
220   .build();
221 table[49] = ObjectBuilder
222   .add(Symbol.ERROR, 13)
223-  .add(Symbol.EXPRESSION, 69)
224+  .add(Symbol.EXPRESSION, State.COMPARE_TWO_EXPRESSIONS_WITH_GTE)
225   .add(Symbol.VARIABLE_SEQUENCE, 3)
226   .add(Symbol.NUMBER, State.START_NUMBER)
227   .add(Symbol.STRING, [SHIFT, State.START_STRING])
228@@ -1045,17 +1053,17 @@ table[49] = ObjectBuilder
229   .build();
230 table[50] = ObjectBuilder
231   .add(Symbol.EOF, [REDUCE, ReduceActions.GT])
232-  .add(Symbol.AMPERSAND, [SHIFT, 20])
233+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
234   .add(Symbol.EQUALS, [REDUCE, ReduceActions.GT])
235-  .add(Symbol.PLUS, [SHIFT, 22])
236+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
237   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.GT])
238   .add(Symbol.LESS_THAN, [REDUCE, ReduceActions.GT])
239   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.GT])
240   .add(Symbol.NOT, [REDUCE, ReduceActions.GT])
241-  .add(Symbol.MINUS, [SHIFT, 26])
242-  .add(Symbol.ASTERISK, [SHIFT, 27])
243-  .add(Symbol.DIVIDE, [SHIFT, 28])
244-  .add(Symbol.CARROT, [SHIFT, 29])
245+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
246+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
247+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
248+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
249   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.GT])
250   .add(Symbol.COMMA, [REDUCE, ReduceActions.GT])
251   .build();
252@@ -1189,22 +1197,22 @@ table[58] = ObjectBuilder
253   .add(Symbol.COMMA, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_BLANK])
254   .build();
255 table[59] = ObjectBuilder
256-  .add(Symbol.RIGHT_PAREN, [SHIFT, 70])
257+  .add(Symbol.RIGHT_PAREN, [SHIFT, State.CLOSE_PAREN_ON_FUNCTION])
258   .add(Symbol.SEMI_COLON, [SHIFT, 71])
259   .add(Symbol.COMMA, [SHIFT, 72])
260   .build();
261 table[60] = ObjectBuilder
262-  .add(Symbol.AMPERSAND, [SHIFT, 20])
263+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
264   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
265-  .add(Symbol.PLUS, [SHIFT, 22])
266+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
267   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.ENSURE_IS_ARRAY])
268   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
269   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
270   .add(Symbol.NOT, [SHIFT, 25])
271-  .add(Symbol.MINUS, [SHIFT, 26])
272-  .add(Symbol.ASTERISK, [SHIFT, 27])
273-  .add(Symbol.DIVIDE, [SHIFT, 28])
274-  .add(Symbol.CARROT, [SHIFT, 29])
275+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
276+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
277+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
278+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
279   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.ENSURE_IS_ARRAY])
280   .add(Symbol.COMMA, [REDUCE, ReduceActions.ENSURE_IS_ARRAY])
281   .build();
282@@ -1282,51 +1290,51 @@ table[66] = ObjectBuilder
283   .add(Symbol.POUND, [REDUCE, ReduceActions.REDUCE_LAST_THREE_A]).build();
284 table[67] = ObjectBuilder
285   .add(Symbol.EOF, [REDUCE, ReduceActions.LTE])
286-  .add(Symbol.AMPERSAND, [SHIFT, 20])
287+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
288   .add(Symbol.EQUALS, [REDUCE, ReduceActions.LTE])
289-  .add(Symbol.PLUS, [SHIFT, 22])
290+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
291   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.LTE])
292   .add(Symbol.LESS_THAN, [REDUCE, ReduceActions.LTE])
293   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.LTE])
294   .add(Symbol.NOT, [REDUCE, ReduceActions.LTE])
295-  .add(Symbol.MINUS, [SHIFT, 26])
296-  .add(Symbol.ASTERISK, [SHIFT, 27])
297-  .add(Symbol.DIVIDE, [SHIFT, 28])
298-  .add(Symbol.CARROT, [SHIFT, 29])
299+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
300+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
301+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
302+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
303   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.LTE])
304   .add(Symbol.COMMA, [REDUCE, ReduceActions.LTE]).build();
305 table[68] = ObjectBuilder
306   .add(Symbol.EOF, [REDUCE, ReduceActions.NOT_EQ])
307-  .add(Symbol.AMPERSAND, [SHIFT, 20])
308+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
309   .add(Symbol.EQUALS, [REDUCE, ReduceActions.NOT_EQ])
310-  .add(Symbol.PLUS, [SHIFT, 22])
311+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
312   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.NOT_EQ])
313   .add(Symbol.LESS_THAN, [REDUCE, ReduceActions.NOT_EQ])
314   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.NOT_EQ])
315   .add(Symbol.NOT, [REDUCE, ReduceActions.NOT_EQ])
316-  .add(Symbol.MINUS, [SHIFT, 26])
317-  .add(Symbol.ASTERISK, [SHIFT, 27])
318-  .add(Symbol.DIVIDE, [SHIFT, 28])
319-  .add(Symbol.CARROT, [SHIFT, 29])
320+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
321+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
322+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
323+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
324   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.NOT_EQ])
325   .add(Symbol.COMMA, [REDUCE, ReduceActions.NOT_EQ]).build();
326-table[69] = ObjectBuilder
327+table[State.COMPARE_TWO_EXPRESSIONS_WITH_GTE] = ObjectBuilder
328   .add(Symbol.EOF, [REDUCE, ReduceActions.GTE])
329-  .add(Symbol.AMPERSAND, [SHIFT, 20])
330+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
331   .add(Symbol.EQUALS, [REDUCE, ReduceActions.GTE])
332-  .add(Symbol.PLUS, [SHIFT, 22])
333+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
334   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.GTE])
335   .add(Symbol.LESS_THAN, [REDUCE, ReduceActions.GTE])
336   .add(Symbol.GREATER_THAN, [REDUCE, ReduceActions.GTE])
337   .add(Symbol.NOT, [REDUCE, ReduceActions.GTE])
338-  .add(Symbol.MINUS, [SHIFT, 26])
339-  .add(Symbol.ASTERISK, [SHIFT, 27])
340-  .add(Symbol.DIVIDE, [SHIFT, 28])
341-  .add(Symbol.CARROT, [SHIFT, 29])
342+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
343+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
344+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
345+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
346   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.GTE])
347   .add(Symbol.COMMA, [REDUCE, ReduceActions.GTE])
348   .build();
349-table[70] = ObjectBuilder
350+table[State.CLOSE_PAREN_ON_FUNCTION] = ObjectBuilder
351   .add(Symbol.EOF, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
352   .add(Symbol.AMPERSAND, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
353   .add(Symbol.EQUALS, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
354@@ -1398,31 +1406,31 @@ table[73] = ObjectBuilder
355   .add(Symbol.POUND, [REDUCE, ReduceActions.REDUCE_LAST_THREE_B])
356   .build();
357 table[74] = ObjectBuilder
358-  .add(Symbol.AMPERSAND, [SHIFT, 20])
359+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
360   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
361-  .add(Symbol.PLUS, [SHIFT, 22])
362+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
363   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.REDUCE_INT])
364   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
365   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
366   .add(Symbol.NOT, [SHIFT, 25])
367-  .add(Symbol.MINUS, [SHIFT, 26])
368-  .add(Symbol.ASTERISK, [SHIFT, 27])
369-  .add(Symbol.DIVIDE, [SHIFT, 28])
370-  .add(Symbol.CARROT, [SHIFT, 29])
371+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
372+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
373+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
374+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
375   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.REDUCE_INT])
376   .add(Symbol.COMMA, [REDUCE, ReduceActions.REDUCE_INT]).build();
377 table[75] = ObjectBuilder
378-  .add(Symbol.AMPERSAND, [SHIFT, 20])
379+  .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
380   .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
381-  .add(Symbol.PLUS, [SHIFT, 22])
382+  .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
383   .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.REDUCE_PERCENT])
384   .add(Symbol.LESS_THAN, [SHIFT, State.LESS_THAN])
385   .add(Symbol.GREATER_THAN, [SHIFT, State.GREATER_THAN])
386   .add(Symbol.NOT, [SHIFT, 25])
387-  .add(Symbol.MINUS, [SHIFT, 26])
388-  .add(Symbol.ASTERISK, [SHIFT, 27])
389-  .add(Symbol.DIVIDE, [SHIFT, 28])
390-  .add(Symbol.CARROT, [SHIFT, 29])
391+  .add(Symbol.MINUS, [SHIFT, State.NUMBER_FOLLOWED_BY_MINUS])
392+  .add(Symbol.ASTERISK, [SHIFT, State.NUMBER_FOLLOWED_BY_ASTERISK])
393+  .add(Symbol.DIVIDE, [SHIFT, State.NUMBER_FOLLOWED_BY_SLASH])
394+  .add(Symbol.CARROT, [SHIFT, State.NUMBER_FOLLOWED_BY_CARROT])
395   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.REDUCE_PERCENT])
396   .add(Symbol.COMMA, [REDUCE, ReduceActions.REDUCE_PERCENT]).build();
397 const ACTION_TABLE = table;
398diff --git a/tests/Parser/ParseEngineTest.ts b/tests/Parser/ParseEngineTest.ts
399index 838c21b..0effb61 100644
400--- a/tests/Parser/ParseEngineTest.ts
401+++ b/tests/Parser/ParseEngineTest.ts
402@@ -521,4 +521,4 @@ test("Parse range following comma", function(){
403 
404 
405 
406-assertEquals(parser.parse('(1+2)'), 3);
407+assertEquals(parser.parse('2^4'), 16);