commit
message
[Parser,Rules,ObjectFromPairs] Using INDEX_ naming scheme to make refactoring of rule-sets easier
author
Ben Vogt <[email protected]>
date
2017-08-14 01:07:26
stats
2 file(s) changed,
147 insertions(+),
129 deletions(-)
files
src/Parser/Parser.ts
src/Parser/Rules.ts
1diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
2index 7f906db..032ccfc 100644
3--- a/src/Parser/Parser.ts
4+++ b/src/Parser/Parser.ts
5@@ -1,43 +1,43 @@
6 import {
7 RULES,
8
9- WHITE_SPACE_RULE_INDEX,
10- DOUBLE_QUOTES_RULE_INDEX,
11- SINGLE_QUOTES_RULE_INDEX,
12- FORMULA_NAME_RULE_INDEX,
13- DATE_RULE_INDEX,
14- TIME_RULE_INDEX,
15- $_A1_CELL_RULE_INDEX,
16- A1_CELL_RULE_INDEX,
17- FORMULA_NAME_SIMPLE_RULE_INDEX,
18- VARIABLE_RULE_INDEX,
19- SIMPLE_VARIABLE_RILE_INDEX,
20- INTEGER_RULE_INDEX,
21- OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
22- DOLLAR_SIGN_RULE_INDEX,
23- AMPERSAND_SIGN_RULE_INDEX,
24- SINGLE_WHITESPACE_RULE_INDEX,
25- PERIOD_RULE_INDEX,
26- COLON_RULE_INDEX,
27- SEMI_COLON_RULE_INDEX,
28- COMMA_RULE_INDEX,
29- ASTERISK_RULE_INDEX,
30- FORWARD_SLASH_RULE_INDEX,
31- MINUS_SIGN_RULE_INDEX,
32- PLUS_SIGN_RULE_INDEX,
33- CARET_SIGN_RULE_INDEX,
34- OPEN_PAREN_RULE_INDEX,
35- CLOSE_PAREN_RULE_INDEX,
36- GREATER_THAN_SIGN_RULE_INDEX,
37- LESS_THAN_SIGN_RULE_INDEX,
38- NOT_RULE_INDEX,
39- OPEN_DOUBLE_QUOTE_INDEX,
40- OPEN_SINGLE_QUITE_INDEX,
41- EXCLAMATION_POINT_RULE_INDEX,
42- EQUALS_SIGN_RULE_INDEX,
43- PERCENT_SIGN_RULE_INDEX,
44- HASH_SIGN_RULE_INDEX,
45- END_OF_STRING_RULE_INDEX
46+ INDEX0,
47+ INDEX1,
48+ INDEX2,
49+ INDEX3,
50+ INDEX4,
51+ INDEX5,
52+ INDEX6,
53+ INDEX7,
54+ INDEX8,
55+ INDEX9,
56+ INDEX10,
57+ INDEX11,
58+ INDEX12,
59+ INDEX13,
60+ INDEX14,
61+ INDEX15,
62+ INDEX16,
63+ INDEX17,
64+ INDEX18,
65+ INDEX19,
66+ INDEX20,
67+ INDEX21,
68+ INDEX22,
69+ INDEX23,
70+ INDEX24,
71+ INDEX25,
72+ INDEX26,
73+ INDEX27,
74+ INDEX28,
75+ INDEX29,
76+ INDEX30,
77+ INDEX31,
78+ INDEX32,
79+ INDEX33,
80+ INDEX34,
81+ INDEX35,
82+ INDEX36
83 } from "./Rules";
84 import {
85 ObjectFromPairs
86@@ -418,9 +418,9 @@ var Parser = (function () {
87 },
88 table: [
89 ObjectFromPairs.of([
90- SINGLE_QUOTES_RULE_INDEX, 13,
91- FORMULA_NAME_RULE_INDEX, 1,
92- DATE_RULE_INDEX, 2,
93+ INDEX2, 13,
94+ INDEX3, 1,
95+ INDEX4, 2,
96 6, 3,
97 7, $V0,
98 8, $V1,
99@@ -436,37 +436,45 @@ var Parser = (function () {
100 32, $V9,
101 34, $Va,
102 36, $Vb
103- ]),{1: [3]}, {
104- 5: [1, 19],
105- 11: $Vc,
106- 12: $Vd,
107- 13: $Ve,
108- 16: $Vf,
109- 17: $Vg,
110- 18: $Vh,
111- 19: $Vi,
112- 20: $Vj,
113- 21: $Vk,
114- 22: $Vl
115- }, o($Vm, [2, 2], {33: [1, 30]}), o($Vm, [2, 3]), o($Vm, [2, 4]), o($Vm, [2, 5], {35: [1, 31]}), o($Vm, [2, 6]), {
116- 2: 13,
117- 4: 32,
118- 6: 3,
119- 7: $V0,
120- 8: $V1,
121- 9: 6,
122- 10: $V2,
123- 13: $V3,
124- 14: $V4,
125- 19: $V5,
126- 23: $V6,
127- 25: 12,
128- 26: $V7,
129- 28: $V8,
130- 32: $V9,
131- 34: $Va,
132- 36: $Vb
133- }, {
134+ ]),
135+ {1: [3]},
136+ ObjectFromPairs.of([
137+ INDEX5, [1, 19],
138+ INDEX11, $Vc,
139+ INDEX12, $Vd,
140+ INDEX13, $Ve,
141+ INDEX16, $Vf,
142+ INDEX17, $Vg,
143+ INDEX18, $Vh,
144+ INDEX19, $Vi,
145+ INDEX20, $Vj,
146+ INDEX21, $Vk,
147+ INDEX22, $Vl
148+ ]),
149+ o($Vm, [2, 2], {33: [1, 30]}),
150+ o($Vm, [2, 3]),
151+ o($Vm, [2, 4]),
152+ o($Vm, [2, 5], {35: [1, 31]}),
153+ o($Vm, [2, 6]),
154+ {
155+ 2: 13,
156+ 4: 32,
157+ 6: 3,
158+ 7: $V0,
159+ 8: $V1,
160+ 9: 6,
161+ 10: $V2,
162+ 13: $V3,
163+ 14: $V4,
164+ 19: $V5,
165+ 23: $V6,
166+ 25: 12,
167+ 26: $V7,
168+ 28: $V8,
169+ 32: $V9,
170+ 34: $Va,
171+ 36: $Vb
172+ }, {
173 2: 13,
174 4: 33,
175 6: 3,
176diff --git a/src/Parser/Rules.ts b/src/Parser/Rules.ts
177index f0c3d51..2d7601e 100644
178--- a/src/Parser/Rules.ts
179+++ b/src/Parser/Rules.ts
180@@ -82,83 +82,83 @@ const RULES = [
181
182 // While it is unlikely that an index for a given rule will change, initializing them with `indexOf` will allow me to
183 // change their ordering without having to find and replace indexes manually.
184-const WHITE_SPACE_RULE_INDEX = RULES.indexOf(WHITE_SPACE_RULE);
185-const DOUBLE_QUOTES_RULE_INDEX = RULES.indexOf(DOUBLE_QUOTES_RULE);
186-const SINGLE_QUOTES_RULE_INDEX = RULES.indexOf(SINGLE_QUOTES_RULE);
187-const FORMULA_NAME_RULE_INDEX = RULES.indexOf(FORMULA_NAME_RULE);
188-const DATE_RULE_INDEX = RULES.indexOf(DATE_RULE);
189-const TIME_RULE_INDEX = RULES.indexOf(TIME_RULE);
190-const $_A1_CELL_RULE_INDEX = RULES.indexOf($_A1_CELL_RULE);
191-const A1_CELL_RULE_INDEX = RULES.indexOf(A1_CELL_RULE);
192-const FORMULA_NAME_SIMPLE_RULE_INDEX = RULES.indexOf(FORMULA_NAME_SIMPLE_RULE);
193-const VARIABLE_RULE_INDEX = RULES.indexOf(VARIABLE_RULE);
194-const SIMPLE_VARIABLE_RILE_INDEX = RULES.indexOf(SIMPLE_VARIABLE_RILE);
195-const INTEGER_RULE_INDEX = RULES.indexOf(INTEGER_RULE);
196-const OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX = RULES.indexOf(OPEN_AND_CLOSE_OF_ARRAY_RULE);
197-const DOLLAR_SIGN_RULE_INDEX = RULES.indexOf(DOLLAR_SIGN_RULE);
198-const AMPERSAND_SIGN_RULE_INDEX = RULES.indexOf(AMPERSAND_SIGN_RULE);
199-const SINGLE_WHITESPACE_RULE_INDEX = RULES.indexOf(SINGLE_WHITESPACE_RULE);
200-const PERIOD_RULE_INDEX = RULES.indexOf(PERIOD_RULE);
201-const COLON_RULE_INDEX = RULES.indexOf(COLON_RULE);
202-const SEMI_COLON_RULE_INDEX = RULES.indexOf(SEMI_COLON_RULE);
203-const COMMA_RULE_INDEX = RULES.indexOf(COMMA_RULE);
204-const ASTERISK_RULE_INDEX = RULES.indexOf(ASTERISK_RULE);
205-const FORWARD_SLASH_RULE_INDEX = RULES.indexOf(FORWARD_SLASH_RULE);
206-const MINUS_SIGN_RULE_INDEX = RULES.indexOf(MINUS_SIGN_RULE);
207-const PLUS_SIGN_RULE_INDEX = RULES.indexOf(PLUS_SIGN_RULE);
208-const CARET_SIGN_RULE_INDEX = RULES.indexOf(CARET_SIGN_RULE);
209-const OPEN_PAREN_RULE_INDEX = RULES.indexOf(OPEN_PAREN_RULE);
210-const CLOSE_PAREN_RULE_INDEX = RULES.indexOf(CLOSE_PAREN_RULE);
211-const GREATER_THAN_SIGN_RULE_INDEX = RULES.indexOf(GREATER_THAN_SIGN_RULE);
212-const LESS_THAN_SIGN_RULE_INDEX = RULES.indexOf(LESS_THAN_SIGN_RULE);
213-const NOT_RULE_INDEX = RULES.indexOf(NOT_RULE);
214-const OPEN_DOUBLE_QUOTE_INDEX = RULES.indexOf(OPEN_DOUBLE_QUOTE);
215-const OPEN_SINGLE_QUITE_INDEX = RULES.indexOf(OPEN_SINGLE_QUITE);
216-const EXCLAMATION_POINT_RULE_INDEX = RULES.indexOf(EXCLAMATION_POINT_RULE);
217-const EQUALS_SIGN_RULE_INDEX = RULES.indexOf(EQUALS_SIGN_RULE);
218-const PERCENT_SIGN_RULE_INDEX = RULES.indexOf(PERCENT_SIGN_RULE);
219-const HASH_SIGN_RULE_INDEX = RULES.indexOf(HASH_SIGN_RULE);
220-const END_OF_STRING_RULE_INDEX = RULES.indexOf(END_OF_STRING_RULE);
221+const INDEX0 = RULES.indexOf(WHITE_SPACE_RULE);
222+const INDEX1 = RULES.indexOf(DOUBLE_QUOTES_RULE);
223+const INDEX2 = RULES.indexOf(SINGLE_QUOTES_RULE);
224+const INDEX3 = RULES.indexOf(FORMULA_NAME_RULE);
225+const INDEX4 = RULES.indexOf(DATE_RULE);
226+const INDEX5 = RULES.indexOf(TIME_RULE);
227+const INDEX6 = RULES.indexOf($_A1_CELL_RULE);
228+const INDEX7 = RULES.indexOf(A1_CELL_RULE);
229+const INDEX8 = RULES.indexOf(FORMULA_NAME_SIMPLE_RULE);
230+const INDEX9 = RULES.indexOf(VARIABLE_RULE);
231+const INDEX10 = RULES.indexOf(SIMPLE_VARIABLE_RILE);
232+const INDEX11 = RULES.indexOf(INTEGER_RULE);
233+const INDEX12 = RULES.indexOf(OPEN_AND_CLOSE_OF_ARRAY_RULE);
234+const INDEX13 = RULES.indexOf(DOLLAR_SIGN_RULE);
235+const INDEX14 = RULES.indexOf(AMPERSAND_SIGN_RULE);
236+const INDEX15 = RULES.indexOf(SINGLE_WHITESPACE_RULE);
237+const INDEX16 = RULES.indexOf(PERIOD_RULE);
238+const INDEX17 = RULES.indexOf(COLON_RULE);
239+const INDEX18 = RULES.indexOf(SEMI_COLON_RULE);
240+const INDEX19 = RULES.indexOf(COMMA_RULE);
241+const INDEX20 = RULES.indexOf(ASTERISK_RULE);
242+const INDEX21 = RULES.indexOf(FORWARD_SLASH_RULE);
243+const INDEX22 = RULES.indexOf(MINUS_SIGN_RULE);
244+const INDEX23 = RULES.indexOf(PLUS_SIGN_RULE);
245+const INDEX24 = RULES.indexOf(CARET_SIGN_RULE);
246+const INDEX25 = RULES.indexOf(OPEN_PAREN_RULE);
247+const INDEX26 = RULES.indexOf(CLOSE_PAREN_RULE);
248+const INDEX27 = RULES.indexOf(GREATER_THAN_SIGN_RULE);
249+const INDEX28 = RULES.indexOf(LESS_THAN_SIGN_RULE);
250+const INDEX29 = RULES.indexOf(NOT_RULE);
251+const INDEX30 = RULES.indexOf(OPEN_DOUBLE_QUOTE);
252+const INDEX31 = RULES.indexOf(OPEN_SINGLE_QUITE);
253+const INDEX32 = RULES.indexOf(EXCLAMATION_POINT_RULE);
254+const INDEX33 = RULES.indexOf(EQUALS_SIGN_RULE);
255+const INDEX34 = RULES.indexOf(PERCENT_SIGN_RULE);
256+const INDEX35 = RULES.indexOf(HASH_SIGN_RULE);
257+const INDEX36 = RULES.indexOf(END_OF_STRING_RULE);
258
259
260 export {
261 RULES,
262
263- WHITE_SPACE_RULE_INDEX,
264- DOUBLE_QUOTES_RULE_INDEX,
265- SINGLE_QUOTES_RULE_INDEX,
266- FORMULA_NAME_RULE_INDEX,
267- DATE_RULE_INDEX,
268- TIME_RULE_INDEX,
269- $_A1_CELL_RULE_INDEX,
270- A1_CELL_RULE_INDEX,
271- FORMULA_NAME_SIMPLE_RULE_INDEX,
272- VARIABLE_RULE_INDEX,
273- SIMPLE_VARIABLE_RILE_INDEX,
274- INTEGER_RULE_INDEX,
275- OPEN_AND_CLOSE_OF_ARRAY_RULE_INDEX,
276- DOLLAR_SIGN_RULE_INDEX,
277- AMPERSAND_SIGN_RULE_INDEX,
278- SINGLE_WHITESPACE_RULE_INDEX,
279- PERIOD_RULE_INDEX,
280- COLON_RULE_INDEX,
281- SEMI_COLON_RULE_INDEX,
282- COMMA_RULE_INDEX,
283- ASTERISK_RULE_INDEX,
284- FORWARD_SLASH_RULE_INDEX,
285- MINUS_SIGN_RULE_INDEX,
286- PLUS_SIGN_RULE_INDEX,
287- CARET_SIGN_RULE_INDEX,
288- OPEN_PAREN_RULE_INDEX,
289- CLOSE_PAREN_RULE_INDEX,
290- GREATER_THAN_SIGN_RULE_INDEX,
291- LESS_THAN_SIGN_RULE_INDEX,
292- NOT_RULE_INDEX,
293- OPEN_DOUBLE_QUOTE_INDEX,
294- OPEN_SINGLE_QUITE_INDEX,
295- EXCLAMATION_POINT_RULE_INDEX,
296- EQUALS_SIGN_RULE_INDEX,
297- PERCENT_SIGN_RULE_INDEX,
298- HASH_SIGN_RULE_INDEX,
299- END_OF_STRING_RULE_INDEX
300+ INDEX0,
301+ INDEX1,
302+ INDEX2,
303+ INDEX3,
304+ INDEX4,
305+ INDEX5,
306+ INDEX6,
307+ INDEX7,
308+ INDEX8,
309+ INDEX9,
310+ INDEX10,
311+ INDEX11,
312+ INDEX12,
313+ INDEX13,
314+ INDEX14,
315+ INDEX15,
316+ INDEX16,
317+ INDEX17,
318+ INDEX18,
319+ INDEX19,
320+ INDEX20,
321+ INDEX21,
322+ INDEX22,
323+ INDEX23,
324+ INDEX24,
325+ INDEX25,
326+ INDEX26,
327+ INDEX27,
328+ INDEX28,
329+ INDEX29,
330+ INDEX30,
331+ INDEX31,
332+ INDEX32,
333+ INDEX33,
334+ INDEX34,
335+ INDEX35,
336+ INDEX36
337 }
338\ No newline at end of file