commit
message
[ParserConstants] back to state enumeration
author
Ben Vogt <[email protected]>
date
2017-12-20 02:31:08
stats
4 file(s) changed,
5 insertions(+),
42 deletions(-)
files
src/Parser/DataStore.ts
src/Parser/DataStoreInterface.ts
src/Parser/ObjectBuilder.ts
src/Utilities/ObjectBuilder.ts
src/Parser/ParserConstants.ts
1diff --git a/src/Parser/DataStore.ts b/src/Parser/DataStore.ts
2index 73d25b0..e98b491 100644
3--- a/src/Parser/DataStore.ts
4+++ b/src/Parser/DataStore.ts
5@@ -4,14 +4,11 @@
6 import {
7 Cell
8 } from "../Cell";
9-import {
10- DataStoreInterface
11-} from "./DataStoreInterface";
12
13 /**
14 * Cell DataStore that stores cells in memory.
15 */
16-class DataStore implements DataStoreInterface {
17+class DataStore {
18 /**
19 * Holds cells inside an object for quick access.
20 */
21diff --git a/src/Parser/DataStoreInterface.ts b/src/Parser/DataStoreInterface.ts
22deleted file mode 100644
23index 3999653..0000000
24--- a/src/Parser/DataStoreInterface.ts
25+++ /dev/null
26@@ -1,35 +0,0 @@
27-import {
28- Cell
29-} from "../Cell";
30-
31-/**
32- * Interface to add and get cells.
33- */
34-interface DataStoreInterface {
35-
36- /**
37- * Gets the cell corresponding to the key. If the value is undefined, will return blank cell..
38- * @param key to look up cell
39- * @returns {Cell} to return, if it exists. Returns blank cell if key not in matrix.
40- */
41- getCell(key: string) : Cell;
42-
43- /**
44- * Add cell to matrix. If it exists, update the necessary values. If it doesn't exist add it.
45- * @param cell to add to matrix.
46- * @returns {Cell} Returns the cell after it has been added.
47- */
48- addCell(cell: Cell);
49-
50- /**
51- * Get all dependencies for a specific cell.
52- * @param id of cell
53- * @returns {Array} of A1-format cell ID dependencies, in no particular oder.
54- */
55- getDependencies(id: string) : Array<any>;
56-
57-}
58-
59-export {
60- DataStoreInterface
61-}
62\ No newline at end of file
63diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
64index 1145f3b..c2a6abb 100644
65--- a/src/Parser/ParserConstants.ts
66+++ b/src/Parser/ParserConstants.ts
67@@ -1,6 +1,6 @@
68 import {
69 ObjectBuilder
70-} from "./ObjectBuilder";
71+} from "../Utilities/ObjectBuilder";
72
73 // Rules represent the Regular Expressions that will be used in sequence to match a given input to the Parser.
74 const WHITE_SPACE_RULE = /^(?:\s+)/;
75@@ -355,6 +355,7 @@ const enum State {
76 START_NUMBER = 6,
77 START_STRING = 7,
78 LEFT_PAREN = 8,
79+ EOF_AND_RETURN_LAST = 19,
80 NUMBER_FOLLOWED_BY_AMPERSAND = 20,
81 START_EQUALS = 21,
82 NUMBER_FOLLOWED_BY_PLUS = 22,
83@@ -408,7 +409,7 @@ table[1] = ObjectBuilder
84 .add(Symbol.END, [ACCEPT])
85 .build();
86 table[2] = ObjectBuilder
87- .add(Symbol.EOF, [SHIFT, 19])
88+ .add(Symbol.EOF, [SHIFT, State.EOF_AND_RETURN_LAST])
89 .add(Symbol.AMPERSAND, [SHIFT, State.NUMBER_FOLLOWED_BY_AMPERSAND])
90 .add(Symbol.EQUALS, [SHIFT, State.START_EQUALS])
91 .add(Symbol.PLUS, [SHIFT, State.NUMBER_FOLLOWED_BY_PLUS])
92@@ -626,7 +627,7 @@ table[18] = ObjectBuilder
93 .add(Symbol.RIGHT_PAREN, [REDUCE, ReduceActions.AS_ERROR])
94 .add(Symbol.COMMA, [REDUCE, ReduceActions.AS_ERROR])
95 .build();
96-table[19] = ObjectBuilder
97+table[State.EOF_AND_RETURN_LAST] = ObjectBuilder
98 .add(Symbol.END, [REDUCE, ReduceActions.RETURN_LAST])
99 .build();
100 table[State.NUMBER_FOLLOWED_BY_AMPERSAND] = ObjectBuilder
101diff --git a/src/Parser/ObjectBuilder.ts b/src/Utilities/ObjectBuilder.ts
102similarity index 100%
103rename from src/Parser/ObjectBuilder.ts
104rename to src/Utilities/ObjectBuilder.ts