Class: Packcr::Node::CaptureNode
- Inherits:
-
Packcr::Node
- Object
- Packcr::Node
- Packcr::Node::CaptureNode
- Defined in:
- lib/packcr/node/capture_node.rb
Instance Attribute Summary collapse
-
#expr ⇒ Object
Returns the value of attribute expr.
-
#index ⇒ Object
Returns the value of attribute index.
Instance Method Summary collapse
- #debug_dump(indent = 0) ⇒ Object
- #generate_code(gen, onfail, indent, bare) ⇒ Object
-
#initialize(expr = nil) ⇒ CaptureNode
constructor
A new instance of CaptureNode.
- #link_references(ctx) ⇒ Object
- #nodes ⇒ Object
- #setup_rule(rule) ⇒ Object
- #verify_captures(ctx, capts) ⇒ Object
- #verify_variables(vars) ⇒ Object
Methods inherited from Packcr::Node
Constructor Details
#initialize(expr = nil) ⇒ CaptureNode
6 7 8 |
# File 'lib/packcr/node/capture_node.rb', line 6 def initialize(expr = nil) @expr = expr end |
Instance Attribute Details
#expr ⇒ Object
Returns the value of attribute expr.
4 5 6 |
# File 'lib/packcr/node/capture_node.rb', line 4 def expr @expr end |
#index ⇒ Object
Returns the value of attribute index.
4 5 6 |
# File 'lib/packcr/node/capture_node.rb', line 4 def index @index end |
Instance Method Details
#debug_dump(indent = 0) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/packcr/node/capture_node.rb', line 10 def debug_dump(indent = 0) $stdout.print "#{" " * indent}Capture(index:" Packcr.dump_integer_value(index) $stdout.print ") {\n" expr.debug_dump(indent + 2) $stdout.print "#{" " * indent}}\n" end |
#generate_code(gen, onfail, indent, bare) ⇒ Object
18 19 20 21 22 |
# File 'lib/packcr/node/capture_node.rb', line 18 def generate_code(gen, onfail, indent, ) r = nil gen.write Packcr.template("node/capture.#{gen.lang}.erb", binding, indent: indent) return r end |
#link_references(ctx) ⇒ Object
33 34 35 |
# File 'lib/packcr/node/capture_node.rb', line 33 def link_references(ctx) expr.link_references(ctx) end |
#nodes ⇒ Object
37 38 39 |
# File 'lib/packcr/node/capture_node.rb', line 37 def nodes [expr] end |
#setup_rule(rule) ⇒ Object
41 42 43 44 45 |
# File 'lib/packcr/node/capture_node.rb', line 41 def setup_rule(rule) @index = rule.capts.length rule.capts << self super end |
#verify_captures(ctx, capts) ⇒ Object
28 29 30 31 |
# File 'lib/packcr/node/capture_node.rb', line 28 def verify_captures(ctx, capts) expr.verify_captures(ctx, capts) capts.push(self) end |
#verify_variables(vars) ⇒ Object
24 25 26 |
# File 'lib/packcr/node/capture_node.rb', line 24 def verify_variables(vars) expr.verify_variables(vars) end |