Class: Dhaka::ParseTreeLeafNode

Inherits:
Object
  • Object
show all
Defined in:
lib/dhaka/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:



41
42
43
# File 'lib/dhaka/parser/parse_tree.rb', line 41

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



39
40
41
# File 'lib/dhaka/parser/parse_tree.rb', line 39

def token
  @token
end

Instance Method Details

#head_node?Boolean

:nodoc:

Returns:

  • (Boolean)


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

def head_node? #:nodoc:
  false
end

#linearizeObject

:nodoc:



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

def linearize #:nodoc:
  []
end

#to_dot(graph) ⇒ Object

Returns the dot representation of this node.



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

def to_dot(graph)
  graph.node(self, :label => token)
end

#to_sObject

:nodoc:



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

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

#tokensObject



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

def tokens
  [token]
end