Class: Packcr::Node::RuleNode

Inherits:
Packcr::Node show all
Defined in:
lib/packcr/node/rule_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRuleNode

Returns a new instance of RuleNode.



6
7
8
9
10
11
12
# File 'lib/packcr/node/rule_node.rb', line 6

def initialize
  super
  self.ref = 0
  self.vars = []
  self.capts = []
  self.codes = []
end

Instance Attribute Details

#captsObject

Returns the value of attribute capts.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def capts
  @capts
end

#codesObject

Returns the value of attribute codes.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def codes
  @codes
end

#colObject

Returns the value of attribute col.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def col
  @col
end

#exprObject

Returns the value of attribute expr.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def expr
  @expr
end

#lineObject

Returns the value of attribute line.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def line
  @line
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def name
  @name
end

#refObject

Returns the value of attribute ref.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def ref
  @ref
end

#varsObject

Returns the value of attribute vars.



4
5
6
# File 'lib/packcr/node/rule_node.rb', line 4

def vars
  @vars
end

Instance Method Details

#add_refObject



25
26
27
# File 'lib/packcr/node/rule_node.rb', line 25

def add_ref
  @ref += 1
end

#debug_dump(indent = 0) ⇒ Object



14
15
16
17
18
# File 'lib/packcr/node/rule_node.rb', line 14

def debug_dump(indent = 0)
  $stdout.print "#{" " * indent}Rule(name:'#{name}', ref:#{ref}, vars.len:#{vars.length}, capts.len:#{capts.length}, codes.len:#{codes.length}) {\n"
  expr.debug_dump(indent + 2)
  $stdout.print "#{" " * indent}}\n"
end

#verify(ctx) ⇒ Object



20
21
22
23
# File 'lib/packcr/node/rule_node.rb', line 20

def verify(ctx)
  expr.verify_variables([])
  expr.verify_captures(ctx, [])
end