Class: Dhaka::ParseTreeLeafNode

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/parse_tree.rb

Overview

These are leaf nodes of syntax trees. They contain tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ ParseTreeLeafNode

:nodoc:



48
49
50
# File 'lib/parser/parse_tree.rb', line 48

def initialize(token) #:nodoc:
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



46
47
48
# File 'lib/parser/parse_tree.rb', line 46

def token
  @token
end

Instance Method Details

#dot_nameObject

:nodoc:



73
74
75
# File 'lib/parser/parse_tree.rb', line 73

def dot_name #:nodoc:
  "Node#{object_id}"
end

#head_node?Boolean

:nodoc:

Returns:

  • (Boolean)


69
70
71
# File 'lib/parser/parse_tree.rb', line 69

def head_node? #:nodoc:
  false
end

#linearizeObject

:nodoc:



52
53
54
# File 'lib/parser/parse_tree.rb', line 52

def linearize #:nodoc:
  []
end

#to_dotObject

Returns the dot representation of this node.



65
66
67
# File 'lib/parser/parse_tree.rb', line 65

def to_dot
  %(#{dot_name} [label="#{token.to_s}"])
end

#to_sObject

:nodoc:



60
61
62
# File 'lib/parser/parse_tree.rb', line 60

def to_s #:nodoc:
  "LeafNode: #{token}"
end

#tokensObject



56
57
58
# File 'lib/parser/parse_tree.rb', line 56

def tokens
  [token]
end