Class: GhostWheel::Expression::Alternation

Inherits:
GhostWheel::Expression show all
Defined in:
lib/ghost_wheel/expression/alternation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GhostWheel::Expression

#parse

Constructor Details

#initialize(*expressions) ⇒ Alternation

Returns a new instance of Alternation.


6
7
8
# File 'lib/ghost_wheel/expression/alternation.rb', line 6

def initialize(*expressions)
  @expressions = expressions
end

Instance Attribute Details

#expressionsObject (readonly)

Returns the value of attribute expressions


10
11
12
# File 'lib/ghost_wheel/expression/alternation.rb', line 10

def expressions
  @expressions
end

Instance Method Details

#==(other) ⇒ Object


20
21
22
# File 'lib/ghost_wheel/expression/alternation.rb', line 20

def ==(other)
  super and @expressions == other.expressions
end

#uncached_parse(scanner, cache) ⇒ Object


12
13
14
15
16
17
18
# File 'lib/ghost_wheel/expression/alternation.rb', line 12

def uncached_parse(scanner, cache)
  @expressions.each do |expression|
    result = expression.parse(scanner, cache)
    return result unless result.is_a? FailedParseResult
  end
  FailedParseResult.instance
end