spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[ParserEngine] do-over on ParserEngine
author
Ben Vogt <[email protected]>
date
2017-12-10 02:18:34
stats
3 file(s) changed, 61 insertions(+), 61 deletions(-)
files
src/Parser/ParseEngine.ts
src/Parser/Parser.ts
src/Parser/ParserConstants.ts
  1diff --git a/src/Parser/ParseEngine.ts b/src/Parser/ParseEngine.ts
  2index 635c40b..35bd64e 100644
  3--- a/src/Parser/ParseEngine.ts
  4+++ b/src/Parser/ParseEngine.ts
  5@@ -261,7 +261,8 @@ const enum State {
  6   ASTERISK = 9,
  7   TERMINATE_NUMBER = 29,
  8   TERMINATE = 30,
  9-  MULTIPLY = 31
 10+  MULTIPLY = 31,
 11+  ULTIMATE_TERMINAL = 32
 12 }
 13 
 14 let STATE_NAMES = {};
 15@@ -272,6 +273,7 @@ STATE_NAMES[State.ASTERISK] = "State.ASTERISK";
 16 STATE_NAMES[State.TERMINATE_NUMBER] = "State.TERMINATE_NUMBER";
 17 STATE_NAMES[State.TERMINATE] = "State.TERMINATE";
 18 STATE_NAMES[State.MULTIPLY] = "State.MULTIPLY";
 19+STATE_NAMES[State.ULTIMATE_TERMINAL] = "State.ULTIMATE_TERMINAL";
 20 
 21 /**
 22  * Productions is used to look up both the number to use when reducing the stack (productions[x][1]) and the semantic
 23@@ -380,7 +382,7 @@ let Parser = (function () {
 24         }
 25       }
 26     },
 27-    defaultActions: {19: [REDUCE, 1]},
 28+    defaultActions : ObjectBuilder.add(State.ULTIMATE_TERMINAL, [REDUCE, ReduceActions.RETURN_LAST]).build(),
 29     parseError: function parseError(str, hash) {
 30       if (hash.recoverable) {
 31         this.trace(str);
 32diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
 33index c621ceb..c4d84ad 100644
 34--- a/src/Parser/Parser.ts
 35+++ b/src/Parser/Parser.ts
 36@@ -267,7 +267,7 @@ let Parser = (function () {
 37         }
 38       }
 39     },
 40-    defaultActions: {19: [REDUCE, 1]},
 41+    defaultActions: {19: [REDUCE, ReduceActions.RETURN_LAST]},
 42     parseError: function parseError(str, hash) {
 43       if (hash.recoverable) {
 44         this.trace(str);
 45diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
 46index 0f2d354..7d1b1d8 100644
 47--- a/src/Parser/ParserConstants.ts
 48+++ b/src/Parser/ParserConstants.ts
 49@@ -650,7 +650,7 @@ table[18] = ObjectBuilder
 50   .add(Symbol.COMMA, [REDUCE, ReduceActions.AS_ERROR])
 51   .build();
 52 table[19] = ObjectBuilder
 53-  .add(Symbol.END, [ACCEPT, ReduceActions.RETURN_LAST])
 54+  .add(Symbol.END, [REDUCE, ReduceActions.RETURN_LAST])
 55   .build();
 56 table[20] = ObjectBuilder
 57   .add(Symbol.ERROR, 13)
 58@@ -675,87 +675,87 @@ table[21] = ObjectBuilder
 59   .add(Symbol.ERROR, 13)
 60   .add(Symbol.EXPRESSION, 44)
 61   .add(Symbol.VARIABLE_SEQUENCE, 3)
 62-  .add(Symbol.TIME_AMPM, [SHIFT, ReduceActions.TIME_CALL])
 63-  .add(Symbol.TIME_24, [SHIFT, ReduceActions.AS_NUMBER])
 64+  .add(Symbol.TIME_AMPM, [SHIFT, 4])
 65+  .add(Symbol.TIME_24, [SHIFT, 5])
 66   .add(Symbol.NUMBER, 6)
 67-  .add(Symbol.STRING, [SHIFT, ReduceActions.AMPERSAND])
 68-  .add(Symbol.PLUS, [SHIFT, ReduceActions.LAST_NUMBER])
 69-  .add(Symbol.LEFT_PAREN, [SHIFT, ReduceActions.EQUALS])
 70-  .add(Symbol.MINUS, [SHIFT, ReduceActions.PLUS])
 71-  .add(Symbol.FUNCTION, [SHIFT, ReduceActions.LTE])
 72+  .add(Symbol.STRING, [SHIFT, 7])
 73+  .add(Symbol.PLUS, [SHIFT, 10])
 74+  .add(Symbol.LEFT_PAREN, [SHIFT, 8])
 75+  .add(Symbol.MINUS, [SHIFT, 9])
 76+  .add(Symbol.FUNCTION, [SHIFT, 1])
 77   .add(Symbol.CELL, 12)
 78-  .add(Symbol.FIXEDCELL, [SHIFT, ReduceActions.LT])
 79-  .add(Symbol.CELL_UPPER, [SHIFT, ReduceActions.MINUS])
 80-  .add(Symbol.VARIABLE, [SHIFT, ReduceActions.NOT])
 81-  .add(Symbol.NUMBER_UPPER, [SHIFT, ReduceActions.GT])
 82-  .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
 83+  .add(Symbol.FIXEDCELL, [SHIFT, 16])
 84+  .add(Symbol.CELL_UPPER, [SHIFT, 17])
 85+  .add(Symbol.VARIABLE, [SHIFT, 14])
 86+  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
 87+  .add(Symbol.POUND, [SHIFT, 18])
 88   .build();
 89 table[22] = ObjectBuilder
 90   .add(Symbol.ERROR, 13)
 91   .add(Symbol.EXPRESSION, 45)
 92   .add(Symbol.VARIABLE_SEQUENCE, 3)
 93-  .add(Symbol.TIME_AMPM, [SHIFT, ReduceActions.TIME_CALL])
 94-  .add(Symbol.TIME_24, [SHIFT, ReduceActions.AS_NUMBER])
 95+  .add(Symbol.TIME_AMPM, [SHIFT, 4])
 96+  .add(Symbol.TIME_24, [SHIFT, 5])
 97   .add(Symbol.NUMBER, 6)
 98-  .add(Symbol.STRING, [SHIFT, ReduceActions.AMPERSAND])
 99-  .add(Symbol.PLUS, [SHIFT, ReduceActions.LAST_NUMBER])
100-  .add(Symbol.LEFT_PAREN, [SHIFT, ReduceActions.EQUALS])
101-  .add(Symbol.MINUS, [SHIFT, ReduceActions.PLUS])
102-  .add(Symbol.FUNCTION, [SHIFT, ReduceActions.LTE])
103+  .add(Symbol.STRING, [SHIFT, 7])
104+  .add(Symbol.PLUS, [SHIFT, 10])
105+  .add(Symbol.LEFT_PAREN, [SHIFT, 8])
106+  .add(Symbol.MINUS, [SHIFT, 9])
107+  .add(Symbol.FUNCTION, [SHIFT, 11])
108   .add(Symbol.CELL, 12)
109-  .add(Symbol.FIXEDCELL, [SHIFT, ReduceActions.LT])
110-  .add(Symbol.CELL_UPPER, [SHIFT, ReduceActions.MINUS])
111-  .add(Symbol.VARIABLE, [SHIFT, ReduceActions.NOT])
112-  .add(Symbol.NUMBER_UPPER, [SHIFT, ReduceActions.GT])
113-  .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
114+  .add(Symbol.FIXEDCELL, [SHIFT, 16])
115+  .add(Symbol.CELL_UPPER, [SHIFT, 17])
116+  .add(Symbol.VARIABLE, [SHIFT, 14])
117+  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
118+  .add(Symbol.POUND, [SHIFT, 18])
119   .build();
120 table[23] = ObjectBuilder
121   .add(Symbol.ERROR, 13)
122   .add(Symbol.EXPRESSION, 48)
123   .add(Symbol.VARIABLE_SEQUENCE, 3)
124-  .add(Symbol.TIME_AMPM, [SHIFT, ReduceActions.TIME_CALL])
125-  .add(Symbol.TIME_24, [SHIFT, ReduceActions.AS_NUMBER])
126+  .add(Symbol.TIME_AMPM, [SHIFT, 4])
127+  .add(Symbol.TIME_24, [SHIFT, 5])
128   .add(Symbol.NUMBER, 6)
129-  .add(Symbol.STRING, [SHIFT, ReduceActions.AMPERSAND])
130+  .add(Symbol.STRING, [SHIFT, 7])
131   .add(Symbol.EQUALS, [SHIFT, 46])
132-  .add(Symbol.PLUS, [SHIFT, ReduceActions.LAST_NUMBER])
133-  .add(Symbol.LEFT_PAREN, [SHIFT, ReduceActions.EQUALS])
134+  .add(Symbol.PLUS, [SHIFT, 10])
135+  .add(Symbol.LEFT_PAREN, [SHIFT, 8])
136   .add(Symbol.GREATER_THAN, [SHIFT, 47])
137-  .add(Symbol.MINUS, [SHIFT, ReduceActions.PLUS])
138-  .add(Symbol.FUNCTION, [SHIFT, ReduceActions.LTE])
139+  .add(Symbol.MINUS, [SHIFT, 9])
140+  .add(Symbol.FUNCTION, [SHIFT, 11])
141   .add(Symbol.CELL, 12)
142-  .add(Symbol.FIXEDCELL, [SHIFT, ReduceActions.LT])
143-  .add(Symbol.CELL_UPPER, [SHIFT, ReduceActions.MINUS])
144-  .add(Symbol.VARIABLE, [SHIFT, ReduceActions.NOT])
145-  .add(Symbol.NUMBER_UPPER, [SHIFT, ReduceActions.GT])
146-  .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
147+  .add(Symbol.FIXEDCELL, [SHIFT, 16])
148+  .add(Symbol.CELL_UPPER, [SHIFT, 17])
149+  .add(Symbol.VARIABLE, [SHIFT, 14])
150+  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
151+  .add(Symbol.POUND, [SHIFT, 18])
152   .build();
153 table[24] = ObjectBuilder
154   .add(Symbol.ERROR, 13)
155   .add(Symbol.EXPRESSION, 50)
156   .add(Symbol.VARIABLE_SEQUENCE, 3)
157-  .add(Symbol.TIME_AMPM, [SHIFT, ReduceActions.TIME_CALL])
158-  .add(Symbol.TIME_24, [SHIFT, ReduceActions.AS_NUMBER])
159+  .add(Symbol.TIME_AMPM, [SHIFT, 4])
160+  .add(Symbol.TIME_24, [SHIFT, 5])
161   .add(Symbol.NUMBER, 6)
162-  .add(Symbol.STRING, [SHIFT, ReduceActions.AMPERSAND])
163+  .add(Symbol.STRING, [SHIFT, 7])
164   .add(Symbol.EQUALS, [SHIFT, 49])
165-  .add(Symbol.PLUS, [SHIFT, ReduceActions.LAST_NUMBER])
166-  .add(Symbol.LEFT_PAREN, [SHIFT, ReduceActions.EQUALS])
167-  .add(Symbol.MINUS, [SHIFT, ReduceActions.PLUS])
168-  .add(Symbol.FUNCTION, [SHIFT, ReduceActions.LTE])
169+  .add(Symbol.PLUS, [SHIFT, 10])
170+  .add(Symbol.LEFT_PAREN, [SHIFT, 8])
171+  .add(Symbol.MINUS, [SHIFT, 9])
172+  .add(Symbol.FUNCTION, [SHIFT, 11])
173   .add(Symbol.CELL, 12)
174-  .add(Symbol.FIXEDCELL, [SHIFT, ReduceActions.LT])
175-  .add(Symbol.CELL_UPPER, [SHIFT, ReduceActions.MINUS])
176-  .add(Symbol.VARIABLE, [SHIFT, ReduceActions.NOT])
177-  .add(Symbol.NUMBER_UPPER, [SHIFT, ReduceActions.GT])
178-  .add(Symbol.POUND, [SHIFT, ReduceActions.MULTIPLY])
179+  .add(Symbol.FIXEDCELL, [SHIFT, 16])
180+  .add(Symbol.CELL_UPPER, [SHIFT, 17])
181+  .add(Symbol.VARIABLE, [SHIFT, 14])
182+  .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
183+  .add(Symbol.POUND, [SHIFT, 18])
184   .build();
185 table[25] = ObjectBuilder
186   .add(Symbol.ERROR, 13)
187   .add(Symbol.EXPRESSION, 51)
188   .add(Symbol.VARIABLE_SEQUENCE, 3)
189-  .add(Symbol.TIME_AMPM, [SHIFT, ReduceActions.TIME_CALL])
190-  .add(Symbol.TIME_24, [SHIFT, ReduceActions.AS_NUMBER])
191+  .add(Symbol.TIME_AMPM, [SHIFT, 4])
192+  .add(Symbol.TIME_24, [SHIFT, 5])
193   .add(Symbol.NUMBER, 6)
194   .add(Symbol.STRING, [SHIFT, ReduceActions.AMPERSAND])
195   .add(Symbol.PLUS, [SHIFT, ReduceActions.LAST_NUMBER])