Class: Furnace::AVM2::Tokens::ElseToken

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ElseToken.



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

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

Instance Method Details

#to_structure(options = {}) ⇒ Object



20
21
22
# File 'lib/furnace-avm2/source/implementation_tokens/else_token.rb', line 20

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

#to_textObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/furnace-avm2/source/implementation_tokens/else_token.rb', line 9

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