Class: Packcr::Node::StringNode
Instance Attribute Summary collapse
Instance Method Summary
collapse
#alt, #nodes, #seq, #setup_rule
Constructor Details
#initialize(value = nil) ⇒ StringNode
Returns a new instance of StringNode.
6
7
8
|
# File 'lib/packcr/node/string_node.rb', line 6
def initialize(value = nil)
self.value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
4
5
6
|
# File 'lib/packcr/node/string_node.rb', line 4
def value
@value
end
|
Instance Method Details
#debug_dump(indent = 0) ⇒ Object
14
15
16
17
18
|
# File 'lib/packcr/node/string_node.rb', line 14
def debug_dump(indent = 0)
$stdout.print "#{" " * indent}String(value:'"
Packcr.dump_escaped_string(value)
$stdout.print "')\n"
end
|
#generate_code(gen, onfail, indent, bare) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/packcr/node/string_node.rb', line 20
def generate_code(gen, onfail, indent, bare)
n = value&.length || 0
if n > 0
if n > 1
gen.write Packcr.template("node/string_many.#{gen.lang}.erb", binding, indent: indent)
return Packcr::CODE_REACH__BOTH
else
gen.write Packcr.template("node/string_one.#{gen.lang}.erb", binding, indent: indent)
return Packcr::CODE_REACH__BOTH
end
else
return Packcr::CODE_REACH__ALWAYS_SUCCEED
end
Packcr::CODE_REACH__BOTH
end
|
#link_references(ctx) ⇒ Object
43
44
|
# File 'lib/packcr/node/string_node.rb', line 43
def link_references(ctx)
end
|
#verify_captures(ctx, capts) ⇒ Object
40
41
|
# File 'lib/packcr/node/string_node.rb', line 40
def verify_captures(ctx, capts)
end
|
#verify_variables(vars) ⇒ Object
37
38
|
# File 'lib/packcr/node/string_node.rb', line 37
def verify_variables(vars)
end
|