plurimath 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/Latex-Supported-Data.adoc +1 -0
- data/lib/plurimath/asciimath/parse.rb +1 -1
- data/lib/plurimath/asciimath/transform.rb +2 -6
- data/lib/plurimath/latex/constants.rb +2 -0
- data/lib/plurimath/math/core.rb +38 -6
- data/lib/plurimath/math/formula.rb +60 -6
- data/lib/plurimath/math/function/abs.rb +4 -0
- data/lib/plurimath/math/function/arg.rb +22 -0
- data/lib/plurimath/math/function/bar.rb +4 -0
- data/lib/plurimath/math/function/base.rb +49 -0
- data/lib/plurimath/math/function/binary_function.rb +6 -0
- data/lib/plurimath/math/function/cancel.rb +5 -0
- data/lib/plurimath/math/function/ceil.rb +6 -0
- data/lib/plurimath/math/function/color.rb +20 -1
- data/lib/plurimath/math/function/ddot.rb +4 -0
- data/lib/plurimath/math/function/dot.rb +5 -0
- data/lib/plurimath/math/function/fenced.rb +98 -7
- data/lib/plurimath/math/function/floor.rb +6 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
- data/lib/plurimath/math/function/font_style.rb +31 -6
- data/lib/plurimath/math/function/frac.rb +69 -15
- data/lib/plurimath/math/function/hat.rb +4 -0
- data/lib/plurimath/math/function/inf.rb +30 -0
- data/lib/plurimath/math/function/int.rb +47 -1
- data/lib/plurimath/math/function/intent.rb +22 -0
- data/lib/plurimath/math/function/left.rb +4 -0
- data/lib/plurimath/math/function/lim.rb +6 -0
- data/lib/plurimath/math/function/limits.rb +28 -0
- data/lib/plurimath/math/function/linebreak.rb +5 -0
- data/lib/plurimath/math/function/log.rb +27 -20
- data/lib/plurimath/math/function/longdiv.rb +4 -0
- data/lib/plurimath/math/function/mbox.rb +4 -0
- data/lib/plurimath/math/function/menclose.rb +74 -5
- data/lib/plurimath/math/function/merror.rb +2 -0
- data/lib/plurimath/math/function/mglyph.rb +64 -0
- data/lib/plurimath/math/function/mlabeledtr.rb +29 -0
- data/lib/plurimath/math/function/mod.rb +4 -0
- data/lib/plurimath/math/function/mpadded.rb +84 -0
- data/lib/plurimath/math/function/ms.rb +33 -0
- data/lib/plurimath/math/function/msgroup.rb +4 -0
- data/lib/plurimath/math/function/msline.rb +2 -4
- data/lib/plurimath/math/function/multiscript.rb +70 -6
- data/lib/plurimath/math/function/nary.rb +69 -10
- data/lib/plurimath/math/function/none.rb +25 -0
- data/lib/plurimath/math/function/norm.rb +6 -0
- data/lib/plurimath/math/function/obrace.rb +4 -0
- data/lib/plurimath/math/function/oint.rb +25 -1
- data/lib/plurimath/math/function/over.rb +6 -0
- data/lib/plurimath/math/function/overset.rb +46 -1
- data/lib/plurimath/math/function/phantom.rb +18 -2
- data/lib/plurimath/math/function/power.rb +37 -0
- data/lib/plurimath/math/function/power_base.rb +45 -18
- data/lib/plurimath/math/function/prod.rb +46 -0
- data/lib/plurimath/math/function/right.rb +4 -0
- data/lib/plurimath/math/function/root.rb +9 -1
- data/lib/plurimath/math/function/rule.rb +4 -0
- data/lib/plurimath/math/function/sqrt.rb +7 -1
- data/lib/plurimath/math/function/stackrel.rb +6 -0
- data/lib/plurimath/math/function/substack.rb +4 -0
- data/lib/plurimath/math/function/sum.rb +45 -24
- data/lib/plurimath/math/function/table/bmatrix.rb +18 -5
- data/lib/plurimath/math/function/table/cases.rb +24 -0
- data/lib/plurimath/math/function/table/eqarray.rb +24 -0
- data/lib/plurimath/math/function/table/matrix.rb +23 -3
- data/lib/plurimath/math/function/table/pmatrix.rb +4 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +10 -0
- data/lib/plurimath/math/function/table.rb +58 -7
- data/lib/plurimath/math/function/td.rb +9 -0
- data/lib/plurimath/math/function/ternary_function.rb +14 -1
- data/lib/plurimath/math/function/text.rb +6 -0
- data/lib/plurimath/math/function/tilde.rb +4 -0
- data/lib/plurimath/math/function/tr.rb +9 -0
- data/lib/plurimath/math/function/ubrace.rb +5 -0
- data/lib/plurimath/math/function/ul.rb +4 -0
- data/lib/plurimath/math/function/unary_function.rb +4 -0
- data/lib/plurimath/math/function/underover.rb +14 -0
- data/lib/plurimath/math/function/underset.rb +49 -1
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/number.rb +33 -3
- data/lib/plurimath/math/symbol.rb +68 -3
- data/lib/plurimath/math.rb +3 -2
- data/lib/plurimath/mathml/constants.rb +16 -0
- data/lib/plurimath/mathml/parser.rb +42 -2
- data/lib/plurimath/mathml/transform.rb +80 -29
- data/lib/plurimath/omml/parser.rb +8 -0
- data/lib/plurimath/omml/transform.rb +29 -26
- data/lib/plurimath/unicode_math/constants.rb +1015 -0
- data/lib/plurimath/unicode_math/parse.rb +233 -0
- data/lib/plurimath/unicode_math/parser.rb +58 -0
- data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +138 -0
- data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +114 -0
- data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +102 -0
- data/lib/plurimath/unicode_math/parsing_rules/helper.rb +19 -0
- data/lib/plurimath/unicode_math/parsing_rules/masked.rb +62 -0
- data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +254 -0
- data/lib/plurimath/unicode_math/transform.rb +3831 -0
- data/lib/plurimath/{unicode.rb → unicode_math.rb} +2 -2
- data/lib/plurimath/unitsml.rb +14 -1
- data/lib/plurimath/utility.rb +346 -11
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga.rb +5 -0
- data/lib/plurimath/xml_engine/ox.rb +5 -0
- metadata +23 -3
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "helper"
|
4
|
+
module Plurimath
|
5
|
+
class UnicodeMath
|
6
|
+
module ParsingRules
|
7
|
+
module Masked
|
8
|
+
include Helper
|
9
|
+
|
10
|
+
rule(:rect) { rect_symbols >> space? >> bracketed_masked_value(:rect) }
|
11
|
+
rule(:sqrt) { (sqrt_symbols.as(:root_symbol) >> (exp_script | operand).as(:first_value)).as(:root) }
|
12
|
+
rule(:qdrt) { (qdrt_symbols.as(:root_symbol) >> (exp_script | operand).as(:first_value)).as(:root) }
|
13
|
+
rule(:cbrt) { (cbrt_symbols.as(:root_symbol) >> (exp_script | operand).as(:first_value)).as(:root) }
|
14
|
+
|
15
|
+
rule(:color) { color_symbols >> space? >> bracketed_masked_value(:color) }
|
16
|
+
rule(:phant) { phantom_symbols >> space? >> bracketed_masked_value(:phantom) }
|
17
|
+
|
18
|
+
rule(:backcolor) { backcolor_symbols >> space? >> bracketed_masked_value(:backcolor) }
|
19
|
+
|
20
|
+
rule(:cbrt_symbols) { str("∛") | str("\\cbrt") }
|
21
|
+
rule(:qdrt_symbols) { str("∜") | str("\\cbrt") }
|
22
|
+
rule(:rect_symbols) { str("▭") | str("\\rect") }
|
23
|
+
rule(:sqrt_symbols) { str("√") | str("\\sqrt") | str("\\surd") }
|
24
|
+
rule(:root_symbols) { str("⒭") | str("√") | str("\\root") | str("\\surd") }
|
25
|
+
rule(:arg_function) do
|
26
|
+
str("ⓐ").as(:arg) >> str("(") >> a_ascii.as(:arg_arguments).maybe >> space? >> expression.as(:first_value).maybe >> str(")") |
|
27
|
+
str("ⓐ").as(:arg) >> a_ascii.as(:arg_arguments).maybe >> space? >> expression.as(:first_value).maybe
|
28
|
+
end
|
29
|
+
|
30
|
+
rule(:color_symbols) { str("✎") | str("\\color") }
|
31
|
+
rule(:phantom_symbols) { str("⟡") | str("\\phantom") }
|
32
|
+
rule(:monospace_fonts) { (str("ᅲ") >> str("(") >> match["^\)"].repeat(0).as(:monospace_value) >> str(")")).as(:monospace) }
|
33
|
+
|
34
|
+
rule(:backcolor_symbols) { str("☁") | str("\\backcolor") }
|
35
|
+
rule(:masked_recursive_value) { (space? >> expression | exp_bracket | exp_script).as(:expr) >> masked_recursive_value.as(:func_expr).maybe }
|
36
|
+
|
37
|
+
rule(:root_invisible_character?) { (str("\\naryand").absent? >> invisible_unicode).maybe }
|
38
|
+
|
39
|
+
rule(:nthrt) do
|
40
|
+
(sqrt_symbols >> str("(") >> masked_recursive_value.as(:first_value) >> str("&") >> masked_recursive_value.as(:second_value) >> str(")")).as(:root)
|
41
|
+
end
|
42
|
+
|
43
|
+
rule(:binary_root) do
|
44
|
+
root_symbols >> space? >> masked_recursive_value.as(:root_first_value) >> space? >> root_invisible_character? >> space? >> masked_recursive_value.as(:root_second_value)
|
45
|
+
end
|
46
|
+
|
47
|
+
rule(:intent_function) do
|
48
|
+
str("ⓘ").as(:intent) >> str("(").as(:open_paren) >> parsing_text.as(:intent_arguments).maybe >> space? >> expression.as(:first_value).maybe >> str(")").as(:close_paren) |
|
49
|
+
str("ⓘ").as(:intent) >> expression.as(:intent_expr)
|
50
|
+
end
|
51
|
+
|
52
|
+
def masked_value(func_name)
|
53
|
+
match["^&"].repeat(1).as(:"#{func_name}_value") >> str("&") >> masked_recursive_value.as(:first_value)
|
54
|
+
end
|
55
|
+
|
56
|
+
def bracketed_masked_value(func_name)
|
57
|
+
str("(") >> (masked_value(func_name).as(func_name)) >> str(")")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,254 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "helper"
|
4
|
+
module Plurimath
|
5
|
+
class UnicodeMath
|
6
|
+
module ParsingRules
|
7
|
+
module SubSup
|
8
|
+
include Helper
|
9
|
+
|
10
|
+
rule(:above) { (str("┴") | str("\\above")).as(:over) }
|
11
|
+
rule(:below) { (str("┬") | str("\\below")).as(:under) }
|
12
|
+
|
13
|
+
rule(:subscript) { base_value >> subscript_value }
|
14
|
+
rule(:supscript) { base_value >> supscript_value }
|
15
|
+
|
16
|
+
rule(:sub_or_sup) { subscript | supscript }
|
17
|
+
rule(:base_symbol) { str("_") }
|
18
|
+
rule(:base_syntax) { base_symbol | below }
|
19
|
+
rule(:alpha_ascii) { match["A-Za-z"].as(:symbol) }
|
20
|
+
rule(:script_base) { mini_sub_sup | sub_sup_operand }
|
21
|
+
|
22
|
+
rule(:power_symbol) { str("^") }
|
23
|
+
rule(:power_syntax) { power_symbol | above }
|
24
|
+
rule(:sub_override) { (invisible_space? >> base_syntax >> op_size_overrides_symbols >> (operator_symbols.maybe >> baseless_sub_values(:sub_script))) }
|
25
|
+
rule(:sup_override) { (invisible_space? >> power_syntax >> op_size_overrides_symbols >> (operator_symbols.maybe >> baseless_sup_values(:sup_script))) }
|
26
|
+
|
27
|
+
rule(:sub_sup_paren) { sub_paren.as(:sub_paren) | sup_paren.as(:sup_paren) }
|
28
|
+
rule(:pre_subscript) { base_syntax >> prescript_values.as(:pre_subscript) | sub_paren.as(:pre_subscript) }
|
29
|
+
rule(:pre_supscript) { power_syntax >> prescript_values.as(:pre_supscript) | sup_paren.as(:pre_supscript) }
|
30
|
+
|
31
|
+
rule(:mini_sub_value) { (sub_sup_operand.as(:base) >> sub_paren.as(:sub)).as(:mini_sub) }
|
32
|
+
rule(:mini_sup_value) { (sub_sup_operand.as(:base) >> sup_paren.as(:sup)).as(:mini_sup) }
|
33
|
+
|
34
|
+
rule(:pre_script_base) { (operand.as(:base) >> (subsup | mini_subsup | subscript_value | supscript_value).maybe) }
|
35
|
+
|
36
|
+
rule(:sub_sup_override) { sub_override | sup_override }
|
37
|
+
rule(:operator_symbols) { combined_symbols | negatable_symbols | operator }
|
38
|
+
rule(:invisible_space?) { (invisible_unicode? >> invisible_times.maybe).maybe }
|
39
|
+
rule(:prescript_values) { operand | mini_sub_sup | operator_symbols | binary_symbols }
|
40
|
+
|
41
|
+
rule(:power_base_script) { (base_value >> subsup).as(:subsup_exp) | subscript.as(:sub_exp) | supscript.as(:sup_exp) }
|
42
|
+
|
43
|
+
rule(:mini_sub_sup_present?) { mini_sub_value.present? | mini_sup_value.present? | mini_subsup.present? }
|
44
|
+
|
45
|
+
rule(:subscript_value) do
|
46
|
+
(sub_paren | baseless_sub.as(:sub)) >> recursive_baseless_sub_exp.maybe
|
47
|
+
end
|
48
|
+
|
49
|
+
rule(:supscript_value) do
|
50
|
+
(sup_paren | baseless_sup.as(:sup)) >> recursive_baseless_sup_exp.maybe
|
51
|
+
end
|
52
|
+
|
53
|
+
rule(:pre_sub_sup_override) do
|
54
|
+
base_syntax >> op_size_overrides_symbols >> prescript_values.as(:pre_subscript) |
|
55
|
+
power_syntax >> op_size_overrides_symbols >> prescript_values.as(:pre_supscript)
|
56
|
+
end
|
57
|
+
|
58
|
+
rule(:naryand_recursion) do
|
59
|
+
(operator.absent? >> naryand_values >> naryand_recursion.as(:naryand_recursion).maybe) |
|
60
|
+
(slashed_operator >> naryand_recursion.as(:naryand_recursion).maybe)
|
61
|
+
end
|
62
|
+
|
63
|
+
rule(:baseless_sub) do
|
64
|
+
(invisible_space? >> base_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols.maybe >> baseless_sub_values(:sub_script))) |
|
65
|
+
(invisible_space? >> base_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols >> recursive_baseless_sub_exp.maybe)) |
|
66
|
+
(invisible_space? >> base_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols >> baseless_sub_values(:sub_script).maybe)) |
|
67
|
+
sub_paren.as(:sub_script)
|
68
|
+
end
|
69
|
+
|
70
|
+
rule(:baseless_sup) do
|
71
|
+
(invisible_space? >> power_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols.maybe >> baseless_sup_values(:sup_script))) |
|
72
|
+
(invisible_space? >> power_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols >> recursive_baseless_sup_exp.maybe)) |
|
73
|
+
(invisible_space? >> power_syntax >> op_size_overrides_symbols.absent? >> (operator_symbols >> baseless_sup_values(:sup_script).maybe)) |
|
74
|
+
sup_paren.as(:sup_script)
|
75
|
+
end
|
76
|
+
|
77
|
+
rule(:recursive_baseless_sup_exp) do
|
78
|
+
(mini_sub_sup >> recursive_baseless_sup_exp.as(:exp_iteration).maybe) |
|
79
|
+
(baseless_sup.as(:sup_recursion) >> recursive_baseless_sup_exp.as(:exp_iteration).maybe)
|
80
|
+
end
|
81
|
+
|
82
|
+
rule(:recursive_baseless_sub_exp) do
|
83
|
+
(mini_sub_sup >> recursive_baseless_sub_exp.as(:exp_iteration).maybe) |
|
84
|
+
(baseless_sub.as(:sub_recursion) >> recursive_baseless_sub_exp.as(:exp_iteration).maybe)
|
85
|
+
end
|
86
|
+
|
87
|
+
rule(:naryand_values) do
|
88
|
+
fraction.as(:frac) |
|
89
|
+
(exp_bracket >> (subsup | subscript_value | supscript_value).maybe) |
|
90
|
+
(exp_script >> space?) |
|
91
|
+
negatable_symbols.absent? >> sub_sup_operand
|
92
|
+
end
|
93
|
+
|
94
|
+
rule(:mini_sub_sup) do
|
95
|
+
mini_sub_sup_present? >> (
|
96
|
+
(sub_sup_operand.as(:base) >> mini_subsup).as(:mini_sub_sup) |
|
97
|
+
mini_sub_value |
|
98
|
+
mini_sup_value
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
rule(:nary_sub_sup) do
|
103
|
+
(power_base_script.as(:nary_sub_sup) >> invisible_space? >> naryand_recursion.as(:naryand).maybe) |
|
104
|
+
(op_nary >> invisible_space? >> naryand_recursion.as(:naryand).maybe)
|
105
|
+
end
|
106
|
+
|
107
|
+
rule(:unary_sub_sup) do
|
108
|
+
((power_base_script | mini_sub_sup).as(:unary_sub_sup) >> (invisible_space? >> space?) >> expression.as(:first_value).maybe) |
|
109
|
+
(op_unary_functions >> (invisible_space? >> space?) >> expression.as(:first_value).maybe)
|
110
|
+
end
|
111
|
+
|
112
|
+
rule(:base_value) do
|
113
|
+
op_nary.present? >> op_nary >> invisible_space? >> number.as(:mask).maybe |
|
114
|
+
script_base.as(:base) >> invisible_space?
|
115
|
+
end
|
116
|
+
|
117
|
+
rule(:subsup) do
|
118
|
+
op_size_overrides_symbols.absent? >> baseless_sub.as(:sub) >> (sup_override.as(:sup) | baseless_sup.as(:sup)) |
|
119
|
+
op_size_overrides_symbols.absent? >> baseless_sup.as(:sup) >> (sub_override.as(:sub) | baseless_sub.as(:sub)) |
|
120
|
+
(sub_override.as(:sub) | baseless_sub.as(:sub)) >> baseless_sup.as(:sup) |
|
121
|
+
(sup_override.as(:sup) | baseless_sup.as(:sup)) >> baseless_sub.as(:sub)
|
122
|
+
end
|
123
|
+
|
124
|
+
rule(:mini_subsup) do
|
125
|
+
sub_paren.as(:sub) >> sup_paren.as(:sup) |
|
126
|
+
sup_paren.as(:sup) >> sub_paren.as(:sub)
|
127
|
+
end
|
128
|
+
|
129
|
+
rule(:accents_subsup) do
|
130
|
+
baseless_sub.as(:sub) >> baseless_sup.as(:sup) |
|
131
|
+
baseless_sup.as(:sup) >> baseless_sub.as(:sub) |
|
132
|
+
sub_paren.as(:sub) >> sup_paren.as(:sup) |
|
133
|
+
sup_paren.as(:sup) >> sub_paren.as(:sub) |
|
134
|
+
baseless_sub.as(:sub) |
|
135
|
+
baseless_sup.as(:sup) |
|
136
|
+
sub_paren.as(:sub) |
|
137
|
+
sup_paren.as(:sup)
|
138
|
+
end
|
139
|
+
|
140
|
+
rule(:mini_power_base) do
|
141
|
+
sup_paren.as(:pre_supscript) >> sub_paren.as(:pre_subscript).maybe >> mini_values.as(:mini_base) >> sub_paren.as(:mini_sub).maybe >> mini_values.as(:mini_sup) |
|
142
|
+
sub_paren.as(:pre_subscript) >> sup_paren.as(:pre_supscript).maybe >> mini_values.as(:mini_base) >> sup_paren.as(:mini_sup).maybe >> mini_values.as(:mini_sub) |
|
143
|
+
mini_values.as(:mini_base) >> sub_paren.as(:mini_sub) >> mini_values.as(:mini_sup) |
|
144
|
+
mini_values.as(:mini_base) >> sup_paren.as(:mini_sup) >> sub_paren.as(:mini_sub) |
|
145
|
+
mini_values.as(:mini_base) >> mini_values.as(:mini_sup) |
|
146
|
+
mini_values.as(:mini_base) >> sub_paren.as(:mini_sub)
|
147
|
+
end
|
148
|
+
|
149
|
+
rule(:mini_values) do
|
150
|
+
op_sup_operators |
|
151
|
+
op_sub_operators |
|
152
|
+
op_sup_digits |
|
153
|
+
op_sub_digits |
|
154
|
+
op_sup_alpha |
|
155
|
+
op_sub_alpha
|
156
|
+
end
|
157
|
+
|
158
|
+
rule(:exp_script) do
|
159
|
+
op_nary.present? >> nary_sub_sup.as(:nary) |
|
160
|
+
op_unary_functions.present? >> unary_sub_sup.as(:unary_subsup) |
|
161
|
+
accents.present? >> (accents.as(:base) >> accents_subsup).as(:accents_subsup) |
|
162
|
+
power_base_script |
|
163
|
+
(base_value >> sub_sup_override).as(:override_subsup) |
|
164
|
+
pre_sub_sup_override.as(:pre_override_subsup) >> pre_script_base |
|
165
|
+
(paren_wrap_rule(pre_subsup) >> space? >> pre_script_base).as(:pre_script) |
|
166
|
+
mini_sub_sup |
|
167
|
+
mini_power_base
|
168
|
+
end
|
169
|
+
|
170
|
+
rule(:pre_subsup) do
|
171
|
+
pre_subscript >> pre_supscript |
|
172
|
+
pre_supscript >> pre_subscript |
|
173
|
+
pre_subscript |
|
174
|
+
pre_supscript
|
175
|
+
end
|
176
|
+
|
177
|
+
rule(:sub_sup_operand) do
|
178
|
+
binary_symbols |
|
179
|
+
accents |
|
180
|
+
op_unary_functions >> invisible_unicode? |
|
181
|
+
alpha_numeric_values |
|
182
|
+
number |
|
183
|
+
an_math |
|
184
|
+
other |
|
185
|
+
exp_bracket |
|
186
|
+
parsing_text |
|
187
|
+
negatable_symbols |
|
188
|
+
soperand |
|
189
|
+
(str("|") | str("′")).as(:symbol)
|
190
|
+
end
|
191
|
+
|
192
|
+
rule(:sub_alpha_digits) do
|
193
|
+
(op_sub_digits >> op_sub_alpha).as(:expr) >> sub_paren.as(:sub_recursion).maybe |
|
194
|
+
(op_sub_alpha >> op_sub_digits).as(:expr) >> sub_paren.as(:sub_recursion).maybe |
|
195
|
+
op_sub_alpha >> sub_paren.as(:sub_recursion_expr).maybe |
|
196
|
+
op_sub_digits >> sub_paren.as(:sub_recursion_expr).maybe |
|
197
|
+
op_sub_operators >> sub_paren.as(:sub_recursions).maybe
|
198
|
+
end
|
199
|
+
|
200
|
+
rule(:sup_alpha_digits) do
|
201
|
+
(op_sup_digits >> op_sup_alpha).as(:expr) >> sup_paren.as(:sup_recursion).maybe |
|
202
|
+
(op_sup_alpha >> op_sup_digits).as(:expr) >> sup_paren.as(:sup_recursion).maybe |
|
203
|
+
op_sup_alpha >> sup_paren.as(:sup_recursion_expr).maybe |
|
204
|
+
op_sup_digits >> sup_paren.as(:sup_recursion_expr).maybe |
|
205
|
+
op_sup_operators >> sup_paren.as(:sup_recursions).maybe
|
206
|
+
end
|
207
|
+
|
208
|
+
rule(:sub_paren) do
|
209
|
+
(op_sub_open_paren >> sub_alpha_digits.as(:mini_expr) >> op_sub_close_paren).as(:mini_intermediate_exp) >> sub_paren.maybe |
|
210
|
+
sub_alpha_digits >> sub_paren.maybe
|
211
|
+
end
|
212
|
+
|
213
|
+
rule(:sup_paren) do
|
214
|
+
(op_sup_open_paren >> sup_alpha_digits.as(:mini_expr) >> op_sup_close_paren).as(:mini_intermediate_exp) >> sup_paren.maybe |
|
215
|
+
sup_alpha_digits >> sup_paren.maybe
|
216
|
+
end
|
217
|
+
|
218
|
+
rule(:sub_sup_values) do
|
219
|
+
(operator_symbols.as(:expr) >> (((mini_sub_sup | sub_or_sup) >> space?) >> bracketed_soperand.maybe)) |
|
220
|
+
(operator_symbols.as(:expr) >> bracketed_soperand) |
|
221
|
+
(((primes | prefixed_primes).as(:symbol).as(:first_value) >> repeated_accent_symbols).as(:accents) >> (sub_or_sup.maybe >> space? >> bracketed_soperand).maybe) |
|
222
|
+
bracketed_soperand >> operator_symbols.absent? >> sub_sup_values.as(:expr).maybe |
|
223
|
+
sub_sup_binary_absent >> operator_symbols.absent? >> sub_sup_values.as(:expr).maybe |
|
224
|
+
bracketed_soperand |
|
225
|
+
prefixed_primes |
|
226
|
+
primes |
|
227
|
+
sub_sup_binary_absent
|
228
|
+
end
|
229
|
+
|
230
|
+
rule(:alpha_numeric_values) do
|
231
|
+
alpha_ascii >> alpha_numeric_values.as(:expr) |
|
232
|
+
(number | n_ascii) >> alpha_numeric_values.as(:expr) |
|
233
|
+
alpha_ascii |
|
234
|
+
(number | n_ascii)
|
235
|
+
end
|
236
|
+
|
237
|
+
def paren_wrap_rule(passed_rule)
|
238
|
+
(op_opener >> space? >> passed_rule >> space? >> op_closer) |
|
239
|
+
passed_rule
|
240
|
+
end
|
241
|
+
|
242
|
+
def baseless_sub_values(soperand_name)
|
243
|
+
(mini_sub_sup | sub_sup_paren).as(soperand_name) >> recursive_baseless_sub_exp.maybe >> sub_sup_values.maybe |
|
244
|
+
sub_sup_values.as(soperand_name) >> recursive_baseless_sub_exp.maybe
|
245
|
+
end
|
246
|
+
|
247
|
+
def baseless_sup_values(soperand_name)
|
248
|
+
(mini_sub_sup | sub_sup_paren).as(soperand_name) >> recursive_baseless_sup_exp.maybe >> sub_sup_values.maybe |
|
249
|
+
sub_sup_values.as(soperand_name) >> recursive_baseless_sup_exp.maybe
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|