diff --git a/Makefile b/Makefile index 0619c3fc6..29c1232f0 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,7 @@ latexdoc texdoc doc: #: Build JSON ASCII to unicode opcode table and operator table mathics/data/operator-tables.json mathics/data/op-tables.json mathics/data/operators.json: - $(BASH) ./admin-tools/make-op-tables.sh + $(BASH) ./admin-tools/make-JSON-tables.sh #: Remove ChangeLog rmChangeLog: diff --git a/admin-tools/make-op-tables.sh b/admin-tools/make-JSON-tables.sh similarity index 93% rename from admin-tools/make-op-tables.sh rename to admin-tools/make-JSON-tables.sh index ce3fa01ba..8a166d9da 100755 --- a/admin-tools/make-op-tables.sh +++ b/admin-tools/make-JSON-tables.sh @@ -10,6 +10,7 @@ mathics3-generate-json-table \ --field=ascii-operator-to-unicode \ --field=ascii-operator-to-wl-unicode \ --field=operator-to-ascii \ + --field=operator-to-amslatex \ --field=operator-to-unicode \ -o op-tables.json mathics3-generate-operator-json-table -o operator-tables.json diff --git a/mathics/core/builtin.py b/mathics/core/builtin.py index fbcff0b9d..96bc141fd 100644 --- a/mathics/core/builtin.py +++ b/mathics/core/builtin.py @@ -1159,10 +1159,10 @@ class Operator(Builtin): default_formats = True def get_precedence(self, name: str) -> int: - operator_info = OPERATOR_DATA.get("operator-precedence") + operator_info = OPERATOR_DATA.get("operator-precedences") assert isinstance( operator_info, dict - ), 'Internal error: "operator-precedence" should be found in operators.json' + ), 'Internal error: "operator-precedences" should be found in operators.json' precedence = operator_info.get(name) assert isinstance( precedence, int diff --git a/mathics/core/convert/op.py b/mathics/core/convert/op.py index 92334647d..95d5b1ac9 100644 --- a/mathics/core/convert/op.py +++ b/mathics/core/convert/op.py @@ -22,6 +22,7 @@ OPERATOR_CONVERSION_TABLES = ujson.load(f) ascii_operator_to_symbol = OPERATOR_CONVERSION_TABLES["ascii-operator-to-symbol"] +builtin_constants = OPERATOR_CONVERSION_TABLES["builtin-constants"] operator_to_unicode = OPERATOR_CONVERSION_TABLES["operator-to-unicode"] operator_to_ascii = OPERATOR_CONVERSION_TABLES["operator-to-ascii"] diff --git a/mathics/core/parser/operators.py b/mathics/core/parser/operators.py index b939e2343..ab6e8814e 100644 --- a/mathics/core/parser/operators.py +++ b/mathics/core/parser/operators.py @@ -33,7 +33,8 @@ left_binary_operators = OPERATOR_DATA["left-binary-operators"] misc_operators = OPERATOR_DATA["miscellaneous-operators"] nonassoc_binary_operators = OPERATOR_DATA["non-associative-binary-operators"] -operator_precedences = OPERATOR_DATA["operator-precedence"] +operator_precedences = OPERATOR_DATA["operator-precedences"] +operator_to_amslatex = OPERATOR_DATA["operator-to-amslatex"] postfix_operators = OPERATOR_DATA["postfix-operators"] prefix_operators = OPERATOR_DATA["prefix-operators"] right_binary_operators = OPERATOR_DATA["right-binary-operators"] diff --git a/mathics/core/parser/parser.py b/mathics/core/parser/parser.py index 2fe78228b..e3f5c1259 100644 --- a/mathics/core/parser/parser.py +++ b/mathics/core/parser/parser.py @@ -13,6 +13,7 @@ from mathics_scanner import InvalidSyntaxError, TranslateError from mathics_scanner.tokeniser import Token, Tokeniser, is_symbol_name +from mathics.core.convert.op import builtin_constants from mathics.core.parser.ast import ( Filename, Node, @@ -39,15 +40,11 @@ ternary_operators, ) -# FIXME: get from JSON -special_symbols = { - "\u03C0": "Pi", # Pi - "\uF74D": "E", # ExponentialE - "\uF74E": "I", # ImaginaryI - "\uF74F": "I", # ImaginaryJ - "\u221E": "Infinity", # Infinity - "\u00B0": "Degree", # Degree -} +special_symbols = builtin_constants.copy() +# FIXME: should rework so we don't have to do this +# We have the character name ImaginaryI and ImaginaryJ, but we should +# have the *operator* name, "I". +special_symbols["\uF74F"] = special_symbols["\uF74E"] = "I" # An operator precedence value that will ensure that whatever operator