Class: GhostWheel::Expression::Sequence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GhostWheel::Expression

#parse

Constructor Details

#initialize(*expressions) ⇒ Sequence

Returns a new instance of Sequence.



6
7
8
# File 'lib/ghost_wheel/expression/sequence.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/sequence.rb', line 10

def expressions
  @expressions
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/ghost_wheel/expression/sequence.rb', line 25

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

#uncached_parse(scanner, cache) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ghost_wheel/expression/sequence.rb', line 12

def uncached_parse(scanner, cache)
  scanner.transaction do
    parsed = ParseResult.new(Array.new)
    @expressions.each do |expression|
      case result = expression.parse(scanner, cache)
      when FailedParseResult then scanner.abort(result)
      when ParseResult       then parsed.value << result.value
      end
    end
    parsed
  end
end