commit
message
[ParserConstants] State.ADD_TWO_NUMBERS, State.SUBTRACT_TWO_NUMBERS
author
Ben Vogt <[email protected]>
date
2017-12-10 04:47:20
stats
2 file(s) changed,
19 insertions(+),
5 deletions(-)
files
src/Parser/Parser.ts
src/Parser/ParserConstants.ts
1diff --git a/src/Parser/Parser.ts b/src/Parser/Parser.ts
2index 4e06cfb..4c0d2bc 100644
3--- a/src/Parser/Parser.ts
4+++ b/src/Parser/Parser.ts
5@@ -358,6 +358,17 @@ let Parser = (function () {
6 action = ACTION_TABLE[state] && ACTION_TABLE[state][symbol];
7 }
8
9+ console.log({
10+ text: lexer.match,
11+ token: SYMBOL_INDEX_TO_NAME[symbol] || symbol,
12+ tokenIndex: symbol,
13+ line: lexer.yylineno,
14+ loc: yyloc,
15+ state: state,
16+ stack: stack,
17+ semanticValueStack: semanticValueStack
18+ });
19+
20 // handle parse error
21 if (typeof action === 'undefined' || !action.length || !action[0]) {
22 let error_rule_depth;
23diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
24index e39232d..da018a5 100644
25--- a/src/Parser/ParserConstants.ts
26+++ b/src/Parser/ParserConstants.ts
27@@ -360,7 +360,9 @@ const SYMBOL_INDEX_TO_NAME = symbolIndexToName;
28
29 const enum State {
30 START = 0,
31- START_NUMBER = 6
32+ START_NUMBER = 6,
33+ ADD_TWO_NUMBERS = 45,
34+ SUBTRACT_TWO_NUMBERS = 52
35 }
36
37
38@@ -420,7 +422,7 @@ table[3] = ObjectBuilder
39 .add(Symbol.CARROT, [REDUCE, ReduceActions.CALL_VARIABLE])
40 .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.CALL_VARIABLE])
41 .add(Symbol.COMMA, [REDUCE, ReduceActions.CALL_VARIABLE])
42- .add(33, [SHIFT, ReduceActions.CELL_VALUE])
43+ .add(Symbol.DECIMAL, [SHIFT, ReduceActions.CELL_VALUE])
44 .build();
45 table[State.START_NUMBER] = ObjectBuilder
46 .add(Symbol.EOF, [REDUCE, ReduceActions.AS_NUMBER])
47@@ -731,7 +733,7 @@ table[25] = ObjectBuilder
48 .build();
49 table[26] = ObjectBuilder
50 .add(Symbol.ERROR, 13)
51- .add(Symbol.EXPRESSION, 52)
52+ .add(Symbol.EXPRESSION, State.SUBTRACT_TWO_NUMBERS)
53 .add(Symbol.VARIABLE_SEQUENCE, 3)
54 .add(Symbol.NUMBER, State.START_NUMBER)
55 .add(Symbol.STRING, [SHIFT, 7])
56@@ -949,7 +951,7 @@ table[44] = ObjectBuilder
57 .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.EQUALS])
58 .add(Symbol.COMMA, [REDUCE, ReduceActions.EQUALS])
59 .build();
60-table[45] = ObjectBuilder
61+table[State.ADD_TWO_NUMBERS] = ObjectBuilder
62 .add(Symbol.EOF, [REDUCE, ReduceActions.PLUS])
63 .add(Symbol.AMPERSAND, [SHIFT, 20])
64 .add(Symbol.EQUALS, [REDUCE, ReduceActions.PLUS])
65@@ -1064,7 +1066,7 @@ table[51] = ObjectBuilder
66 .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.NOT])
67 .add(Symbol.COMMA, [REDUCE, ReduceActions.NOT])
68 .build();
69-table[52] = ObjectBuilder
70+table[State.SUBTRACT_TWO_NUMBERS] = ObjectBuilder
71 .add(Symbol.EOF, [REDUCE, ReduceActions.MINUS])
72 .add(Symbol.AMPERSAND, [SHIFT, ReduceActions.TO_POWER])
73 .add(Symbol.EQUALS, [REDUCE, ReduceActions.MINUS])