Skip to content

Commit 87bc59d

Browse files
committed
fix parsing nested Boxes. remove debug print
1 parent 67a73cc commit 87bc59d

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

mathics/builtin/strings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,6 @@ def apply_dummy(self, boxes, evaluation):
17171717
# In the first place, this should handle different kind
17181718
# of boxes in different ways.
17191719
reinput = boxes.boxes_to_text()
1720-
print(reinput)
17211720
return Expression("ToExpression", reinput).evaluate(evaluation)
17221721

17231722

mathics/core/expression.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,8 @@ def boxes_to_text(self, **options) -> str:
15131513
)
15141514
elif self.has_form("SuperscriptBox", 2):
15151515
return "^".join([leaf.boxes_to_text(**options) for leaf in self._leaves])
1516+
elif self.has_form("FractionBox", 2):
1517+
return "/".join([" ( " + leaf.boxes_to_text(**options)+ " ) " for leaf in self._leaves])
15161518
else:
15171519
raise BoxError(self, "text")
15181520

mathics/core/parser/parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def parse_box(self, p):
170170
elif result is None and tag != "END":
171171
self.consume()
172172
new_result = String(token.text)
173+
if new_result.value == r"\(":
174+
new_result = self.p_LeftRowBox(token)
173175
else:
174176
new_result = None
175177
if new_result is None:
@@ -311,7 +313,8 @@ def p_LeftRowBox(self, token):
311313
self.bracket_depth += 1
312314
token = self.next()
313315
while token.tag not in ("RightRowBox", "OtherscriptBox"):
314-
children.append(self.parse_box(0))
316+
newnode = self.parse_box(0)
317+
children.append(newnode)
315318
token = self.next()
316319
if len(children) == 0:
317320
result = String("")

0 commit comments

Comments
 (0)