diff --git a/mathics_scanner/data/OperatorTable.csv b/mathics_scanner/data/OperatorTable.csv index 1d81468..a018238 100644 --- a/mathics_scanner/data/OperatorTable.csv +++ b/mathics_scanner/data/OperatorTable.csv @@ -174,11 +174,11 @@ Cup,Cup,440,340,340,43,43,460,460,{},"{""⌣""}",{},"{{""expr1"", ""⌣"", ""exp CircleMinus,CircleMinus,430,330,330,44,44,450,450,{},"{""⊖""}",{},"{{""expr1"", ""⊖"", ""expr2""}}","{""CircleMinus"", ""["", ""expr1"", "","", ""expr2"", ""]""}","CircleMinus[expr1, expr2]",Binary,Infix,Left,False, CirclePlus,CirclePlus,430,330,330,44,44,450,450,{},"{""⊕""}",{},"{{""expr1"", ""⊕"", ""expr2""}}","{""CirclePlus"", ""["", ""expr1"", "","", ""expr2"", ""]""}","CirclePlus[expr1, expr2]",Binary,Infix,None,False, Sum,Sum,420,320,325,45,45,440,445,"{""∑""}",{},{},"{{""∑"", ""expr""}}","{""Sum"", ""["", ""expr"", ""]""}",Sum[expr],Unary,Prefix,Right,True,Usage and Parse may not be correct. -Integrate,Integral,420,325,325,23,45,455,445,"{""∫""}",{},"{""""}","{{""∫"", ""expr1"", """", ""expr2""}}","{""Integrate"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Prefix,Right,True, -ClockwiseContourIntegral,ClockwiseContourIntegral,420,670,325,,45,455,445,"{""∲""}",{},"{""""}","{{""∲"", ""expr1"", """", ""expr2""}}","{""ClockwiseContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Unary,Prefix,Right,True,Usage and Parse may not be correct. -ContourIntegral,ContourIntegral,420,670,325,,45,455,445,"{""∮""}",{},"{""""}","{{""∮"", ""expr1"", """", ""expr2""}}","{""ContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Unary,Prefix,Right,True,Usage and Parse may not be correct. -CounterClockwiseContourIntegral,CounterClockwiseContourIntegral,420,670,325,,45,455,445,"{""∳""}",{},"{""""}","{{""∳"", ""expr1"", """", ""expr2""}}","{""CounterClockwiseContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Unary,Prefix,Right,True,Usage and Parse may not be correct. -DoubleContourIntegral,DoubleContourIntegral,420,670,325,,45,455,445,"{""∯""}",{},"{""""}","{{""∯"", ""expr1"", """", ""expr2""}}","{""DoubleContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Unary,Prefix,Right,True,Usage and Parse may not be correct. +Integrate,Integral,420,325,325,23,45,455,445,"{""∫""}",{},"{""""}","{{""∫"", ""expr1"", """", ""expr2""}}","{""Integrate"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Compound,Right,True, +ClockwiseContourIntegral,ClockwiseContourIntegral,420,670,325,,45,455,445,"{""∲""}",{},"{""""}","{{""∲"", ""expr1"", """", ""expr2""}}","{""ClockwiseContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Compound,Right,True,Usage and Parse may not be correct. +ContourIntegral,ContourIntegral,420,670,325,,45,455,445,"{""∮""}",{},"{""""}","{{""∮"", ""expr1"", """", ""expr2""}}","{""ContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Compound,Right,True,Usage and Parse may not be correct. +CounterClockwiseContourIntegral,CounterClockwiseContourIntegral,420,670,325,,45,455,445,"{""∳""}",{},"{""""}","{{""∳"", ""expr1"", """", ""expr2""}}","{""CounterClockwiseContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Compound,Right,True,Usage and Parse may not be correct. +DoubleContourIntegral,DoubleContourIntegral,420,670,325,,45,455,445,"{""∯""}",{},"{""""}","{{""∯"", ""expr1"", """", ""expr2""}}","{""DoubleContourIntegral"", ""["", ""expr1"", "","", ""expr2"", ""]""}","Integrate[expr1, expr2]",Binary,Compound,Right,True,Usage and Parse may not be correct. ExpectationE,ExpectationE,420,325,325,,45,455,445,"{""""}",{},{},"{{"""", ""expr""}}","{""ExpectationE"", ""["", ""expr"", ""]""}",,Unary,Prefix,Right,True,Usage and Parse may not be correct. ProbabilityPr,ProbabilityPr,420,325,325,,45,455,445,"{""""}",{},{},"{{"""", ""expr""}}","{""ProbabilityPr"", ""["", ""expr"", ""]""}",,Unary,Prefix,Right,True,Usage and Parse may not be correct. Limit,Limit,410,320,320,,45.5,440,440,"{""""}",{},{},"{{"""", ""expr""}}","{""Limit"", ""["", ""expr"", ""]""}",,Unary,Prefix,Right,True,Usage and Parse may not be correct. diff --git a/mathics_scanner/data/named-characters.yml b/mathics_scanner/data/named-characters.yml index 80690ef..65aca22 100644 --- a/mathics_scanner/data/named-characters.yml +++ b/mathics_scanner/data/named-characters.yml @@ -32,6 +32,9 @@ # prespective, an operator name like "Association" # might have *two* (bracketing) symbols associated # here: "LeftAssociation" and "RightAssociation". +# More operator information can be found in +# file "operators.yml". +# # # unicode-equivalent: A unicode equivalent for the named-character, if it # exists. If it is the same as "ascii", please omit. @@ -53,6 +56,7 @@ # http://milde.users.sourceforge.net/LUCR/Math/unimathsymbols.pdf # https://reference.wolfram.com/language/ref/character/....html # https://github.com/rsmenon/pygments-mathematica +# https://reference.wolfram.com/language/tutorial/OperatorInputForms.html AAcute: amslatex: "\\'{a}" @@ -143,12 +147,12 @@ Apply: # @@@ replaces heads at level 1 of expr by f. # We add "3Ats" at the end so keys are unique, but -# the WL operator is still "Apply". +# the WL operator is still "MapApply". Apply3Ats: ascii: "@@@" has-unicode-inverse: false is-letter-like: false - operator-name: Apply + operator-name: MapApply ApplyTo: ascii: "//=" @@ -1660,12 +1664,6 @@ Decrement: # See also PatternTest and RawQuestion -Definition: - ascii: "?" - has-unicode-inverse: false - is-letter-like: false - operator-name: Definition - # \[Degree] is letter-like, not an operator, which is # mutually exclusive. @@ -2677,7 +2675,6 @@ DownLeftVectorBar: DownPointer: has-unicode-inverse: false is-letter-like: false - operator-name: DownPointer unicode-equivalent: "\u25BE" unicode-equivalent-name: BLACK DOWN-POINTING SMALL TRIANGLE wl-unicode: "\u25BE" @@ -4966,12 +4963,6 @@ Implies: unicode-equivalent-name: RIGHTWARDS DOUBLE ARROW wl-unicode: "\uF523" -Increment: - ascii: "++" - has-unicode-inverse: false - is-letter-like: false - operator-name: Increment - IndentingNewLine: esc-alias: nl has-unicode-inverse: false @@ -5003,12 +4994,12 @@ Information: is-letter-like: false operator-name: Information +# https://reference.wolfram.com/language/ref/character/Integral.html Integral: amslatex: "\\int" esc-alias: int has-unicode-inverse: false is-letter-like: false - # TODO: This should be a prefix operator operator-name: Integral unicode-equivalent: "\u222B" unicode-equivalent-name: INTEGRAL @@ -5188,6 +5179,7 @@ LeftAssociation: esc-alias: <| has-unicode-inverse: false is-letter-like: false + operator-name: LeftAssociation wl-unicode: "\uF113" LeftBracketingBar: @@ -5208,10 +5200,12 @@ LeftCeiling: wl-unicode: "\u2308" wl-unicode-name: LEFT CEILING +# Left part of "Part[] operator LeftDoubleBracket: esc-alias: '[[' has-unicode-inverse: false is-letter-like: false + operator-name: LeftPart unicode-equivalent: "\u301A" unicode-equivalent-name: LEFT WHITE SQUARE BRACKET wl-unicode: "\u301A" @@ -5221,6 +5215,7 @@ LeftDoubleBracketingBar: esc-alias: l|| has-unicode-inverse: false is-letter-like: false + operator-name: LeftDoubleBracketingBar unicode-equivalent: "\u2016" unicode-equivalent-name: DOUBLE VERTICAL LINE wl-unicode: "\uF605" @@ -5271,6 +5266,12 @@ LeftGuillemet: wl-unicode: "\xAB" wl-unicode-name: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +LeftList: + ascii: "{{" + has-unicode-inverse: false + is-letter-like: false + operator-name: LeftList + LeftModified: esc-alias: '[' has-unicode-inverse: false @@ -5280,7 +5281,6 @@ LeftModified: LeftPointer: has-unicode-inverse: false is-letter-like: false - operator-name: LeftPointer unicode-equivalent: "\u25C2" unicode-equivalent-name: BLACK LEFT-POINTING SMALL TRIANGLE wl-unicode: "\u25C2" @@ -5530,7 +5530,6 @@ LongDash: esc-alias: -- has-unicode-inverse: false is-letter-like: false - operator-name: LongDash unicode-equivalent: "\u2014" unicode-equivalent-name: EM DASH wl-unicode: "\u2014" @@ -5612,6 +5611,12 @@ MapApply: is-letter-like: false operator-name: MapApply +MaxLimit: + esc-alias: Mlim + has-unicode-inverse: false + is-letter-like: false + wl-unicode: "\uF439" + Mars: has-unicode-inverse: false is-letter-like: false @@ -5649,11 +5654,11 @@ Mercury: wl-unicode: "\u263F" wl-unicode-name: MERCURY -Message: +MessageName: ascii: "::" has-unicode-inverse: false is-letter-like: false - operator-name: Message + operator-name: MessageName Mho: esc-alias: mho @@ -5679,6 +5684,14 @@ Minus: is-letter-like: false operator-name: Minus +MinLimit: + amslatex: "\\lim_" + esc-alias: mlim + has-unicode-inverse: false + is-letter-like: false + unicode-equivalent: "lim" + wl-unicode: "\uF43A" + MinusPlus: amslatex: "\\mp" esc-alias: -+ @@ -5888,7 +5901,7 @@ NotEqual: esc-alias: '!=' has-unicode-inverse: false is-letter-like: false - operator-name: NotEqual + operator-name: Unequal unicode-equivalent: "\u2260" unicode-equivalent-name: NOT EQUAL TO wl-unicode: "\u2260" @@ -6199,6 +6212,7 @@ NotSucceeds: NotSucceedsEqual: has-unicode-inverse: false + operator-name: NotSucceedsEqual is-letter-like: false wl-unicode: "\uF42D" @@ -6427,7 +6441,6 @@ Option: ascii: ":" has-unicode-inverse: false is-letter-like: false - operator-name: Option OptionKey: esc-alias: opt @@ -6439,6 +6452,7 @@ Or: esc-alias: '||' has-unicode-inverse: false is-letter-like: false + operator-name: Or unicode-equivalent: "\u2228" unicode-equivalent-name: LOGICAL OR wl-unicode: "\u2228" @@ -6491,7 +6505,7 @@ PartialD: wl-unicode: "\u2202" wl-unicode-name: PARTIAL DIFFERENTIAL -# See also Definition and RawQuestion +# See also RawQuestion PatternTest: ascii: "?" has-unicode-inverse: false @@ -6597,6 +6611,12 @@ Power: wl-unicode: "^" wl-unicode-name: CIRCUMFLEX ACCENT +PreIncrement: + ascii: "++" + has-unicode-inverse: false + is-letter-like: false + operator-name: PreIncrement + Precedes: has-unicode-inverse: false is-letter-like: false @@ -6775,12 +6795,12 @@ RawEscape: is-letter-like: false wl-unicode: "\e" -# Note: RawGreater WL's name for Mathics Greater or ASCII ">" +# Note: the operator name and key name differ. RawGreater: ascii: ">" has-unicode-inverse: true is-letter-like: false - operator-name: RawGreater + operator-name: Greater unicode-equivalent-name: GREATER-THAN SIGN wl-unicode: "\u003e" wl-unicode-name: GREATER-THAN SIGN @@ -6788,6 +6808,7 @@ RawGreater: RawLeftBrace: ascii: '{' has-unicode-inverse: false + operator-name: LeftList is-letter-like: false RawLeftBracket: @@ -6810,7 +6831,7 @@ RawPercent: has-unicode-inverse: false is-letter-like: false -# See also Definition and PatternTest +# See also PatternTest RawQuestion: ascii: "?" has-unicode-inverse: false @@ -7077,6 +7098,7 @@ RightAssociation: esc-alias: '|>' has-unicode-inverse: false is-letter-like: false + operator-name: RightAssociation wl-unicode: "\uF114" RightBracketingBar: @@ -7103,10 +7125,12 @@ RightComposition: is-letter-like: false operator-name: RightComposition +# Right part of "Part[] operator RightDoubleBracket: esc-alias: ']]' has-unicode-inverse: false is-letter-like: false + operator-name: RightPart unicode-equivalent: "\u301B" unicode-equivalent-name: RIGHT WHITE SQUARE BRACKET wl-unicode: "\u301B" @@ -7167,6 +7191,12 @@ RightGuillemet: wl-unicode: "\xBB" wl-unicode-name: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +RightList: + ascii: "}}" + has-unicode-inverse: false + is-letter-like: false + operator-name: RightList + RightModified: esc-alias: ']' has-unicode-inverse: false @@ -7176,7 +7206,6 @@ RightModified: RightPointer: has-unicode-inverse: false is-letter-like: false - operator-name: RightPointer unicode-equivalent: "\u25B8" unicode-equivalent-name: BLACK RIGHT-POINTING SMALL TRIANGLE wl-unicode: "\u25B8" @@ -8581,11 +8610,11 @@ UndirectedEdge: unicode-equivalent-name: LEFT RIGHT ARROW wl-unicode: "\uF3D4" -UnSameQ: +UnsameQ: ascii: "=!=" has-unicode-inverse: false is-letter-like: false - operator-name: UnSameQ + operator-name: UnsameQ Union: esc-alias: un diff --git a/mathics_scanner/data/operators-additional.yml b/mathics_scanner/data/operators-additional.yml index 2b107cd..00db270 100644 --- a/mathics_scanner/data/operators-additional.yml +++ b/mathics_scanner/data/operators-additional.yml @@ -3,6 +3,21 @@ # Note: we keep the misspelling of "meaningfull" # and the uncoverted types like None and True +ApplyTo: + actual-precedence: 75 + Precedence: 75 # CSV has 604 which is wrong + Precedence-corrected: 75 + Precedence-Function: 75 + WolframLanguageData: 76 + WolframLanguageData-corrected: 75 + UnicodeCharacters.tr: + UnicodeCharacters-corrected.tr: 75 + arity: Binary + affix: Infix + associativity: left + meaningfull: "true" + # comments: + Derivative: actual-precedence: 770 Precedence: 670 # CSV has 604 which is wrong diff --git a/mathics_scanner/data/operators-intro.yml b/mathics_scanner/data/operators-intro.yml index 6ede149..7429df6 100644 --- a/mathics_scanner/data/operators-intro.yml +++ b/mathics_scanner/data/operators-intro.yml @@ -3,20 +3,24 @@ # This information comes largely from Robert L. Jacobson's Table of # Wolfram Language Operators found at: # https://github.com/WLTools/LanguageSpec/blob/master/docs/Specification/Syntax/Operator%20Table.csv - +# # We have copy of this in the Mathics-Scanner repository. # The CSV file has been converted to YAML using mathics_scanner/generate/operator_csv_to_yaml.py # +# Some operator information attached to individual character names can +# be found in file named-characters.yml. +# +# # For a description of many of the fields below, see # https://www.robertjacobson.dev/posts/2018-09-03-generalizing-pemdas-what-is-an-operator/ # and: # https://www.robertjacobson.dev/posts/2018-09-04-defining-the-wolfram-language-part-2-operator-properties/ - +# # However, I will summmarize some of the field descriptions. - +# # precedence # ---------- - +# # Many fields below mention precedence, and the WMA builtin-function # Precedence[]. When given an operator, this function gives an integer # used in specifying the order operations occur when one operator is @@ -29,7 +33,7 @@ # |-> to get treated as one unit and not split into two operators like # | and ->. So the precedence of |-> has to be higher than |. # - +# # arity (https://en.wikipedia.org/wiki/Arity) # ----- # @@ -41,14 +45,34 @@ # - Binary (2 arguments) # - Ternary (3 arguments) # - n-ary (n arguments) - - +# +# # actual-precedence: a precedence value that programs can use. +# # Precedence-corrected: the value used in Mathics3. -# WolframLangageData: a value returned using WolframLangageData[???] + +# WolframLanguageData: a "PrecedenceRanks" value returned using: +# WolframLanguageData[*operator_name*, "PrecedenceRanks"] +# Example: +# In[1] := WolframLanguageData[AddTo, "PrecedenceRanks"] +# Out[1]= {{expr1 +=expr2 , AddTo[expr1 ,expr2]} -> 73 +# +# Note that 73 uses a diffrent precedence scheme than the one +# given by Precedence and used in Mathics3. +# +# Also Note that WolframLanguageData can also be used to give the +# ASCII and unicode character representations: + +# In[2] := WolframLanguageData[AddTo, "ShortNotations"] +# Out[2]= {+=} +# In[2] := WolframLanguageData[GreaterEqual, "ShortNotations"] +# Out[7]= {>=, ≥} +# # usage: when it exists, an example of the use of this operator +# # parse: when "usage" exists, a parse of the example -# parse: when "usage" exists, the FullForm translation of the example + +# FullForm: when "usage" exists, the FullForm translation of the example # associativity: when two or more of the same operator is used, which group to # evaluate first. One of: diff --git a/mathics_scanner/data/operators.yml b/mathics_scanner/data/operators.yml index 2d7bd89..517b9e7 100644 --- a/mathics_scanner/data/operators.yml +++ b/mathics_scanner/data/operators.yml @@ -1,23 +1,27 @@ -# Autogenerated from operator_csv_to_yaml.py on 2024-08-31 14:46:57.289938 +# Autogenerated from operator_csv_to_yaml.py on 2024-09-07 19:43:33.857220 # Information about Wolfram Language named operators. # This information comes largely from Robert L. Jacobson's Table of # Wolfram Language Operators found at: # https://github.com/WLTools/LanguageSpec/blob/master/docs/Specification/Syntax/Operator%20Table.csv - +# # We have copy of this in the Mathics-Scanner repository. # The CSV file has been converted to YAML using mathics_scanner/generate/operator_csv_to_yaml.py # +# Some operator information attached to individual character names can +# be found in file named-characters.yml. +# +# # For a description of many of the fields below, see # https://www.robertjacobson.dev/posts/2018-09-03-generalizing-pemdas-what-is-an-operator/ # and: # https://www.robertjacobson.dev/posts/2018-09-04-defining-the-wolfram-language-part-2-operator-properties/ - +# # However, I will summmarize some of the field descriptions. - +# # precedence # ---------- - +# # Many fields below mention precedence, and the WMA builtin-function # Precedence[]. When given an operator, this function gives an integer # used in specifying the order operations occur when one operator is @@ -30,7 +34,7 @@ # |-> to get treated as one unit and not split into two operators like # | and ->. So the precedence of |-> has to be higher than |. # - +# # arity (https://en.wikipedia.org/wiki/Arity) # ----- # @@ -42,14 +46,34 @@ # - Binary (2 arguments) # - Ternary (3 arguments) # - n-ary (n arguments) - - +# +# # actual-precedence: a precedence value that programs can use. +# # Precedence-corrected: the value used in Mathics3. -# WolframLangageData: a value returned using WolframLangageData[???] + +# WolframLanguageData: a "PrecedenceRanks" value returned using: +# WolframLanguageData[*operator_name*, "PrecedenceRanks"] +# Example: +# In[1] := WolframLanguageData[AddTo, "PrecedenceRanks"] +# Out[1]= {{expr1 +=expr2 , AddTo[expr1 ,expr2]} -> 73 +# +# Note that 73 uses a diffrent precedence scheme than the one +# given by Precedence and used in Mathics3. +# +# Also Note that WolframLanguageData can also be used to give the +# ASCII and unicode character representations: + +# In[2] := WolframLanguageData[AddTo, "ShortNotations"] +# Out[2]= {+=} +# In[2] := WolframLanguageData[GreaterEqual, "ShortNotations"] +# Out[7]= {>=, ≥} +# # usage: when it exists, an example of the use of this operator +# # parse: when "usage" exists, a parse of the example -# parse: when "usage" exists, the FullForm translation of the example + +# FullForm: when "usage" exists, the FullForm translation of the example # associativity: when two or more of the same operator is used, which group to # evaluate first. One of: @@ -160,6 +184,25 @@ Apply: meaningful: true # comments: +ApplyTo: + actual-precedence: 75 + precedence: 75 + WolframLanguageData: 76 + WolframLanguageData-corrected: 75 + UnicodeCharacters.tr: None + UnicodeCharacters-corrected.tr: 75 + # N-tokens: None + # L-tokens: None + # O-tokens: None + # usage: None + # parse: None + FullForm: None + arity: Binary + affix: Infix + associativity: left + meaningful: true + # comments: None + Association: actual-precedence: -10 Precedence-Function: 670 @@ -599,8 +642,8 @@ ClockwiseContourIntegral: # usage: {{"∲", "expr1", "", "expr2"}} # parse: {"ClockwiseContourIntegral", "[", "expr1", ",", "expr2", "]"} FullForm: Integrate[expr1, expr2] - arity: Unary - affix: Prefix + arity: Binary + affix: Compound associativity: right meaningful: true # comments: Usage and Parse may not be correct. @@ -832,8 +875,8 @@ ContourIntegral: # usage: {{"∮", "expr1", "", "expr2"}} # parse: {"ContourIntegral", "[", "expr1", ",", "expr2", "]"} FullForm: Integrate[expr1, expr2] - arity: Unary - affix: Prefix + arity: Binary + affix: Compound associativity: right meaningful: true # comments: Usage and Parse may not be correct. @@ -891,8 +934,8 @@ CounterClockwiseContourIntegral: # usage: {{"∳", "expr1", "", "expr2"}} # parse: {"CounterClockwiseContourIntegral", "[", "expr1", ",", "expr2", "]"} FullForm: Integrate[expr1, expr2] - arity: Unary - affix: Prefix + arity: Binary + affix: Compound associativity: right meaningful: true # comments: Usage and Parse may not be correct. @@ -1376,8 +1419,8 @@ DoubleContourIntegral: # usage: {{"∯", "expr1", "", "expr2"}} # parse: {"DoubleContourIntegral", "[", "expr1", ",", "expr2", "]"} FullForm: Integrate[expr1, expr2] - arity: Unary - affix: Prefix + arity: Binary + affix: Compound associativity: right meaningful: true # comments: Usage and Parse may not be correct. @@ -2605,7 +2648,7 @@ Integrate: # parse: {"Integrate", "[", "expr1", ",", "expr2", "]"} FullForm: Integrate[expr1, expr2] arity: Binary - affix: Prefix + affix: Compound associativity: right meaningful: true # comments: diff --git a/test/test_ascii.py b/test/test_ascii.py index 9de8742..0eb9c5a 100644 --- a/test/test_ascii.py +++ b/test/test_ascii.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from mathics_scanner.load import ( - load_mathics_character_yaml, load_mathics_character_json, + load_mathics_character_yaml, ) yaml_data = load_mathics_character_yaml() @@ -24,5 +24,4 @@ def test_ascii(): assert char_symbol.startswith(r"\[") assert char_symbol.endswith(r"]") raw_char_symbol = char_symbol[len(r"\[") : -len(r"]")] - assert raw_char_symbol in yaml_data assert raw_char_symbol in ascii_operator_to_symbol.values() diff --git a/test/test_general_yaml_sanity.py b/test/test_general_yaml_sanity.py index ffa4edc..b5687c8 100644 --- a/test/test_general_yaml_sanity.py +++ b/test/test_general_yaml_sanity.py @@ -73,7 +73,7 @@ def test_operators(): operator_name_seen = set() # These names have more than one operator symbol - dup_operators = set(["Apply", "Function"]) + dup_operators = set(["Apply", "Function", "MapApply", "LeftList"]) # These symbols have more than one operator name dup_operator_symbols = set(["?", "!"]) @@ -83,14 +83,12 @@ def test_operators(): if len(v["ascii"]) > 1: assert ( "operator-name" in v - ), "In %s: ASCII with more than one characters must be an operator" % ( - k - ) + ), f"In {k}: ASCII with more than one characters must be an operator" pass else: - assert "wl-unicode" in v, ( - "In %s: there must be either an ascii name or have a wl-unicode" % k - ) + assert ( + "wl-unicode" in v + ), f"In {k}: there must be either an ascii name or have a wl-unicode" if "operator-name" not in v: continue @@ -108,7 +106,7 @@ def test_operators(): continue assert ( operator_name not in operator_name_seen - ), "Operator name %s has operator %s already been seen" % (operator_name, k) + ), f"Operator name {operator_name} has operator {k} already been seen" operator_name_seen.add(operator_name) @@ -171,7 +169,11 @@ def test_wl_unicode(): def test_unicode_operators(): - exclude_list = frozenset("Apply3Ats FunctionAmpersand".split(" ")) + exclude_list = frozenset( + """Apply3Ats LeftDoubleBracket Function FunctionAmpersand NotEqual RawGreater RawLeftBrace RightDoubleBracket""".split( + " " + ) + ) for k, v in yaml_data.items(): if k in exclude_list: continue @@ -180,7 +182,7 @@ def test_unicode_operators(): operator_name = v["operator-name"] assert ( k == operator_name - ), f"Section name {k} should match operator-name {operator_name} when a section has an operator" + ), f"Section name {k} should match operator-name {operator_name} or be explicitly excluded when a section has an operator" def test_wl_unicode_name():