From bcb7f18973ada59f6d17efb4cf59055ddd1f81be Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 7 Dec 2024 20:41:11 -0500 Subject: [PATCH] Handle boxing ternary operators They list two operators. We just need the first of these in "tokens". --- mathics_scanner/tokeniser.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mathics_scanner/tokeniser.py b/mathics_scanner/tokeniser.py index cdaac50..a7a2fff 100644 --- a/mathics_scanner/tokeniser.py +++ b/mathics_scanner/tokeniser.py @@ -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 = { @@ -264,7 +270,6 @@ def init_module(): "FormBox", "FractionBox", "InterpretedBox", - "OverunderscriptBox", "OverscriptBox", "RadicalBox", "RawBackslash", @@ -272,6 +277,7 @@ def init_module(): "SubscriptBox", "SuperscriptBox", "UnderscriptBox", + "UnderoverscriptBox", ], "]": ["RawRightBracket"], "^": ["UpSetDelayed", "UpSet", "Power"],