Class: Temple::Mixins::GrammarDSL::Or Private

Inherits:
Rule show all
Defined in:
lib/temple/mixins/grammar_dsl.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

Element, Root

Instance Method Summary collapse

Methods inherited from Rule

#copy_to, #match?

Constructor Details

#initialize(grammar, *children) ⇒ Or

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Or.



29
30
31
32
# File 'lib/temple/mixins/grammar_dsl.rb', line 29

def initialize(grammar, *children)
  super(grammar)
  @children = children.map {|rule| @grammar.Rule(rule) }
end

Instance Method Details

#<<(rule) ⇒ Object Also known as: |

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
# File 'lib/temple/mixins/grammar_dsl.rb', line 34

def <<(rule)
  @children << @grammar.Rule(rule)
  self
end

#after_copy(source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/temple/mixins/grammar_dsl.rb', line 46

def after_copy(source)
  @children = @children.map {|child| child.copy_to(@grammar) }
end

#match(exp, unmatched) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
# File 'lib/temple/mixins/grammar_dsl.rb', line 41

def match(exp, unmatched)
  tmp = []
  @children.any? {|rule| rule.match(exp, tmp) } || (unmatched.concat(tmp) && false)
end