Class: Antlr4::Runtime::TerminalNodeImpl

Inherits:
TerminalNode show all
Defined in:
lib/antlr4/runtime/terminal_node_impl.rb

Direct Known Subclasses

ErrorNodeImpl

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ TerminalNodeImpl

Returns a new instance of TerminalNodeImpl



9
10
11
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 9

def initialize(symbol)
  @symbol = symbol
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent



7
8
9
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 7

def parent
  @parent
end

#symbolObject

Returns the value of attribute symbol



6
7
8
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 6

def symbol
  @symbol
end

Instance Method Details

#accept(visitor) ⇒ Object



32
33
34
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 32

def accept(visitor)
  visitor.visit_terminal(self)
end

#child(_i) ⇒ Object



13
14
15
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 13

def child(_i)
  nil
end

#child_countObject



28
29
30
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 28

def child_count
  0
end

#payloadObject



17
18
19
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 17

def payload
  @symbol
end

#source_intervalObject



21
22
23
24
25
26
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 21

def source_interval
  return Interval.invalid if @symbol.nil?

  token_index = @symbol.token_index
  Interval.new(token_index, token_index)
end

#textObject



36
37
38
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 36

def text
  @symbol.text
end

#to_sObject



44
45
46
47
48
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 44

def to_s
  return '<EOF>' if @symbol.type == Token::EOF

  @symbol.text
end

#to_string_tree(_parser = nil) ⇒ Object



40
41
42
# File 'lib/antlr4/runtime/terminal_node_impl.rb', line 40

def to_string_tree(_parser = nil)
  to_s
end