Skip to content

Commit

Permalink
Go over operator characters...
Browse files Browse the repository at this point in the history
and add more information in operators YAML
  • Loading branch information
rocky committed Sep 2, 2024
1 parent b0f1563 commit a3c366f
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 151 deletions.
5 changes: 0 additions & 5 deletions mathics_scanner/data/OperatorTable.csv
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ 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.
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.
Expand Down
73 changes: 45 additions & 28 deletions mathics_scanner/data/named-characters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -143,12 +146,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: "//="
Expand Down Expand Up @@ -1342,11 +1345,11 @@ CircleTimes:
wl-unicode: "\u2297"
wl-unicode-name: CIRCLED TIMES

# See comment under "Integrate".
ClockwiseContourIntegral:
esc-alias: ccint
has-unicode-inverse: false
is-letter-like: false
operator-name: ClockwiseContourIntegral
unicode-equivalent: "\u2232"
unicode-equivalent-name: CLOCKWISE CONTOUR INTEGRAL
wl-unicode: "\u2232"
Expand Down Expand Up @@ -1474,7 +1477,6 @@ ContourIntegral:
esc-alias: cint
has-unicode-inverse: false
is-letter-like: false
operator-name: ContourIntegral
unicode-equivalent: "\u222E"
unicode-equivalent-name: CONTOUR INTEGRAL
wl-unicode: "\u222E"
Expand Down Expand Up @@ -1505,11 +1507,11 @@ Copyright:
wl-unicode: "\xA9"
wl-unicode-name: COPYRIGHT SIGN

# See comment under "Integral".
CounterClockwiseContourIntegral:
esc-alias: cccint
has-unicode-inverse: false
is-letter-like: false
operator-name: CounterClockwiseContourIntegral
unicode-equivalent: "\u2233"
unicode-equivalent-name: ANTICLOCKWISE CONTOUR INTEGRAL
wl-unicode: "\u2233"
Expand Down Expand Up @@ -1660,12 +1662,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.

Expand Down Expand Up @@ -1919,11 +1915,11 @@ DottedSquare:
unicode-equivalent-name: SQUARE FOUR CORNERS
wl-unicode: "\uF751"

# See comment before "Integral".
DoubleContourIntegral:
amslatex: "\\oiint"
has-unicode-inverse: false
is-letter-like: false
operator-name: DoubleContourIntegral
unicode-equivalent: "\u222F"
unicode-equivalent-name: SURFACE INTEGRAL
wl-unicode: "\u222F"
Expand Down Expand Up @@ -2677,7 +2673,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"
Expand Down Expand Up @@ -5003,13 +4998,15 @@ Information:
is-letter-like: false
operator-name: Information

# While one might think that Integral is an WL operator, it is not.
# The builtin function name is "Integrate". I imagine part of the
# reason is the complexity in specifying it as an operator which takes
# a min, max, a function, and some sort of derivative partial .
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
wl-unicode: "\u222B"
Expand Down Expand Up @@ -5188,6 +5185,7 @@ LeftAssociation:
esc-alias: <|
has-unicode-inverse: false
is-letter-like: false
operator-name: LeftAssociation
wl-unicode: "\uF113"

LeftBracketingBar:
Expand Down Expand Up @@ -5221,6 +5219,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"
Expand Down Expand Up @@ -5271,6 +5270,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
Expand All @@ -5280,7 +5285,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"
Expand Down Expand Up @@ -5530,7 +5534,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"
Expand Down Expand Up @@ -5649,11 +5652,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
Expand All @@ -5679,6 +5682,15 @@ Minus:
is-letter-like: false
operator-name: Minus

MinLmit:
amslatex: "\\lim_"
esc-alias: mlim
has-unicode-inverse: false
is-letter-like: false
unicode-equivalent: "lim"
wl-unicode: "\uF43A"
wl-unicode-name: PRIVATE-USE-F43A

MinusPlus:
amslatex: "\\mp"
esc-alias: -+
Expand Down Expand Up @@ -5888,7 +5900,6 @@ NotEqual:
esc-alias: '!='
has-unicode-inverse: false
is-letter-like: false
operator-name: NotEqual
unicode-equivalent: "\u2260"
unicode-equivalent-name: NOT EQUAL TO
wl-unicode: "\u2260"
Expand Down Expand Up @@ -6427,7 +6438,6 @@ Option:
ascii: ":"
has-unicode-inverse: false
is-letter-like: false
operator-name: Option

OptionKey:
esc-alias: opt
Expand Down Expand Up @@ -6491,7 +6501,7 @@ PartialD:
wl-unicode: "\u2202"
wl-unicode-name: PARTIAL DIFFERENTIAL

# See also Definition and RawQuestion
# See also RawQuestion
PatternTest:
ascii: "?"
has-unicode-inverse: false
Expand Down Expand Up @@ -6775,19 +6785,20 @@ 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

RawLeftBrace:
ascii: '{'
has-unicode-inverse: false
operator-name: LeftList
is-letter-like: false

RawLeftBracket:
Expand All @@ -6810,7 +6821,7 @@ RawPercent:
has-unicode-inverse: false
is-letter-like: false

# See also Definition and PatternTest
# See also PatternTest
RawQuestion:
ascii: "?"
has-unicode-inverse: false
Expand Down Expand Up @@ -7077,6 +7088,7 @@ RightAssociation:
esc-alias: '|>'
has-unicode-inverse: false
is-letter-like: false
operator-name: RightAssociation
wl-unicode: "\uF114"

RightBracketingBar:
Expand Down Expand Up @@ -7167,6 +7179,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
Expand All @@ -7176,7 +7194,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"
Expand Down Expand Up @@ -8581,11 +8598,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
Expand Down
15 changes: 15 additions & 0 deletions mathics_scanner/data/operators-additional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 33 additions & 9 deletions mathics_scanner/data/operators-intro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
# -----
#
Expand All @@ -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[???]

# WolframLangageData: a "PrecedenceRanks" value returned using:
# WolframLangageData[*operator_name*, "PrecedenceRanks"]
# Example:
# In[1] := WolframLangageData[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] := WolframLangageData[AddTo, "ShortNotations"]
# Out[2]= {+=}
# In[2] := WolframLangageData[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:
Expand Down
Loading

0 comments on commit a3c366f

Please sign in to comment.