plurimath 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +8 -11
- data/.gitignore +1 -0
- data/AsciiMath-Supported-Data.adoc +280 -0
- data/Gemfile +1 -0
- data/Latex-Supported-Data.adoc +1872 -0
- data/MathML-Supported-Data.adoc +270 -0
- data/README.adoc +94 -0
- data/lib/plurimath/asciimath/constants.rb +215 -222
- data/lib/plurimath/asciimath/parse.rb +45 -11
- data/lib/plurimath/asciimath/parser.rb +4 -3
- data/lib/plurimath/asciimath/transform.rb +222 -131
- data/lib/plurimath/asciimath.rb +1 -1
- data/lib/plurimath/html/constants.rb +50 -0
- data/lib/plurimath/html/parse.rb +149 -0
- data/lib/plurimath/html/parser.rb +26 -0
- data/lib/plurimath/html/transform.rb +363 -0
- data/lib/plurimath/html.rb +1 -1
- data/lib/plurimath/latex/constants.rb +1885 -1858
- data/lib/plurimath/latex/parse.rb +127 -34
- data/lib/plurimath/latex/parser.rb +5 -4
- data/lib/plurimath/latex/transform.rb +324 -164
- data/lib/plurimath/math/formula.rb +9 -1
- data/lib/plurimath/math/function/bar.rb +1 -1
- data/lib/plurimath/math/function/base.rb +7 -1
- data/lib/plurimath/math/function/binary_function.rb +10 -5
- data/lib/plurimath/math/function/color.rb +4 -4
- data/lib/plurimath/math/function/fenced.rb +7 -2
- data/lib/plurimath/math/function/font_style/bold.rb +18 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
- data/lib/plurimath/math/function/font_style/script.rb +18 -0
- data/lib/plurimath/math/function/font_style.rb +2 -22
- data/lib/plurimath/math/function/frac.rb +4 -4
- data/lib/plurimath/math/function/inf.rb +0 -1
- data/lib/plurimath/math/function/left.rb +3 -6
- data/lib/plurimath/math/function/limits.rb +0 -1
- data/lib/plurimath/math/function/log.rb +6 -0
- data/lib/plurimath/math/function/mod.rb +6 -0
- data/lib/plurimath/math/function/multiscript.rb +11 -0
- data/lib/plurimath/math/function/norm.rb +2 -1
- data/lib/plurimath/math/function/over.rb +29 -0
- data/lib/plurimath/math/function/overset.rb +2 -2
- data/lib/plurimath/math/function/power.rb +7 -1
- data/lib/plurimath/math/function/power_base.rb +14 -7
- data/lib/plurimath/math/function/prod.rb +6 -0
- data/lib/plurimath/math/function/right.rb +24 -0
- data/lib/plurimath/math/function/root.rb +5 -4
- data/lib/plurimath/math/function/sqrt.rb +1 -1
- data/lib/plurimath/math/function/substack.rb +0 -1
- data/lib/plurimath/math/function/sum.rb +6 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +25 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
- data/lib/plurimath/math/function/table/matrix.rb +24 -0
- data/lib/plurimath/math/function/table/multline.rb +24 -0
- data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
- data/lib/plurimath/math/function/table/split.rb +24 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
- data/lib/plurimath/math/function/table.rb +17 -5
- data/lib/plurimath/math/function/td.rb +6 -1
- data/lib/plurimath/math/function/ternary_function.rb +16 -6
- data/lib/plurimath/math/function/text.rb +19 -7
- data/lib/plurimath/math/function/tr.rb +6 -1
- data/lib/plurimath/math/function/unary_function.rb +5 -0
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +8 -0
- data/lib/plurimath/math/symbol.rb +12 -3
- data/lib/plurimath/math.rb +9 -4
- data/lib/plurimath/mathml/constants.rb +2 -34
- data/lib/plurimath/mathml/parse.rb +7 -2
- data/lib/plurimath/mathml/parser.rb +2 -1
- data/lib/plurimath/mathml/transform.rb +73 -68
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/constants.rb +154 -0
- data/lib/plurimath/omml/parser.rb +22 -0
- data/lib/plurimath/omml/transform.rb +216 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +73 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +49 -7
- data/README.md +0 -40
@@ -3,233 +3,226 @@
|
|
3
3
|
module Plurimath
|
4
4
|
class Asciimath
|
5
5
|
class Constants
|
6
|
-
|
6
|
+
TABLE_PARENTHESIS = {
|
7
|
+
"[": "]",
|
8
|
+
"{": "}",
|
7
9
|
"(": ")",
|
10
|
+
"|": "|",
|
11
|
+
}.freeze
|
12
|
+
PARENTHESIS = {
|
8
13
|
"(:": ":)",
|
9
|
-
"{": "}",
|
10
14
|
"{:": ":}",
|
15
|
+
"(": ")",
|
16
|
+
"{": "}",
|
11
17
|
"[": "]",
|
12
18
|
}.freeze
|
13
|
-
SYMBOLS =
|
14
|
-
twoheadrightarrowtail
|
15
|
-
twoheadrightarrow
|
16
|
-
rightarrowtail
|
17
|
-
Leftrightarrow
|
18
|
-
leftrightarrow
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Leftarrow
|
23
|
-
leftarrow
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
bigwedge
|
30
|
-
rceiling
|
31
|
-
lceiling
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
emptyset
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
epsilon
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
varphi
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
alpha
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
sigma
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
Pi
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
gt
|
221
|
-
|~
|
222
|
-
in
|
223
|
-
/_
|
224
|
-
>
|
225
|
-
@
|
226
|
-
/
|
227
|
-
*
|
228
|
-
-
|
229
|
-
<
|
230
|
-
=
|
231
|
-
+
|
232
|
-
].freeze
|
19
|
+
SYMBOLS = {
|
20
|
+
twoheadrightarrowtail: :"⤖",
|
21
|
+
twoheadrightarrow: :"↠",
|
22
|
+
rightarrowtail: :"↣",
|
23
|
+
Leftrightarrow: :"⇔",
|
24
|
+
leftrightarrow: :"↔",
|
25
|
+
Rightarrow: :"⇒",
|
26
|
+
rightarrow: :"→",
|
27
|
+
varepsilon: :"ɛ",
|
28
|
+
Leftarrow: :"⇐",
|
29
|
+
leftarrow: :"←",
|
30
|
+
downarrow: :"↓",
|
31
|
+
therefore: :"∴",
|
32
|
+
backslash: :"\\",
|
33
|
+
setminus: :"\\",
|
34
|
+
triangle: :"△",
|
35
|
+
bigwedge: :"⋀",
|
36
|
+
rceiling: :"⌉",
|
37
|
+
lceiling: :"⌈",
|
38
|
+
supseteq: :"⊇",
|
39
|
+
subseteq: :"⊆",
|
40
|
+
vartheta: :"ϑ",
|
41
|
+
emptyset: :"∅",
|
42
|
+
diamond: :"⋄",
|
43
|
+
uparrow: :"↑",
|
44
|
+
implies: :"⇒",
|
45
|
+
partial: :"∂",
|
46
|
+
because: :"∵",
|
47
|
+
upsilon: :"υ",
|
48
|
+
epsilon: :"ε",
|
49
|
+
bigcap: :"⋂",
|
50
|
+
bigvee: :"⋁",
|
51
|
+
propto: :"∝",
|
52
|
+
approx: :"≈",
|
53
|
+
exists: :"∃",
|
54
|
+
forall: :"∀",
|
55
|
+
otimes: :"⊗",
|
56
|
+
ltimes: :"⋉",
|
57
|
+
bowtie: :"⋈",
|
58
|
+
rtimes: :"⋊",
|
59
|
+
models: :"⊨",
|
60
|
+
mapsto: :"↦",
|
61
|
+
bigcup: :"⋃",
|
62
|
+
succeq: :"⪰",
|
63
|
+
preceq: :"⪯",
|
64
|
+
rfloor: :"⌋",
|
65
|
+
lfloor: :"⌊",
|
66
|
+
square: :"□",
|
67
|
+
supset: :"⊃",
|
68
|
+
subset: :"⊂",
|
69
|
+
lambda: :"λ",
|
70
|
+
Lambda: :"Λ",
|
71
|
+
varphi: :"φ",
|
72
|
+
">->>": :"⤖",
|
73
|
+
"/_\\": :"△",
|
74
|
+
"|><|": :"⋈",
|
75
|
+
kappa: :"κ",
|
76
|
+
Delta: :"Δ",
|
77
|
+
delta: :"δ",
|
78
|
+
gamma: :"γ",
|
79
|
+
Gamma: :"Γ",
|
80
|
+
Theta: :"Θ",
|
81
|
+
theta: :"θ",
|
82
|
+
alpha: :"α",
|
83
|
+
aleph: :"ࡗ",
|
84
|
+
infty: :"ÝE;",
|
85
|
+
equiv: :"ࣕ",
|
86
|
+
frown: :"ऒ",
|
87
|
+
notin: :"ࢡ",
|
88
|
+
angle: :"ࢬ",
|
89
|
+
"!in": :"∉",
|
90
|
+
cdots: :"⋯",
|
91
|
+
vdash: :"⊢",
|
92
|
+
wedge: :"∧",
|
93
|
+
oplus: :"⊕",
|
94
|
+
nabla: :"∇",
|
95
|
+
ddots: :"⋱",
|
96
|
+
vdots: :"⋮",
|
97
|
+
Sigma: :"A3;",
|
98
|
+
Omega: :"A9;",
|
99
|
+
omega: :"C9;",
|
100
|
+
sigma: :"C3;",
|
101
|
+
times: :"×",
|
102
|
+
ldots: :"...",
|
103
|
+
">-=": :"⪰",
|
104
|
+
"-<=": :"⪯",
|
105
|
+
"><|": :"⋊",
|
106
|
+
"|==": :"⊨",
|
107
|
+
"|--": :"⊢",
|
108
|
+
"^^^": :"⋀",
|
109
|
+
"|->": :"↦",
|
110
|
+
">->": :"↣",
|
111
|
+
"->>": :"↠",
|
112
|
+
"__|": :"⌋",
|
113
|
+
"|__": :"⌊",
|
114
|
+
"|><": :"⋉",
|
115
|
+
"_|_": :"⊥",
|
116
|
+
"***": :"⋆",
|
117
|
+
"<=>": :"⇔",
|
118
|
+
quad: :"  ",
|
119
|
+
star: :"⋆",
|
120
|
+
odot: :"⊙",
|
121
|
+
cdot: :"⋅",
|
122
|
+
rarr: :"→",
|
123
|
+
darr: :"↓",
|
124
|
+
prop: :"∝",
|
125
|
+
lArr: :"⇐",
|
126
|
+
rArr: :"⇒",
|
127
|
+
uarr: :"↑",
|
128
|
+
hArr: :"⇔",
|
129
|
+
harr: :"↔",
|
130
|
+
larr: :"←",
|
131
|
+
grad: :"∇",
|
132
|
+
circ: :"∘",
|
133
|
+
sube: :"⊆",
|
134
|
+
supe: :"⊇",
|
135
|
+
succ: :"ãB;",
|
136
|
+
prec: :"ãA;",
|
137
|
+
cong: :"ࣅ",
|
138
|
+
beta: :"β",
|
139
|
+
zeta: :"ζ",
|
140
|
+
iota: :"ι",
|
141
|
+
":'": :"∵",
|
142
|
+
"^^": :"∧",
|
143
|
+
"o+": :"⊕",
|
144
|
+
"o.": :"⊙",
|
145
|
+
"**": :"∗",
|
146
|
+
"~~": :"≈",
|
147
|
+
"O/": :"∅",
|
148
|
+
"->": :"→",
|
149
|
+
"=>": :"⇒",
|
150
|
+
">>": :"〉",
|
151
|
+
"<<": :"〈",
|
152
|
+
"~|": :"⌉",
|
153
|
+
"!=": :"≠",
|
154
|
+
">-": :"≻",
|
155
|
+
"-<": :"≺",
|
156
|
+
"~=": :"≅",
|
157
|
+
"-=": :"≡",
|
158
|
+
":.": :"∴",
|
159
|
+
">=": :"≥",
|
160
|
+
"<=": :"≤",
|
161
|
+
"|~": :"⌈",
|
162
|
+
"/_": :"∠",
|
163
|
+
"+-": :"±",
|
164
|
+
"-:": :"÷",
|
165
|
+
sup: :"⊃",
|
166
|
+
sub: :"⊂",
|
167
|
+
top: :"⊤",
|
168
|
+
vvv: :"⋁",
|
169
|
+
vee: :"∨",
|
170
|
+
nnn: :"⋂",
|
171
|
+
cap: :"∩",
|
172
|
+
ast: :"∗",
|
173
|
+
bot: :"⊥",
|
174
|
+
del: :"∂",
|
175
|
+
uuu: :"⋃",
|
176
|
+
cup: :"∪",
|
177
|
+
iff: :"⇔",
|
178
|
+
eta: :"η",
|
179
|
+
Phi: :"Φ",
|
180
|
+
Psi: :"Ψ",
|
181
|
+
psi: :"ψ",
|
182
|
+
chi: :"χ",
|
183
|
+
phi: :"ϕ",
|
184
|
+
rho: :"ρ",
|
185
|
+
tau: :"τ",
|
186
|
+
div: :"÷",
|
187
|
+
neg: :"¬",
|
188
|
+
not: :"¬",
|
189
|
+
"@": :"∘",
|
190
|
+
"*": :"⋅",
|
191
|
+
"<": :"<",
|
192
|
+
">": :">",
|
193
|
+
"-": :"-",
|
194
|
+
"=": :"=",
|
195
|
+
"+": :"+",
|
196
|
+
"/": :"/",
|
197
|
+
nn: :"∩",
|
198
|
+
vv: :"∨",
|
199
|
+
TT: :"⊤",
|
200
|
+
EE: :"∃",
|
201
|
+
ox: :"⊗",
|
202
|
+
to: :"→",
|
203
|
+
AA: :"∀",
|
204
|
+
uu: :"∪",
|
205
|
+
ne: :"≠",
|
206
|
+
ZZ: :"ℤ",
|
207
|
+
RR: :"ℝ",
|
208
|
+
QQ: :"ℚ",
|
209
|
+
NN: :"ℕ",
|
210
|
+
CC: :"ℂ",
|
211
|
+
oo: :"∞",
|
212
|
+
ge: :"≥",
|
213
|
+
le: :"≤",
|
214
|
+
in: :"∈",
|
215
|
+
nu: :"ν",
|
216
|
+
mu: :"μ",
|
217
|
+
pi: :"π",
|
218
|
+
Pi: :"Π",
|
219
|
+
xi: :"ξ",
|
220
|
+
Xi: :"Ξ",
|
221
|
+
xx: :"×",
|
222
|
+
pm: :"±",
|
223
|
+
gt: :">",
|
224
|
+
lt: :"<",
|
225
|
+
}.freeze
|
233
226
|
UNARY_CLASSES = %i[
|
234
227
|
arccos
|
235
228
|
arcsin
|
@@ -4,17 +4,32 @@ require "parslet"
|
|
4
4
|
module Plurimath
|
5
5
|
class Asciimath
|
6
6
|
class Parse < Parslet::Parser
|
7
|
-
rule(:
|
7
|
+
rule(:space) { str(" ") }
|
8
|
+
rule(:base) { str("_").as(:_) }
|
9
|
+
rule(:power) { str("^").as(:^) }
|
10
|
+
rule(:comma) { (str(",") >> space) | str(",") }
|
8
11
|
|
9
|
-
rule(:
|
12
|
+
rule(:symbols) { arr_to_expression(Constants::SYMBOLS.keys, :symbol) }
|
13
|
+
rule(:font_style) { arr_to_expression(Constants::FONT_STYLES, :fonts) }
|
10
14
|
|
11
|
-
rule(:
|
15
|
+
rule(:unary_functions) { arr_to_expression(Constants::UNARY_CLASSES) }
|
16
|
+
rule(:binary_functions) { arr_to_expression(Constants::BINARY_CLASSES) }
|
12
17
|
|
13
|
-
rule(:
|
18
|
+
rule(:left_right_open_paren) { str("(") | str("[") }
|
19
|
+
rule(:left_right_close_paren) { str(")") | str("]") }
|
14
20
|
|
15
|
-
rule(:
|
21
|
+
rule(:left_right) do
|
22
|
+
(str("left") >> left_right_open_paren.as(:left) >> iteration.as(:left_right_value) >> str("right") >> left_right_close_paren.as(:right)) |
|
23
|
+
table
|
24
|
+
end
|
16
25
|
|
17
|
-
rule(:
|
26
|
+
rule(:open_table) do
|
27
|
+
arr_to_expression(Constants::TABLE_PARENTHESIS.keys, :table_left)
|
28
|
+
end
|
29
|
+
|
30
|
+
rule(:close_table) do
|
31
|
+
arr_to_expression(Constants::TABLE_PARENTHESIS.values, :table_right)
|
32
|
+
end
|
18
33
|
|
19
34
|
rule(:lparen) do
|
20
35
|
Constants::PARENTHESIS.keys.reduce do |expression, parenthesis|
|
@@ -43,6 +58,21 @@ module Plurimath
|
|
43
58
|
match("[0-9]").repeat(1).as(:number)
|
44
59
|
end
|
45
60
|
|
61
|
+
rule(:table) do
|
62
|
+
(open_table.as(:table_left) >> tr >> close_table.as(:table_right)) |
|
63
|
+
(str("left") >> left_right_open_paren.as(:left) >> tr >> str("right") >> left_right_close_paren.as(:right))
|
64
|
+
end
|
65
|
+
|
66
|
+
rule(:tr) do
|
67
|
+
((str("[").as(:open_tr) >> td.as(:tds_list) >> str("]")).as(:table_row) >> comma >> tr.as(:expr)) |
|
68
|
+
(str("[").as(:open_tr) >> td.as(:tds_list) >> str("]")).as(:table_row)
|
69
|
+
end
|
70
|
+
|
71
|
+
rule(:td) do
|
72
|
+
(sequence.as(:td) >> str(",") >> sequence.as(:tds)) |
|
73
|
+
sequence.as(:td)
|
74
|
+
end
|
75
|
+
|
46
76
|
rule(:sequence) do
|
47
77
|
(lparen >> expression >> rparen).as(:intermediate_exp) |
|
48
78
|
(binary_functions >> sequence.as(:base) >> sequence.maybe.as(:exponent)).as(:binary) |
|
@@ -53,16 +83,18 @@ module Plurimath
|
|
53
83
|
end
|
54
84
|
|
55
85
|
rule(:iteration) do
|
56
|
-
|
86
|
+
table.as(:table) |
|
87
|
+
(sequence.as(:dividend) >> str("mod").as(:mod) >> sequence.as(:divisor)).as(:mod) |
|
57
88
|
(sequence >> base >> sequence.as(:base) >> power >> sequence.as(:exponent)).as(:power_base) |
|
58
89
|
(sequence >> base >> sequence).as(:base) |
|
59
90
|
(sequence >> power >> sequence).as(:power) |
|
60
91
|
sequence.as(:sequence) |
|
61
|
-
|
92
|
+
space
|
62
93
|
end
|
63
94
|
|
64
95
|
rule(:expression) do
|
65
|
-
|
96
|
+
left_right.as(:left_right) |
|
97
|
+
(iteration >> expression).as(:expr) |
|
66
98
|
(iteration >> str("/").as(:/) >> iteration).as(:expr) |
|
67
99
|
str("")
|
68
100
|
end
|
@@ -70,9 +102,11 @@ module Plurimath
|
|
70
102
|
root :expression
|
71
103
|
|
72
104
|
def arr_to_expression(arr, name = nil)
|
105
|
+
type = arr.first.class
|
73
106
|
arr.reduce do |expression, expr_string|
|
74
|
-
|
75
|
-
expression
|
107
|
+
as_value = name.nil? ? expr_string || expression : name
|
108
|
+
expression = str(expression).as(as_value) if expression.is_a?(type)
|
109
|
+
expression | str(expr_string).as(as_value)
|
76
110
|
end
|
77
111
|
end
|
78
112
|
|
@@ -14,10 +14,11 @@ module Plurimath
|
|
14
14
|
|
15
15
|
def parse
|
16
16
|
nodes = Parse.new.parse(text)
|
17
|
-
|
18
|
-
|
17
|
+
nodes = JSON.parse(nodes.to_json, symbolize_names: true)
|
18
|
+
transformed_tree = Transform.new.apply(nodes)
|
19
|
+
return transformed_tree if transformed_tree.is_a?(Math::Formula)
|
19
20
|
|
20
|
-
|
21
|
+
Math::Formula.new(transformed_tree)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|