Class: Plurimath::Asciimath::Parse
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- Plurimath::Asciimath::Parse
- Defined in:
- lib/plurimath/asciimath/parse.rb
Instance Method Summary collapse
Instance Method Details
#arr_to_expression(arr, name = nil) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/plurimath/asciimath/parse.rb', line 104 def arr_to_expression(arr, name = nil) type = arr.first.class arr.reduce do |expression, expr_string| as_value = name.nil? ? expr_string || expression : name expression = str(expression).as(as_value) if expression.is_a?(type) expression | str(expr_string).as(as_value) end end |
#read_text ⇒ Object
113 114 115 116 117 118 |
# File 'lib/plurimath/asciimath/parse.rb', line 113 def read_text dynamic do |_sour, context| rparen = Constants::PARENTHESIS[context.captures[:paren].to_sym] match("[^#{rparen}]").repeat.as(:text) end end |