Class: Plurimath::Latex::Parse

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/plurimath/latex/parse.rb

Instance Method Summary collapse

Instance Method Details

#arr_to_expression(array, name = nil) ⇒ Object



180
181
182
183
184
185
186
187
# File 'lib/plurimath/latex/parse.rb', line 180

def arr_to_expression(array, name = nil)
  type = array.first.class
  array.reduce do |expression, expr_string|
    name = name || expr_string.to_sym || expression.to_sym
    expression = str(expression).as(name) if expression.is_a?(type)
    expression | str(expr_string).as(name)
  end
end

#read_textObject



189
190
191
192
193
194
195
# File 'lib/plurimath/latex/parse.rb', line 189

def read_text
  dynamic do |_sour, context|
    lparen = context.captures[:paren][:lparen].to_s
    rparen = Constants::PARENTHESIS[lparen]
    match("[^#{rparen}]").repeat.as(:mbox)
  end
end