commit
message
[Parser,ParserContants] fixing LTE evaluation
author
Ben Vogt <[email protected]>
date
2017-12-10 23:40:26
stats
3 file(s) changed,
10 insertions(+),
8 deletions(-)
files
src/Parser/ParserConstants.ts
src/Sheet.ts
tests/Parser/ParseEngineTest.ts
1diff --git a/src/Parser/ParserConstants.ts b/src/Parser/ParserConstants.ts
2index c64dfaf..87e3e28 100644
3--- a/src/Parser/ParserConstants.ts
4+++ b/src/Parser/ParserConstants.ts
5@@ -365,6 +365,7 @@ const enum State {
6 NUMBER_FOLLOWED_BY_SLASH = 28,
7 NUMBER_FOLLOWED_BY_CARROT = 29,
8 ADD_TWO_NUMBERS = 45,
9+ LESS_THAN_EQUALS = 46,
10 SUBTRACT_TWO_NUMBERS = 52,
11 MULTIPLY_TWO_NUMBERS = 53,
12 DIVIDE_TWO_NUMBERS = 54,
13@@ -684,7 +685,7 @@ table[State.LESS_THAN] = ObjectBuilder
14 .add(Symbol.VARIABLE_SEQUENCE, 3)
15 .add(Symbol.NUMBER, State.START_NUMBER)
16 .add(Symbol.STRING, [SHIFT, State.START_STRING])
17- .add(Symbol.EQUALS, [SHIFT, 46])
18+ .add(Symbol.EQUALS, [SHIFT, State.LESS_THAN_EQUALS])
19 .add(Symbol.PLUS, [SHIFT, 10])
20 .add(Symbol.LEFT_PAREN, [SHIFT, State.LEFT_PAREN])
21 .add(Symbol.GREATER_THAN, [SHIFT, 47])
22@@ -960,7 +961,7 @@ table[State.ADD_TWO_NUMBERS] = ObjectBuilder
23 .add(Symbol.SEMI_COLON, [REDUCE, ReduceActions.PLUS])
24 .add(Symbol.COMMA, [REDUCE, ReduceActions.PLUS])
25 .build();
26-table[46] = ObjectBuilder
27+table[State.LESS_THAN_EQUALS] = ObjectBuilder
28 .add(Symbol.ERROR, 13)
29 .add(Symbol.EXPRESSION, 67)
30 .add(Symbol.VARIABLE_SEQUENCE, 3)
31diff --git a/src/Sheet.ts b/src/Sheet.ts
32index 88935c9..4742d46 100644
33--- a/src/Sheet.ts
34+++ b/src/Sheet.ts
35@@ -377,7 +377,7 @@ let Sheet = (function () {
36 break;
37
38 case '<=':
39- result = (exp1 === exp2);
40+ result = (exp1 <= exp2);
41 break;
42
43 case '<>':
44diff --git a/tests/Parser/ParseEngineTest.ts b/tests/Parser/ParseEngineTest.ts
45index 2a46b2e..d9246d2 100644
46--- a/tests/Parser/ParseEngineTest.ts
47+++ b/tests/Parser/ParseEngineTest.ts
48@@ -207,7 +207,7 @@ let helper = {
49 break;
50
51 case '<=':
52- result = (exp1 === exp2);
53+ result = (exp1 <= exp2);
54 break;
55
56 case '<>':
57@@ -376,7 +376,7 @@ test("Parse equality operators", function(){
58 assertEquals(parser.parse('1 < 2'), true);
59 assertEquals(parser.parse('1 < 0'), false);
60 assertEquals(parser.parse('1 <= 1'), true);
61- // assertEquals('= 1 <= 2', true); // TODO: Fails.
62+ assertEquals(parser.parse('1 <= 2'), true);// fails...
63 assertEquals(parser.parse('1 >= 1'), true);
64 assertEquals(parser.parse('2 >= 1'), true);
65 assertEquals(parser.parse('1 >= 0'), true);
66@@ -388,7 +388,7 @@ test("Parse equality operators", function(){
67 test("Parse operators, order of operations", function(){
68 assertEquals(parser.parse('10 + -10'), 0);
69 assertEquals(parser.parse('10 + -10 = 0'), true);
70- // assertEquals(parser.parse('10 + -10 = 0 & "str"'), false); // TODO should pass.
71+ assertEquals(parser.parse('10 + -10 = 0 & "str"'), false);
72 assertEquals(parser.parse('-10%'), -0.1);
73 assertEquals(parser.parse('10 + 10%'), 10.1);
74 assertEquals(parser.parse('-10 + 10%'), -9.9);
75@@ -521,4 +521,4 @@ test("Parse range following comma", function(){
76
77
78
79-assertEquals(parser.parse('SUM(1, 2, 3)'), 6);
80+assertEquals(parser.parse('1 <= 2'), true);