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:



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

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



44
45
46
# File 'lib/parser/parse_tree.rb', line 44

def token
  @token
end

Instance Method Details

#dot_nameObject

:nodoc:



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

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

#head_node?Boolean

:nodoc:

Returns:

  • (Boolean)


62
63
64
# File 'lib/parser/parse_tree.rb', line 62

def head_node? #:nodoc:
  false
end

#linearizeObject

:nodoc:



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

def linearize #:nodoc:
  []
end

#to_dotObject

Returns the dot representation of this node.



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

def to_dot
  label = "#{token}#{' : '+token.value.to_s if token.value}"
  "#{dot_name} [label=\"#{label}\"]"
end

#to_sObject

:nodoc:



54
55
56
# File 'lib/parser/parse_tree.rb', line 54

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

#tokensObject



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

def tokens
  [token]
end