Parent

Files

Parslet::Accelerator::Apply

@api private

Public Class Methods

new(engine, expr) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 7
def initialize(engine, expr)
  @engine = engine
  @expr = expr
end

Public Instance Methods

match(type_tag) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 67
def match(type_tag)
  expr_tag = @expr.type
  if expr_tag == type_tag
    yield *@expr.args
  end
end
visit_alternative(alternatives) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 28
def visit_alternative(alternatives)
  match(:alt) do |*expressions|
    return false if alternatives.size != expressions.size

    alternatives.zip(expressions).all? do |atom, expr|
      @engine.match(atom, expr)
    end
  end
end
visit_entity(name, block) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 15
def visit_entity(name, block)
  false
end
visit_lookahead(positive, atom) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 46
def visit_lookahead(positive, atom)
  match(:absent) do |expr|
    return positive == false && @engine.match(atom, expr)
  end
  match(:present) do |expr|
    return positive == true && @engine.match(atom, expr)
  end
end
visit_named(name, atom) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 18
def visit_named(name, atom)
  match(:as) do |key|
    @engine.try_bind(key, name)
  end
end
visit_parser(root) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 12
def visit_parser(root)
  false
end
visit_re(regexp) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 54
def visit_re(regexp)
  match(:re) do |*bind_conditions|
    bind_conditions.all? { |bind_cond| 
      @engine.try_bind(bind_cond, regexp) }
  end
end
visit_repetition(tag, min, max, atom) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 23
def visit_repetition(tag, min, max, atom)
  match(:rep) do |e_min, e_max, expr|
    e_min == min && e_max == max && @engine.match(atom, expr)
  end
end
visit_sequence(sequence) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 37
def visit_sequence(sequence)
  match(:seq) do |*expressions|
    return false if sequence.size != expressions.size

    sequence.zip(expressions).all? do |atom, expr|
      @engine.match(atom, expr)
    end
  end
end
visit_str(str) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 60
def visit_str(str)
  match(:str) do |*bind_conditions|
    bind_conditions.all? { |bind_cond| 
      @engine.try_bind(bind_cond, str) }
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.