From b5036fa8678c8b02a1f3acf54b5a76fb1bfeb880 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 1 Mar 2026 16:18:57 -0500 Subject: [PATCH 1/3] Adjust to using current Mathics3-Scanner API --- Makefile | 2 +- .../{make-tables.sh => make-JSON-tables.sh} | 2 +- mathicsscript/completion.py | 9 +++++---- mathicsscript/data/inputrc-no-unicode | 8 ++++---- mathicsscript/data/inputrc-unicode | 8 ++++---- mathicsscript/data/mma-tables.json | 2 +- mathicsscript/format.py | 6 ++---- mathicsscript/settings.py | 5 +++++ mathicsscript/termshell_gnu.py | 15 +++++++++------ mathicsscript/termshell_prompt.py | 6 ++++-- 10 files changed, 36 insertions(+), 27 deletions(-) rename admin-tools/{make-tables.sh => make-JSON-tables.sh} (84%) diff --git a/Makefile b/Makefile index 8d61f36..81a7cab 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ check: inputrc inputrc: mathicsscript/data/inputrc-unicode mathicsscript/data/inputrc-no-unicode mathicsscript/data/inputrc-unicode mathicsscript/data/inputrc-no-unicode mathicsscript/data/inputrc-unicode/mma-tables.json: - $(SHELL) ./admin-tools/make- @echo "# GNU Readline input unicode translations\n# Autogenerated from mathics_scanner.generate.rl_inputrc on $$(date)\n" > $@ + $(SHELL) ./admin-tools/make-JSON-tables.sh # Check StructuredText long description formatting check-rst: diff --git a/admin-tools/make-tables.sh b/admin-tools/make-JSON-tables.sh similarity index 84% rename from admin-tools/make-tables.sh rename to admin-tools/make-JSON-tables.sh index fa0b76c..3d14cb9 100755 --- a/admin-tools/make-tables.sh +++ b/admin-tools/make-JSON-tables.sh @@ -4,7 +4,7 @@ mydir=$(dirname $bs) PYTHON=${PYTHON:-python} cd $mydir/../mathicsscript/data -mathics3-generate-json-table --field=ascii-operators -o mma-tables.json +mathics3-make-named-character-json --field=ascii-operators -o mma-tables.json for file in inputrc-unicode inputrc-no-unicode; do echo "# GNU Readline input unicode translations" > $file diff --git a/mathicsscript/completion.py b/mathicsscript/completion.py index 813ffbf..db6a12a 100644 --- a/mathicsscript/completion.py +++ b/mathicsscript/completion.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2021-2022, 2024-2025 Rocky Bernstein +# Copyright (C) 2021-2022, 2024-2026 Rocky Bernstein # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -21,8 +21,9 @@ from typing import Iterable, List, NamedTuple, Tuple from mathics.core.symbols import strip_context -from mathics_scanner import named_characters from mathics_pygments.lexer import Regex +from mathicsscript.settings import NAMED_CHARACTERS + from prompt_toolkit.completion import ( CompleteEvent, Completer, @@ -82,11 +83,11 @@ def get_completions( yield Completion(cmd, -len(word)) -class MathicsCompleter(WordCompleter): +class Mathics3Completer(WordCompleter): def __init__(self, definitions): self.definitions = definitions self.completer = WordCompleter([]) - self.named_characters = sorted(named_characters.keys()) + self.named_characters = sorted(NAMED_CHARACTERS["named-characters"].keys()) # From WordCompleter, adjusted with default values self.ignore_case = True diff --git a/mathicsscript/data/inputrc-no-unicode b/mathicsscript/data/inputrc-no-unicode index 6c6fe3a..fe41918 100644 --- a/mathicsscript/data/inputrc-no-unicode +++ b/mathicsscript/data/inputrc-no-unicode @@ -1,5 +1,5 @@ # GNU Readline input unicode translations -# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Feb 12 11:52:14 AM EST 2025 +# Autogenerated from mathics_scanner.generate.rl_inputrc on Sun Mar 1 03:40:19 PM EST 2026 "\ea'\e": "á" "\ea-\e": "ā" @@ -8,9 +8,9 @@ "\eae\e": "æ" "\ea`\e": "à" "\ea^\e": "â" -"\eal\e": "ℵ" "\eao\e": "å" "\ea~\e": "ã" +"\eal\e": "ℵ" "\eesc\e": "\\[AliasIndicator]" "\eam\e": "\\[AlignmentMarker]" "\ea\e": "α" @@ -146,7 +146,7 @@ "\ediffd\e": "∆" "\edd\e": "𝑑" "\edi\e": "ϝ" -"\ede\e": "→" +"\ede\e": "⇴" "\edratio\e": "ϴ" "\eshift\e": "\\[DiscreteShift]" "\edhy\e": "\\[DiscretionaryHyphen]" @@ -597,7 +597,7 @@ "\e]\e": "\\[RightModified]" "\erT\e": "⊢" "\evec\e": "⇀" -"\e->\e": "→" +"\e->\e": "⇾" "\e:>\e": "⧴" "\esv\e": "š" "\esz\e": "ß" diff --git a/mathicsscript/data/inputrc-unicode b/mathicsscript/data/inputrc-unicode index 6c6fe3a..50ab09f 100644 --- a/mathicsscript/data/inputrc-unicode +++ b/mathicsscript/data/inputrc-unicode @@ -1,5 +1,5 @@ # GNU Readline input unicode translations -# Autogenerated from mathics_scanner.generate.rl_inputrc on Wed Feb 12 11:52:14 AM EST 2025 +# Autogenerated from mathics_scanner.generate.rl_inputrc on Sun Mar 1 03:40:18 PM EST 2026 "\ea'\e": "á" "\ea-\e": "ā" @@ -8,9 +8,9 @@ "\eae\e": "æ" "\ea`\e": "à" "\ea^\e": "â" -"\eal\e": "ℵ" "\eao\e": "å" "\ea~\e": "ã" +"\eal\e": "ℵ" "\eesc\e": "\\[AliasIndicator]" "\eam\e": "\\[AlignmentMarker]" "\ea\e": "α" @@ -146,7 +146,7 @@ "\ediffd\e": "∆" "\edd\e": "𝑑" "\edi\e": "ϝ" -"\ede\e": "→" +"\ede\e": "⇴" "\edratio\e": "ϴ" "\eshift\e": "\\[DiscreteShift]" "\edhy\e": "\\[DiscretionaryHyphen]" @@ -597,7 +597,7 @@ "\e]\e": "\\[RightModified]" "\erT\e": "⊢" "\evec\e": "⇀" -"\e->\e": "→" +"\e->\e": "⇾" "\e:>\e": "⧴" "\esv\e": "š" "\esz\e": "ß" diff --git a/mathicsscript/data/mma-tables.json b/mathicsscript/data/mma-tables.json index 8af01d6..9dfc224 100644 --- a/mathicsscript/data/mma-tables.json +++ b/mathicsscript/data/mma-tables.json @@ -1 +1 @@ -{"ascii-operators": ["+=", "&&", "_", "___", "__", ":", "@*", ";", "/;", "--", "'", "/", "/=", ".", "=|", "==", "!", "!!", "|->", "&", "<<", ">=", "??", "\\!", "{{", "<", "<=", "/@", "//@", "@@@", "::", "-", "**", "!", "!=", "||", "?", "+", "//", "^", "++", "::", ">>", ">>>", ">", "{", "..", "...", "/.", "//.", "/*", "||", "}}", "->", ":>", "===", "=", ":=", ";;", "~~", "<>", "-=", "/:", "*", "*=", "<->", "=!=", "=.", "^=", "^:=", "|"], "builtin-constants": {"\u00b0": "Degree", "\u2147": "ExponentialE", "\u2148": "ImaginaryI", "\u2149": "ImaginaryJ", "\u221e": "Infinity", "\u03c0": "Pi"}, "unicode-operators": {"+=": "AddTo", "\u2227": "And", "\u2235": "Because", "_": "Blank", "___": "BlankNullSequence", "__": "BlankSequence", "\u2322": "Cap", "\u00b7": "CenterDot", "\u2299": "CircleDot", "\u2296": "CircleMinus", "\u2295": "CirclePlus", "\u2297": "CircleTimes", "\u2232": "ClockwiseContourIntegral", "\u2236": "Colon", "@*": "Composition", ";": "CompoundExpression", "/;": "Condition", "\u2261": "Congruent", "null": "RightAssociation", "\u222e": "ContourIntegral", "\u2210": "Coproduct", "\u2233": "CounterClockwiseContourIntegral", "\u2323": "Cup", "\u224d": "CupCap", "--": "Decrement", "\u2207": "Del", "'": "Derivative", "\u22c4": "Diamond", "\ud835\udc51": "DifferentialD", "\u2192": "Rule", "\u00f7": "Divide", "/=": "DivideBy", ".": "Dot", "\u2250": "DotEqual", "\u222f": "DoubleContourIntegral", "\u21d3": "DoubleDownArrow", "\u21d0": "DoubleLeftArrow", "\u21d4": "DoubleLeftRightArrow", "\u2ae4": "DoubleLeftTee", "\u27f8": "DoubleLongLeftArrow", "\u27fa": "DoubleLongLeftRightArrow", "\u27f9": "DoubleLongRightArrow", "\u21d2": "DoubleRightArrow", "\u22a8": "DoubleRightTee", "\u21d1": "DoubleUpArrow", "\u21d5": "DoubleUpDownArrow", "\u2225": "DoubleVerticalBar", "\u2193": "DownArrow", "\u2913": "DownArrowBar", "\u21f5": "DownArrowUpArrow", "\u2950": "DownLeftRightVector", "\u295e": "DownLeftTeeVector", "\u21bd": "DownLeftVector", "\u2956": "DownLeftVectorBar", "\u295f": "DownRightTeeVector", "\u21c1": "DownRightVector", "\u2957": "DownRightVectorBar", "\u22a4": "DownTee", "\u21a7": "DownTeeArrow", "\u2208": "Element", "\u2a75": "Equal", "\u2242": "EqualTilde", "\u21cc": "Equilibrium", "\u29e6": "Equivalent", "\u2203": "Exists", "!": "Factorial", "!!": "Factorial2", "\u2200": "ForAll", "\u27fc": "Function", "&": "Function", "<<": "Get", "\u2265": "GreaterEqual", "\u22db": "GreaterEqualLess", "\u2267": "GreaterFullEqual", "\u226b": "GreaterGreater", "\u2277": "GreaterLess", "\u2a7e": "GreaterSlantEqual", "\u2273": "GreaterTilde", "\u224e": "HumpDownHump", "\u224f": "HumpEqual", "??": "Information", "\u222b": "Integral", "\\!": "InterpretedBox", "\u22c2": "Intersection", "\u2190": "LeftArrow", "\u21e4": "LeftArrowBar", "\u21c6": "LeftArrowRightArrow", "\u2308": "LeftCeiling", "\u301a": "LeftPart", "\u2016": "RightDoubleBracketingBar", "\u2961": "LeftDownTeeVector", "\u21c3": "LeftDownVector", "\u2959": "LeftDownVectorBar", "\u230a": "LeftFloor", "{{": "LeftList", "\u2194": "UndirectedEdge", "\u294e": "LeftRightVector", "\u22a3": "LeftTee", "\u21a4": "LeftTeeArrow", "\u295a": "LeftTeeVector", "\u22b2": "LeftTriangle", "\u29cf": "LeftTriangleBar", "\u22b4": "LeftTriangleEqual", "\u2951": "LeftUpDownVector", "\u2960": "LeftUpTeeVector", "\u21bf": "LeftUpVector", "\u2958": "LeftUpVectorBar", "\u21bc": "LeftVector", "\u2952": "LeftVectorBar", "<": "Less", "\u2264": "LessEqual", "\u22da": "LessEqualGreater", "\u2266": "LessFullEqual", "\u2276": "LessGreater", "\u226a": "LessLess", "\u2a7d": "LessSlantEqual", "\u2272": "LessTilde", "\u27f5": "LongLeftArrow", "\u27f7": "LongLeftRightArrow", "\u27f6": "LongRightArrow", "\u2199": "LowerLeftArrow", "\u2198": "LowerRightArrow", "/@": "Map", "//@": "MapAll", "@@@": "MapApply", "::": "MessageName", "\u2212": "Minus", "\u2213": "MinusPlus", "\u2aa2": "NestedGreaterGreater", "\u2aa1": "NestedLessLess", "**": "NonCommutativeMultiply", "\u22bd": "Nor", "\u00ac": "Not", "\u2262": "NotCongruent", "\u226d": "NotCupCap", "\u2226": "NotDoubleVerticalBar", "\u2209": "NotElement", "\u2260": "Unequal", "\u2204": "NotExists", "\u226f": "NotGreater", "\u2271": "NotGreaterEqual", "\u2269": "NotGreaterFullEqual", "\uf427": "NotGreaterGreater", "\u2279": "NotGreaterLess", "\u2275": "NotGreaterTilde", "\u22ea": "NotLeftTriangle", "\u22ec": "NotLeftTriangleEqual", "\u226e": "NotLess", "\u2270": "NotLessEqual", "\u2268": "NotLessFullEqual", "\u2278": "NotLessGreater", "\u2274": "NotLessTilde", "\u2280": "NotPrecedes", "\u22e0": "NotPrecedesSlantEqual", "\u22e8": "NotPrecedesTilde", "\u220c": "NotReverseElement", "\u22eb": "NotRightTriangle", "\u22ed": "NotRightTriangleEqual", "\u22e2": "NotSquareSubsetEqual", "\u22e3": "NotSquareSupersetEqual", "\u2284": "NotSubset", "\u2288": "NotSubsetEqual", "\u2281": "NotSucceeds", "\u22e1": "NotSucceedsSlantEqual", "\u22e9": "NotSucceedsTilde", "\u2285": "NotSuperset", "\u2289": "NotSupersetEqual", "\u2241": "NotTilde", "\u2244": "NotTildeEqual", "\u2247": "NotTildeFullEqual", "\u2249": "NotTildeTilde", "\u2228": "Or", "?": "PatternTest", "\u27c2": "Perpendicular", "+": "Plus", "//": "Postfix", "^": "Power", "++": "PreIncrement", "\u227a": "Precedes", "\u2aaf": "PrecedesEqual", "\u227c": "PrecedesSlantEqual", "\u227e": "PrecedesTilde", "\u220f": "Product", "\u2237": "Proportion", "\u221d": "Proportional", ">>": "Put", ">>>": "PutAppend", ">": "Greater", "{": "LeftList", "..": "Repeated", "...": "RepeatedNull", "/.": "ReplaceAll", "//.": "ReplaceRepeated", "\u220b": "ReverseElement", "\u21cb": "ReverseEquilibrium", "\u296f": "ReverseUpEquilibrium", "\u21e5": "RightArrowBar", "\u21c4": "RightArrowLeftArrow", "\u2309": "RightCeiling", "/*": "RightComposition", "\u301b": "RightPart", "\u295d": "RightDownTeeVector", "\u21c2": "RightDownVector", "\u2955": "RightDownVectorBar", "\u230b": "RightFloor", "}}": "RightList", "\u22a2": "RightTee", "\u21a6": "RightTeeArrow", "\u295b": "RightTeeVector", "\u22b3": "RightTriangle", "\u29d0": "RightTriangleBar", "\u22b5": "RightTriangleEqual", "\u294f": "RightUpDownVector", "\u295c": "RightUpTeeVector", "\u21be": "RightUpVector", "\u2954": "RightUpVectorBar", "\u21c0": "RightVector", "\u2953": "RightVectorBar", "\u2970": "RoundImplies", "\u29f4": "RuleDelayed", "===": "SameQ", "=": "Set", ":=": "SetDelayed", "\u2218": "SmallCircle", ";;": "Span", "\u221a": "Sqrt", "\u25ab": "Square", "\u2293": "SquareIntersection", "\u228f": "SquareSubset", "\u2291": "SquareSubsetEqual", "\u2290": "SquareSuperset", "\u2292": "SquareSupersetEqual", "\u2294": "SquareUnion", "\u22c6": "Star", "~~": "StringExpression", "<>": "StringJoin", "\u2282": "Subset", "\u2286": "SubsetEqual", "-=": "SubtractFrom", "\u227b": "Succeeds", "\u2ab0": "SucceedsEqual", "\u227d": "SucceedsSlantEqual", "\u227f": "SucceedsTilde", "\u220d": "SuchThat", "\u2211": "Sum", "\u2283": "Superset", "\u2287": "SupersetEqual", "/:": "TagSet", "\u2234": "Therefore", "\u223c": "Tilde", "\u2243": "TildeEqual", "\u2245": "TildeFullEqual", "\u2248": "TildeTilde", "\u00d7": "Times", "*=": "TimesBy", "\u1d40": "Transpose", "=!=": "UnsameQ", "\u22c3": "Union", "\u228e": "UnionPlus", "=.": "Unset", "\u2191": "UpArrow", "\u2912": "UpArrowBar", "\u21c5": "UpArrowDownArrow", "\u2195": "UpDownArrow", "\u296e": "UpEquilibrium", "\u22a5": "UpTee", "\u21a5": "UpTeeArrow", "\u2196": "UpperLeftArrow", "\u2197": "UpperRightArrow", "^=": "UpSet", "^:=": "UpSetDelayed", "\u22c1": "Vee", "\u2758": "VerticalBar", "\u2240": "VerticalTilde", "\u22c0": "Wedge", "\u22bb": "Xor"}} +{"ascii-operators": ["+=", "|", "&&", "@@", "@@@", "//=", "_", "___", "__", ":", "@*", ";", "/;", "--", "'", "/", "/=", ".", "=|", "==", "!", "!!", "|->", "&", "<<", ">=", "??", "\\!", "{{", "<", "<=", "/@", "//@", "@@@", "::", "-", "**", "!", "!=", ":", "||", "?", "+", "//", "^", "++", "::", ">>", ">>>", ">", "{", "..", "...", "/.", "//.", "/*", "||", "}}", "->", ":>", "===", "=", ":=", ";;", "~~", "<>", "-=", "/:", "*", "*=", "<->", "=!=", "=.", "^=", "^:=", "|"], "builtin-constants": {"\u00b0": "Degree", "\u2147": "ExponentialE", "\u2148": "ImaginaryI", "\u2149": "ImaginaryJ", "\u221e": "Infinity", "\u03c0": "Pi"}, "unicode-operators": {"+=": "AddTo", "|": "Alternatives", "@@": "Apply", "@@@": "MapApply", "//=": "ApplyTo", "\u2227": "And", "\u2235": "Because", "_": "Blank", "___": "BlankNullSequence", "__": "BlankSequence", "\u2322": "Cap", "\u00b7": "CenterDot", "\u2299": "CircleDot", "\u2296": "CircleMinus", "\u2295": "CirclePlus", "\u2297": "CircleTimes", "\u2232": "ClockwiseContourIntegral", "\u2236": "Colon", "@*": "Composition", ";": "CompoundExpression", "/;": "Condition", "\u2261": "Congruent", "null": "RightAssociation", "\u222e": "ContourIntegral", "\u2210": "Coproduct", "\u2233": "CounterClockwiseContourIntegral", "\u2323": "Cup", "\u224d": "CupCap", "--": "Decrement", "\u2207": "Del", "'": "Derivative", "\u22c4": "Diamond", "\ud835\udc51": "DifferentialD", "\u21f4": "DirectedEdge", "\u00f7": "Divide", "/=": "DivideBy", ".": "Dot", "\u2250": "DotEqual", "\u222f": "DoubleContourIntegral", "\u21d3": "DoubleDownArrow", "\u21d0": "DoubleLeftArrow", "\u21d4": "DoubleLeftRightArrow", "\u2ae4": "DoubleLeftTee", "\u27f8": "DoubleLongLeftArrow", "\u27fa": "DoubleLongLeftRightArrow", "\u27f9": "DoubleLongRightArrow", "\u21d2": "Implies", "\u22a8": "DoubleRightTee", "\u21d1": "DoubleUpArrow", "\u21d5": "DoubleUpDownArrow", "\u2225": "DoubleVerticalBar", "\u2193": "DownArrow", "\u2913": "DownArrowBar", "\u21f5": "DownArrowUpArrow", "\u2950": "DownLeftRightVector", "\u295e": "DownLeftTeeVector", "\u21bd": "DownLeftVector", "\u2956": "DownLeftVectorBar", "\u295f": "DownRightTeeVector", "\u21c1": "DownRightVector", "\u2957": "DownRightVectorBar", "\u22a4": "DownTee", "\u21a7": "DownTeeArrow", "\u2208": "Element", "\u2a75": "Equal", "\u2242": "EqualTilde", "\u21cc": "Equilibrium", "\u29e6": "Equivalent", "\u2203": "Exists", "!": "Factorial", "!!": "Factorial2", "\u2200": "ForAll", "\u27fc": "Function", "&": "Function", "<<": "Get", "\u2265": "GreaterEqual", "\u22db": "GreaterEqualLess", "\u2267": "GreaterFullEqual", "\u226b": "GreaterGreater", "\u2277": "GreaterLess", "\u2a7e": "GreaterSlantEqual", "\u2273": "GreaterTilde", "\u224e": "HumpDownHump", "\u224f": "HumpEqual", "??": "Information", "\u222b": "Integral", "\\!": "InterpretedBox", "\u22c2": "Intersection", "\u2329": "LeftAngleBracket", "\u2190": "LeftArrow", "\u21e4": "LeftArrowBar", "\u21c6": "LeftArrowRightArrow", "\u2308": "LeftCeiling", "\u301a": "LeftDoubleBracket", "\u2016": "RightDoubleBracketingBar", "\u2961": "LeftDownTeeVector", "\u21c3": "LeftDownVector", "\u2959": "LeftDownVectorBar", "\u230a": "LeftFloor", "{{": "LeftList", "\u2194": "UndirectedEdge", "\u294e": "LeftRightVector", "\u22a3": "LeftTee", "\u21a4": "LeftTeeArrow", "\u295a": "LeftTeeVector", "\u22b2": "LeftTriangle", "\u29cf": "LeftTriangleBar", "\u22b4": "LeftTriangleEqual", "\u2951": "LeftUpDownVector", "\u2960": "LeftUpTeeVector", "\u21bf": "LeftUpVector", "\u2958": "LeftUpVectorBar", "\u21bc": "LeftVector", "\u2952": "LeftVectorBar", "<": "Less", "\u2264": "LessEqual", "\u22da": "LessEqualGreater", "\u2266": "LessFullEqual", "\u2276": "LessGreater", "\u226a": "LessLess", "\u2a7d": "LessSlantEqual", "\u2272": "LessTilde", "\u27f5": "LongLeftArrow", "\u27f7": "LongLeftRightArrow", "\u27f6": "LongRightArrow", "\u2199": "LowerLeftArrow", "\u2198": "LowerRightArrow", "/@": "Map", "//@": "MapAll", "::": "MessageName", "\u2212": "Minus", "\u2213": "MinusPlus", "\u22bc": "Nand", "\u2aa2": "NestedGreaterGreater", "\u2aa1": "NestedLessLess", "**": "NonCommutativeMultiply", "\u22bd": "Nor", "\u00ac": "Not", "\u2262": "NotCongruent", "\u226d": "NotCupCap", "\u2226": "NotDoubleVerticalBar", "\u2209": "NotElement", "\u2260": "Unequal", "\u2204": "NotExists", "\u226f": "NotGreater", "\u2271": "NotGreaterEqual", "\u2269": "NotGreaterFullEqual", "\uf427": "NotGreaterGreater", "\u2279": "NotGreaterLess", "\u2275": "NotGreaterTilde", "\u22ea": "NotLeftTriangle", "\u22ec": "NotLeftTriangleEqual", "\u226e": "NotLess", "\u2270": "NotLessEqual", "\u2268": "NotLessFullEqual", "\u2278": "NotLessGreater", "\u2274": "NotLessTilde", "\u2280": "NotPrecedes", "\u22e0": "NotPrecedesSlantEqual", "\u22e8": "NotPrecedesTilde", "\u220c": "NotReverseElement", "\u22eb": "NotRightTriangle", "\u22ed": "NotRightTriangleEqual", "\u22e2": "NotSquareSubsetEqual", "\u22e3": "NotSquareSupersetEqual", "\u2284": "NotSubset", "\u2288": "NotSubsetEqual", "\u2281": "NotSucceeds", "\u22e1": "NotSucceedsSlantEqual", "\u22e9": "NotSucceedsTilde", "\u2285": "NotSuperset", "\u2289": "NotSupersetEqual", "\u2241": "NotTilde", "\u2244": "NotTildeEqual", "\u2247": "NotTildeFullEqual", "\u2249": "NotTildeTilde", ":": "Optional", "\u2228": "Or", "?": "PatternTest", "\u27c2": "Perpendicular", "+": "Plus", "//": "Postfix", "^": "Power", "++": "PreIncrement", "\u227a": "Precedes", "\u2aaf": "PrecedesEqual", "\u227c": "PrecedesSlantEqual", "\u227e": "PrecedesTilde", "\u220f": "Product", "\u2237": "Proportion", "\u221d": "Proportional", ">>": "Put", ">>>": "PutAppend", ">": "Greater", "{": "LeftList", "..": "Repeated", "...": "RepeatedNull", "/.": "ReplaceAll", "//.": "ReplaceRepeated", "\u220b": "ReverseElement", "\u21cb": "ReverseEquilibrium", "\u296f": "ReverseUpEquilibrium", "\u2192": "RightArrow", "\u21e5": "RightArrowBar", "\u21c4": "RightArrowLeftArrow", "\u2309": "RightCeiling", "/*": "RightComposition", "\u301b": "RightDoubleBracket", "\u295d": "RightDownTeeVector", "\u21c2": "RightDownVector", "\u2955": "RightDownVectorBar", "\u230b": "RightFloor", "}}": "RightList", "\u22a2": "RightTee", "\u21a6": "RightTeeArrow", "\u295b": "RightTeeVector", "\u22b3": "RightTriangle", "\u29d0": "RightTriangleBar", "\u22b5": "RightTriangleEqual", "\u294f": "RightUpDownVector", "\u295c": "RightUpTeeVector", "\u21be": "RightUpVector", "\u2954": "RightUpVectorBar", "\u21c0": "RightVector", "\u2953": "RightVectorBar", "\u2970": "RoundImplies", "\u21fe": "Rule", "\u29f4": "RuleDelayed", "===": "SameQ", "=": "Set", ":=": "SetDelayed", "\u2218": "SmallCircle", ";;": "Span", "\u221a": "Sqrt", "\u25ab": "Square", "\u2293": "SquareIntersection", "\u228f": "SquareSubset", "\u2291": "SquareSubsetEqual", "\u2290": "SquareSuperset", "\u2292": "SquareSupersetEqual", "\u2294": "SquareUnion", "\u22c6": "Star", "~~": "StringExpression", "<>": "StringJoin", "\u2282": "Subset", "\u2286": "SubsetEqual", "-=": "SubtractFrom", "\u227b": "Succeeds", "\u2ab0": "SucceedsEqual", "\u227d": "SucceedsSlantEqual", "\u227f": "SucceedsTilde", "\u220d": "SuchThat", "\u2211": "Sum", "\u2283": "Superset", "\u2287": "SupersetEqual", "/:": "TagSet", "\u2234": "Therefore", "\u223c": "Tilde", "\u2243": "TildeEqual", "\u2245": "TildeFullEqual", "\u2248": "TildeTilde", "\u00d7": "Times", "*=": "TimesBy", "\u1d40": "Transpose", "=!=": "UnsameQ", "\u22c3": "Union", "\u228e": "UnionPlus", "=.": "Unset", "\u2191": "UpArrow", "\u2912": "UpArrowBar", "\u21c5": "UpArrowDownArrow", "\u2195": "UpDownArrow", "\u296e": "UpEquilibrium", "\u22a5": "UpTee", "\u21a5": "UpTeeArrow", "\u2196": "UpperLeftArrow", "\u2197": "UpperRightArrow", "^=": "UpSet", "^:=": "UpSetDelayed", "\u22c1": "Vee", "\u2758": "VerticalBar", "\u2240": "VerticalTilde", "\u22c0": "Wedge", "\u22bb": "Xor"}} diff --git a/mathicsscript/format.py b/mathicsscript/format.py index 42a0b31..7049db7 100644 --- a/mathicsscript/format.py +++ b/mathicsscript/format.py @@ -1,5 +1,5 @@ """ -Format Mathics objects +Format Mathics3 objects """ import math @@ -22,10 +22,10 @@ SymbolOutputForm, SymbolPlot, SymbolStandardForm, - SymbolStringForm, SymbolTeXForm, ) from mathics.session import get_settings_value +from mathicsscript.asymptote import Asy, write_asy_and_view PyMathicsGraph = Symbol("Pymathics`Graph") @@ -49,8 +49,6 @@ except ImportError: svg2png = None -from mathicsscript.asymptote import Asy, write_asy_and_view - have_asymptote = False try: asymptote_graph = Asy(show_help=False) diff --git a/mathicsscript/settings.py b/mathicsscript/settings.py index c0f59ef..c5b3c1a 100644 --- a/mathicsscript/settings.py +++ b/mathicsscript/settings.py @@ -2,7 +2,12 @@ from mathics.core.definitions import Definitions from mathics.core.load_builtin import import_and_load_builtins +from mathics_scanner.load import load_mathics3_named_characters_json from mathics.settings import default_pymathics_modules +from typing import Final + +NAMED_CHARACTERS: Final[dict] = load_mathics3_named_characters_json() + # Initialize definitions extension_modules = default_pymathics_modules diff --git a/mathicsscript/termshell_gnu.py b/mathicsscript/termshell_gnu.py index 51bf6ae..8756886 100644 --- a/mathicsscript/termshell_gnu.py +++ b/mathicsscript/termshell_gnu.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2020-2022, 2025 Rocky Bernstein +# Copyright (C) 2020-2022, 2025-2026 Rocky Bernstein import atexit import os @@ -15,8 +15,8 @@ def read_init_file(_: str): return +from typing import Final from mathicsscript.bindkeys import read_inputrc -from mathics_scanner import named_characters from mathicsscript.termshell import ( CONFIGDIR, HISTSIZE, @@ -24,6 +24,7 @@ def read_init_file(_: str): USER_INPUTRC, ) from mathics.core.symbols import strip_context +from mathicsscript.settings import NAMED_CHARACTERS try: from readline import ( @@ -49,10 +50,10 @@ def write_history_file(_: str): set_completer = set_completer_delims = null_fn -RL_COMPLETER_DELIMS_WITH_BRACE = " \t\n_~!@#%^&*()-=+{]}|;:'\",<>/?" -RL_COMPLETER_DELIMS = " \t\n_~!@#%^&*()-=+[{]}\\|;:'\",<>/?" +RL_COMPLETER_DELIMS_WITH_BRACE: Final[str] = " \t\n_~!@#%^&*()-=+{]}|;:'\",<>/?" +RL_COMPLETER_DELIMS: Final[str] = " \t\n_~!@#%^&*()-=+[{]}\\|;:'\",<>/?" -HISTFILE = osp.join(CONFIGDIR, "history-gnu") +HISTFILE: Final[str] = osp.join(CONFIGDIR, "history-gnu") class TerminalShellGNUReadline(TerminalShellCommon): @@ -77,7 +78,9 @@ def __init__( lambda text, state: self.complete_symbol_name(text, state) ) - self.named_character_names = set(named_characters.keys()) + self.named_character_names = set( + NAMED_CHARACTERS["named-characters"].keys() + ) # Make _ a delimiter, but not $ or ` # set_completer_delims(RL_COMPLETER_DELIMS) diff --git a/mathicsscript/termshell_prompt.py b/mathicsscript/termshell_prompt.py index 372fb18..0b23489 100644 --- a/mathicsscript/termshell_prompt.py +++ b/mathicsscript/termshell_prompt.py @@ -21,7 +21,7 @@ from pygments.styles import get_style_by_name from mathicsscript.bindkeys import bindings, read_init_file, read_inputrc -from mathicsscript.completion import MathicsCompleter +from mathicsscript.completion import Mathics3Completer from mathicsscript.termshell import ( HISTFILE, HISTSIZE, @@ -68,7 +68,9 @@ def __init__( f"Can't read user inputrc file {USER_INPUTRC}; skipping\n" ) - self.completer = MathicsCompleter(self.definitions) if want_completion else None + self.completer = ( + Mathics3Completer(self.definitions) if want_completion else None + ) def bottom_toolbar(self): """Adds a mode-line toolbar at the bottom""" From 7160fca31dcdb4ee86f5582af0b2ff2cb5623c73 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 1 Mar 2026 16:25:12 -0500 Subject: [PATCH 2/3] Update CI to use github repo for scanner --- .github/workflows/macos.yaml | 12 +++++++----- .github/workflows/ubuntu.yml | 12 +++++++----- .github/workflows/windows.yml | 14 ++++++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index f9b5368..2a793ee 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -23,11 +23,13 @@ jobs: run: | brew install asymptote python3 -m pip install --upgrade pip - # Can comment out when next Mathics core and Mathics-scanner are released - # git clone https://github.com/Mathics3/mathics-scanner - # (cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh) - # git clone https://github.com/Mathics3/mathics-core - # (cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full]) + # We can comment out after next Mathics-Scanner release + # python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full] + git clone --depth 1 https://github.com/Mathics3/mathics-scanner.git + cd mathics-scanner/ + pip install -e . + bash -x admin-tools/make-JSON-tables.sh + cd .. - name: Install mathicsscript run: | make diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 58efee8..bd31c6e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -22,11 +22,13 @@ jobs: run: | sudo apt-get update -qq && sudo apt-get install -qq liblapack-dev llvm-dev asymptote python3 -m pip install --upgrade pip - # We can comment out when next Mathics core and Mathics-scanner are released - # git clone https://github.com/Mathics3/mathics-scanner - # (cd mathics-scanner && pip install -e . && bash ./admin-tools/make-JSON-tables.sh) - # git clone https://github.com/Mathics3/mathics-core - # (cd mathics-core && bash ./admin-tools/make-JSON-tables.sh && pip install -e .[full]) + # We can comment out after next Mathics-Scanner release + # python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full] + git clone --depth 1 https://github.com/Mathics3/mathics-scanner.git + cd mathics-scanner/ + pip install -e . + bash -x admin-tools/make-JSON-tables.sh + cd .. - name: Install mathicsscript run: | make diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2327351..2a7ae21 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -24,12 +24,14 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install wheel set LLVM_DIR="C:\Program Files\LLVM" - # We can comment out when next Mathics core and Mathics-scanner are released - # git clone https://github.com/Mathics3/mathics-scanner - # bash -c '(cd mathics-scanner && python -m pip install -e . && bash ./admin-tools/make-JSON-tables.sh)' - # git clone https://github.com/Mathics3/mathics-core - # bash -c '(cd mathics-core && ./admin-tools/make-JSON-tables.sh && python -m pip install -e .)' - # python -m pip install -e . + # We can comment out after next Mathics-Scanner release + python -m pip install -e "Mathics-Scanner[full] @ git+https://github.com/Mathics3/mathics-scanner" + pip install -e . + git clone --depth 1 https://github.com/Mathics3/mathics-scanner.git + cd mathics-scanner/ + pip install -e . + bash -x admin-tools/make-JSON-tables.sh + cd .. - name: Install mathicsscript run: | make From eb7884a0456b2b68172a88a7fb127a7dae0c40d5 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 1 Mar 2026 16:32:26 -0500 Subject: [PATCH 3/3] Administrivia --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b24bcb..1b5322c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: exclude: ChangeLog-spell-corrected.diff - id: end-of-file-fixer exclude: ChangeLog-spell-corrected.diff - stages: [commit] + stages: [pre-commit] - id: trailing-whitespace exclude: ChangeLog-spell-corrected.diff - repo: https://github.com/psf/black