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:
48 49 50 |
# File 'lib/parser/parse_tree.rb', line 48 def initialize(token) #:nodoc: @token = token end |
Instance Attribute Details
#token ⇒ Object (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_name ⇒ Object
:nodoc:
73 74 75 |
# File 'lib/parser/parse_tree.rb', line 73 def dot_name #:nodoc: "Node#{object_id}" end |
#head_node? ⇒ Boolean
:nodoc:
69 70 71 |
# File 'lib/parser/parse_tree.rb', line 69 def head_node? #:nodoc: false end |
#linearize ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/parser/parse_tree.rb', line 52 def linearize #:nodoc: [] end |
#to_dot ⇒ Object
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_s ⇒ Object
:nodoc:
60 61 62 |
# File 'lib/parser/parse_tree.rb', line 60 def to_s #:nodoc: "LeafNode: #{token}" end |
#tokens ⇒ Object
56 57 58 |
# File 'lib/parser/parse_tree.rb', line 56 def tokens [token] end |