Class: NodeClass
Instance Attribute Summary collapse
-
#source_text ⇒ Object
The ‘text_value’ method can be used to read the parse tree as Treetop originally read it.
Instance Method Summary
collapse
#count, #find, #flatten, #inject, #select
Instance Attribute Details
#source_text ⇒ Object
The ‘text_value’ method can be used to read the parse tree as Treetop originally read it. The ‘source_text’ method returns redefined value or falls back to original text_value if none was set.
10
11
12
|
# File 'lib/piggly/parser/nodes.rb', line 10
def source_text
@source_text
end
|
Instance Method Details
#assignment? ⇒ Boolean
55
|
# File 'lib/piggly/parser/nodes.rb', line 55
def assignment?; false end
|
#block? ⇒ Boolean
43
|
# File 'lib/piggly/parser/nodes.rb', line 43
def block?; false end
|
#branch? ⇒ Boolean
42
|
# File 'lib/piggly/parser/nodes.rb', line 42
def branch?; false end
|
49
|
# File 'lib/piggly/parser/nodes.rb', line 49
def ; false end
|
#datatype? ⇒ Boolean
53
|
# File 'lib/piggly/parser/nodes.rb', line 53
def datatype?; false end
|
#else? ⇒ Boolean
59
|
# File 'lib/piggly/parser/nodes.rb', line 59
def else?; false; end
|
#expression? ⇒ Boolean
41
|
# File 'lib/piggly/parser/nodes.rb', line 41
def expression?; false end
|
#for? ⇒ Boolean
46
|
# File 'lib/piggly/parser/nodes.rb', line 46
def for?; false end
|
#identifier? ⇒ Boolean
54
|
# File 'lib/piggly/parser/nodes.rb', line 54
def identifier?; false end
|
#if? ⇒ Boolean
58
|
# File 'lib/piggly/parser/nodes.rb', line 58
def if?; false; end
|
#indent(method = nil) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/piggly/parser/nodes.rb', line 63
def indent(method = nil)
if method and respond_to?(method)
send(method).text_value[/\n[\t ]*\z/]
else
text_value[/\n[\t ]*\z/]
end || ""
end
|
#keyword? ⇒ Boolean
61
|
# File 'lib/piggly/parser/nodes.rb', line 61
def keyword?; false; end
|
#label? ⇒ Boolean
60
|
# File 'lib/piggly/parser/nodes.rb', line 60
def label?; false; end
|
#loop? ⇒ Boolean
45
|
# File 'lib/piggly/parser/nodes.rb', line 45
def loop?; false end
|
#named?(label) ⇒ Boolean
True if node is called label by the parent node
72
73
74
75
76
|
# File 'lib/piggly/parser/nodes.rb', line 72
def named?(label)
if p = parent
p.respond_to?(label) and p.send(label).equal?(self)
end
end
|
#sql? ⇒ Boolean
56
|
# File 'lib/piggly/parser/nodes.rb', line 56
def sql?; false end
|
#statement? ⇒ Boolean
57
|
# File 'lib/piggly/parser/nodes.rb', line 57
def statement?; false; end
|
#string? ⇒ Boolean
52
|
# File 'lib/piggly/parser/nodes.rb', line 52
def string?; false end
|
#stub? ⇒ Boolean
44
|
# File 'lib/piggly/parser/nodes.rb', line 44
def stub?; false end
|
48
|
# File 'lib/piggly/parser/nodes.rb', line 48
def style; nil end
|
#tag(prefix = nil, id = nil) ⇒ Object
Return a newly created Tag value, but only the tag.id is attached to the tree. The reason that is we maintain the Tags in a separate collection (to avoid a full traversal just to get the list of tags later), and we can retrieve the Tag associated with this node by its tag_id.
22
23
24
25
26
27
28
29
30
|
# File 'lib/piggly/parser/nodes.rb', line 22
def tag(prefix = nil, id = nil)
unless defined? @tag_id
if named?(:body)
Piggly::Tags::BlockTag.new(prefix, id)
else
Piggly::Tags::EvaluationTag.new(prefix, id)
end.tap{|tag| @tag_id = tag.id }
end
end
|
32
33
34
|
# File 'lib/piggly/parser/nodes.rb', line 32
def tag_id
@tag_id or raise RuntimeError, "Node is not tagged"
end
|
#tagged? ⇒ Boolean
36
37
38
|
# File 'lib/piggly/parser/nodes.rb', line 36
def tagged?
defined? @tag_id
end
|
#token? ⇒ Boolean
51
|
# File 'lib/piggly/parser/nodes.rb', line 51
def token?; false end
|
#while? ⇒ Boolean
47
|
# File 'lib/piggly/parser/nodes.rb', line 47
def while?; false end
|
#whitespace? ⇒ Boolean
50
|
# File 'lib/piggly/parser/nodes.rb', line 50
def whitespace?; false end
|