spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← Commit log
commit
message
[ParserConstants] and again, more state enumerations
author
Ben Vogt <[email protected]>
date
2017-12-10 23:24:00
stats
2 file(s) changed, 9 insertions(+), 5 deletions(-)
files
src/Parser/ParserConstants.ts
tests/Parser/ParseEngineTest.ts
 1diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
 2index 1646d57..c64dfaf 100644
 3--- a/src/Parser/ParserConstants.ts
 4+++ b/src/Parser/ParserConstants.ts
 5@@ -371,7 +371,9 @@ const enum State {
 6   NUMBER_TO_POWER_OF_OTHER = 55,
 7   CLOSE_PAREN_ON_EXPRESSION = 57,
 8   COMPARE_TWO_EXPRESSIONS_WITH_GTE = 69,
 9-  CLOSE_PAREN_ON_FUNCTION = 70
10+  CLOSE_PAREN_ON_FUNCTION = 70,
11+  VARIABLE_FOLLOWED_BY_SEMI_COLON = 71,
12+  VARIABLE_FOLLOWED_BY_COMMA = 72
13 }
14 
15 
16@@ -1157,8 +1159,8 @@ table[58] = ObjectBuilder
17   .build();
18 table[59] = ObjectBuilder
19   .add(Symbol.RIGHT_PAREN, [SHIFT, State.CLOSE_PAREN_ON_FUNCTION])
20-  .add(Symbol.SEMI_COLON, [SHIFT, 71])
21-  .add(Symbol.COMMA, [SHIFT, 72])
22+  .add(Symbol.SEMI_COLON, [SHIFT, State.VARIABLE_FOLLOWED_BY_SEMI_COLON])
23+  .add(Symbol.COMMA, [SHIFT, State.VARIABLE_FOLLOWED_BY_COMMA])
24   .build();
25 table[60] = ObjectBuilder
26   .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
27@@ -1300,7 +1302,7 @@ table[State.CLOSE_PAREN_ON_FUNCTION] = ObjectBuilder
28   .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
29   .add(Symbol.COMMA, [REDUCE, ReduceActions.CALL_FUNCTION_LAST_TWO_IN_STACK])
30   .build();
31-table[71] = ObjectBuilder
32+table[State.VARIABLE_FOLLOWED_BY_SEMI_COLON] = ObjectBuilder
33   .add(Symbol.ERROR, 13)
34   .add(Symbol.EXPRESSION, 74)
35   .add(Symbol.VARIABLE_SEQUENCE, 3)
36@@ -1318,7 +1320,7 @@ table[71] = ObjectBuilder
37   .add(Symbol.NUMBER_UPPER, [SHIFT, 15])
38   .add(Symbol.POUND, [SHIFT, 18])
39   .build();
40-table[72] = ObjectBuilder
41+table[State.VARIABLE_FOLLOWED_BY_COMMA] = ObjectBuilder
42   .add(Symbol.ERROR, 13)
43   .add(Symbol.EXPRESSION, 75)
44   .add(Symbol.VARIABLE_SEQUENCE, 3)
45diff --git a/tests/Parser/ParseEngineTest.ts b/tests/Parser/ParseEngineTest.ts
46index 0effb61..2a46b2e 100644
47--- a/tests/Parser/ParseEngineTest.ts
48+++ b/tests/Parser/ParseEngineTest.ts
49@@ -521,4 +521,4 @@ test("Parse range following comma", function(){
50 
51 
52 
53-assertEquals(parser.parse('2^4'), 16);
54+assertEquals(parser.parse('SUM(1, 2, 3)'), 6);