Class: Electr::ExpressionRule
- Defined in:
- lib/electr/parser/rules/expression_rule.rb
Instance Method Summary collapse
Methods inherited from BaseRule
Constructor Details
This class inherits a constructor from Electr::BaseRule
Instance Method Details
#apply! ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/electr/parser/rules/expression_rule.rb', line 5 def apply! while @units.size > 0 if first_unit_fname? accept(:fname) accept(:open_parenthesis, '(') while @units.first && (not @units.first.closed_parenthesis?) accept(@units.first.type) end accept(:closed_parenthesis, ')') else accept(@units.first.type) end end sya = Sya.new(@series.dup) @series = sya.run if @series.first.numeric? || @series.first.constant? || @series.first.value? || @series.first.fname? dig_series(@ast_node) else unit = @series.shift node = OperatorAST.new(unit.value) dig_series(node) while @series.size > 0 @ast_node.add_child(node) end end |