Class: Dhaka::ParseTreeLeafNode
- Inherits:
-
Object
- Object
- Dhaka::ParseTreeLeafNode
- Defined in:
- lib/parser/parse_tree.rb
Overview
These are leaf nodes of syntax trees. They contain tokens.
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#dot_name ⇒ Object
:nodoc:.
-
#head_node? ⇒ Boolean
:nodoc:.
-
#initialize(token) ⇒ ParseTreeLeafNode
constructor
:nodoc:.
-
#linearize ⇒ Object
:nodoc:.
-
#to_dot ⇒ Object
Returns the dot representation of this node.
-
#to_s ⇒ Object
:nodoc:.
- #tokens ⇒ Object
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
#token ⇒ Object (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_name ⇒ Object
:nodoc:
66 67 68 |
# File 'lib/parser/parse_tree.rb', line 66 def dot_name #:nodoc: "Node#{object_id}" end |
#head_node? ⇒ Boolean
:nodoc:
62 63 64 |
# File 'lib/parser/parse_tree.rb', line 62 def head_node? #:nodoc: false end |
#linearize ⇒ Object
:nodoc:
48 49 50 |
# File 'lib/parser/parse_tree.rb', line 48 def linearize #:nodoc: [] end |
#to_dot ⇒ Object
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_s ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/parser/parse_tree.rb', line 54 def to_s #:nodoc: "LeafNode: #{token}" end |
#tokens ⇒ Object
51 52 53 |
# File 'lib/parser/parse_tree.rb', line 51 def tokens [token] end |