class Temple::Mixins::GrammarDSL::Element

Public Class Methods

new(grammar, rule) click to toggle source
Calls superclass method Temple::Mixins::GrammarDSL::Or::new
# File lib/temple/mixins/grammar_dsl.rb, line 85
def initialize(grammar, rule)
  super(grammar)
  @rule = grammar.Rule(rule)
end

Public Instance Methods

after_copy(source) click to toggle source
# File lib/temple/mixins/grammar_dsl.rb, line 96
def after_copy(source)
  @children = @children.map do |child|
    child == source ? self : child.copy_to(@grammar)
  end
  @rule = @rule.copy_to(@grammar)
end
match(exp, unmatched) click to toggle source
Calls superclass method Temple::Mixins::GrammarDSL::Or#match
# File lib/temple/mixins/grammar_dsl.rb, line 90
def match(exp, unmatched)
  return false unless Array === exp && !exp.empty?
  head, *tail = exp
  @rule.match(head, unmatched) && super(tail, unmatched)
end