Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go over row box parsing #832

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions mathics/builtin/makeboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
from mathics.core.expression import Expression
from mathics.core.list import ListExpression
from mathics.core.number import dps
from mathics.core.parser.parser import NEVER_ADD_PARENTHESIS
from mathics.core.symbols import Atom, Symbol
from mathics.core.systemsymbols import SymbolInputForm, SymbolOutputForm, SymbolRowBox
from mathics.eval.makeboxes import (
NEVER_ADD_PARENTHESIS,
_boxed_string,
format_element,
parenthesize,
)
from mathics.eval.makeboxes import _boxed_string, format_element, parenthesize


def int_to_s_exp(expr, n):
Expand Down
124 changes: 69 additions & 55 deletions mathics/core/parser/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,48 @@

from collections import defaultdict

binary_box_ops = {
"FractionBox": 670,
"OverscriptBox": 710,
"RadicalBox": 670,
"SubscriptBox": 695,
"SuperscriptBox": 590,
"UnderscriptBox": 710,
}

left_binary_ops = {
"Divide": 470,
"PlusMinus": 310,
"MinusPlus": 310,
"Subtract": 310,
"LeftTee": 190,
"DoubleLeftTee": 190,
"Condition": 130,
"ReplaceAll": 110,
"ReplaceRepeated": 110,
"Because": 50,
"PutAppend": 30,
"Put": 30,
"Postfix": 70,
}

misc_ops = {
"DifferentialD": 550,
"Sum": 320,
"Pattern": 150,
"Optional": 140,
"SqrtBox": 670,
"RadicalBox": 670,
"FractionBox": 670,
"OverscriptBox": 710,
"UnderscriptBox": 710,
"SubscriptBox": 695,
"FormBox": 670,
"SuperscriptBox": 590,
"UnderoverscriptBox": 700,
"SubsuperscriptBox": 690,
}

prefix_ops = {
"Get": 720,
"PreIncrement": 660,
Expand Down Expand Up @@ -35,44 +77,6 @@
"Function": 90,
}

left_binary_ops = {
"Divide": 470,
"PlusMinus": 310,
"MinusPlus": 310,
"Subtract": 310,
"LeftTee": 190,
"DoubleLeftTee": 190,
"Condition": 130,
"ReplaceAll": 110,
"ReplaceRepeated": 110,
"Because": 50,
"PutAppend": 30,
"Put": 30,
"Postfix": 70,
}

right_binary_ops = {
"Apply": 620,
"Map": 620,
"MapAll": 620,
"Power": 590,
"Implies": 200,
"RightTee": 190,
"DoubleRightTee": 190,
"SuchThat": 180,
"Rule": 120,
"RuleDelayed": 120,
"AddTo": 100,
"SubtractFrom": 100,
"TimesBy": 100,
"DivideBy": 100,
"Therefore": 50,
"UpSet": 40,
"Set": 40,
"SetDelayed": 40,
"UpSetDelayed": 40,
}

flat_binary_ops = {
"MessageName": 750,
"Composition": 625,
Expand Down Expand Up @@ -137,26 +141,36 @@
"PatternTest": 680,
}

ternary_ops = {
"Span": 305,
"Infix": 630,
right_binary_ops = {
"Apply": 620,
"Map": 620,
"MapAll": 620,
"Power": 590,
"Implies": 200,
"RightTee": 190,
"DoubleRightTee": 190,
"SuchThat": 180,
"Rule": 120,
"RuleDelayed": 120,
"AddTo": 100,
"SubtractFrom": 100,
"TimesBy": 100,
"DivideBy": 100,
"Therefore": 50,
"UpSet": 40,
"Set": 40,
"SetDelayed": 40,
"UpSetDelayed": 40,
}

misc_ops = {
"DifferentialD": 550,
"Sum": 320,
"Pattern": 150,
"Optional": 140,
"SqrtBox": 670,
"RadicalBox": 670,
"FractionBox": 670,
"OverscriptBox": 710,
"UnderscriptBox": 710,
"SubscriptBox": 695,
"FormBox": 670,
"SuperscriptBox": 590,
"UnderoverscriptBox": 700,
ternary_box_ops = {
"SubsuperscriptBox": 690,
"UnderoverscriptBox": 700,
}

ternary_ops = {
"Span": 305,
"Infix": 630,
}

inequality_ops = ["Less", "LessEqual", "Greater", "GreaterEqual", "Equal", "Unequal"]
Expand Down
Loading