Skip to content

Commit

Permalink
Handle boxing ternary operators
Browse files Browse the repository at this point in the history
They list two operators. We just need the first of these in "tokens".
  • Loading branch information
rocky committed Dec 25, 2024
1 parent 1a26150 commit 075a2b8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mathics_scanner/tokeniser.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,18 @@ def init_module():
("VerticalSeparator", r" \uF432 "),
]

for table in ("box-operators", "no-meaning-infix-operators"):
table_info = OPERATOR_DATA[table]
for table_name in ("box-operators", "no-meaning-infix-operators"):
table_info = OPERATOR_DATA[table_name]
for operator_name, unicode in table_info.items():
if any([tup[0] == operator_name for tup in tokens]):
print(f"Please remove {operator_name}")
tokens.append((operator_name, f" {unicode} "))
# if any([tup[0] == operator_name for tup in tokens]):
# print(f"Please remove {operator_name}")

# Ternary operators have two character symbols
# in a list. For tokens, we just want the first
# of the pair
if isinstance(unicode, list):
unicode = unicode[0]
tokens.append((operator_name, rf" {unicode} "))

literal_tokens = {
"!": ["Unequal", "Factorial2", "Factorial"],
Expand Down Expand Up @@ -264,14 +270,14 @@ def init_module():
"FormBox",
"FractionBox",
"InterpretedBox",
"OverunderscriptBox",
"OverscriptBox",
"RadicalBox",
"RawBackslash",
"SqrtBox",
"SubscriptBox",
"SuperscriptBox",
"UnderscriptBox",
"UnderoverscriptBox",
],
"]": ["RawRightBracket"],
"^": ["UpSetDelayed", "UpSet", "Power"],
Expand Down

0 comments on commit 075a2b8

Please sign in to comment.