Skip to content

Commit d53f444

Browse files
authored
Fixed bug in symbolic parse where a Token is returned instead of an ExprNode. (#234)
1 parent 827aa78 commit d53f444

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

app/preview_tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ def test_natural_logarithm_notation(self):
7676
preview = result["preview"]
7777
assert preview["latex"] == r"\ln{\left(x \right)}"
7878

79+
@pytest.mark.parametrize(
80+
"response, response_latex, response_sympy", [
81+
("e", "e", "E",),
82+
("oo", "\\infty", "oo"),
83+
("ex", "e \\cdot x", "Ex"),
84+
("e * x", "e \\cdot x", "E * x")
85+
]
86+
)
87+
def test_eulers_number_notation(self, response, response_latex, response_sympy):
88+
params = Params(is_latex=False, elementary_functions=True, strict_syntax=False)
89+
result = preview_function(response, params)
90+
assert "preview" in result.keys()
91+
92+
preview = result["preview"]
93+
assert preview["latex"] == response_latex
94+
assert preview["sympy"] == response_sympy
95+
7996
@pytest.mark.parametrize(
8097
"response, is_latex, response_latex, response_sympy",
8198
[

app/utility/slr_parsing_utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,15 +815,15 @@ def parse(self, input_tokens, verbose=False):
815815
parse_action = self.parsing_action(stack[-1], a)
816816
if parse_action < len(self.states):
817817
stack.append(parse_action)
818-
output.append(a)
818+
output.append(ExprNode(a, []))
819819
if verbose:
820820
print("shift and transition to: "+self.state_string(self._states_index[parse_action])+" \t"+str(output))
821821
a = tokens.pop(0)
822822
elif parse_action == len(self.states):
823823
if verbose:
824824
print("ACCEPT")
825825
if len(tokens) > 0 and tokens != [self.end_token]:
826-
output += self.parse(tokens)
826+
output += ExprNode(self.parse(tokens), [])
827827
break
828828
elif parse_action <= len(self.states)+len(self.productions_token):
829829
production = productions_token[parse_action-len(self.states)]

0 commit comments

Comments
 (0)