Class: Packcr::Node::CharclassNode
Instance Attribute Summary collapse
Instance Method Summary
collapse
#alt, #link_references, #nodes, #seq, #sequence?, #setup, #setup_rule, #verify_captures, #verify_variables
Constructor Details
#initialize(value = nil) ⇒ CharclassNode
Returns a new instance of CharclassNode.
6
7
8
|
# File 'lib/packcr/node/charclass_node.rb', line 6
def initialize(value = nil)
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
4
5
6
|
# File 'lib/packcr/node/charclass_node.rb', line 4
def value
@value
end
|
Instance Method Details
#debug_dump(indent = 0) ⇒ Object
10
11
12
13
14
|
# File 'lib/packcr/node/charclass_node.rb', line 10
def debug_dump(indent = 0)
$stdout.print "#{" " * indent}Charclass(value:'"
Packcr.dump_escaped_string(value)
$stdout.print "')\n"
end
|
#generate_code(gen, onfail, indent, bare, oncut: nil) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/packcr/node/charclass_node.rb', line 20
def generate_code(gen, onfail, indent, bare, oncut: nil)
if gen.ascii
return generate_ascii_code(gen, onfail, indent, bare)
else
return generate_utf8_charclass_code(gen, onfail, indent, bare)
end
end
|
#generate_reverse_code(gen, onsuccess, indent, bare, oncut: nil) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/packcr/node/charclass_node.rb', line 28
def generate_reverse_code(gen, onsuccess, indent, bare, oncut: nil)
if gen.ascii
raise "unexpected"
else
return generate_utf8_charclass_reverse_code(gen, onsuccess, indent, bare)
end
end
|
#reachability ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/packcr/node/charclass_node.rb', line 36
def reachability
charclass = self.value
n = charclass&.length || 0
if charclass.nil? || n > 0
return Packcr::CODE_REACH__BOTH
else
return Packcr::CODE_REACH__ALWAYS_FAIL
end
end
|
#reversible?(gen) ⇒ Boolean
16
17
18
|
# File 'lib/packcr/node/charclass_node.rb', line 16
def reversible?(gen)
gen.lang == :rb && !gen.ascii
end
|