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



90
91
92
93
94
95
# File 'lib/plurimath/latex/parse.rb', line 90

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

#read_textObject



97
98
99
100
101
102
# File 'lib/plurimath/latex/parse.rb', line 97

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