Class: Furnace::AVM2::Tokens::ControlFlowToken

Inherits:
Code::NonterminalToken
  • Object
show all
Defined in:
lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(origin, condition, body, options = {}) ⇒ ControlFlowToken

Returns a new instance of ControlFlowToken.



4
5
6
7
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 4

def initialize(origin, condition, body, options={})
  super(origin, [condition, body], options)
  @condition, @body = condition, body
end

Instance Method Details

#keywordObject



9
10
11
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 9

def keyword
  raise "reimplement ControlFlowToken#keyword in a subclass"
end

#to_structure(options = {}) ⇒ Object



22
23
24
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 22

def to_structure(options={})
  structurize "#{keyword}(...) ...", options
end

#to_textObject



13
14
15
16
17
18
19
20
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 13

def to_text
  header = "#{keyword}(#{@condition.to_text})"
  if @body.is_a? ScopeToken
    "#{header} #{@body.to_text}"
  else
    "#{header}\n#{indent @body.to_text}"
  end
end