Class: Language::Atom::Then

Inherits:
Language::Atom show all
Defined in:
lib/language/atom.rb

Instance Method Summary collapse

Methods inherited from Language::Atom

#<<, #>>, #absent, #aka, #any, #ignore, #inspect, #maybe, #repeat, #rule, #str, #then, #|

Constructor Details

#initialize(parent:, block:) ⇒ Then

Returns a new instance of Then.



28
29
30
31
# File 'lib/language/atom.rb', line 28

def initialize(parent:, block:)
  @parent = parent
  @block = block
end

Instance Method Details

#parse(parser) ⇒ Object



33
34
35
36
# File 'lib/language/atom.rb', line 33

def parse(parser)
  @parent.parse(parser)
  parser.output = Output.from_raw(@block.call(parser.output.to_raw))
end

#to_sObject



38
39
40
# File 'lib/language/atom.rb', line 38

def to_s
  "(#{@parent}).then {}"
end