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 8, 2024
1 parent 8d4aa62 commit bcb7f18
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mathics_scanner/tokeniser.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,17 @@ 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}")
# 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, f" {unicode} "))

literal_tokens = {
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 bcb7f18

Please sign in to comment.