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

Methods inherited from Packcr::Node

#alt, #seq, #setup_rule

Constructor Details

#initialize(expr = nil, name = nil, line = nil, col = nil) ⇒ RuleNode

Returns a new instance of RuleNode.



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

def initialize(expr = nil, name = nil, line = nil, col = nil)
  super()
  self.ref = 0
  self.vars = []
  self.capts = []
  self.codes = []
  @expr = expr
  @name = name
  @line = line
  @col = col
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



29
30
31
# File 'lib/packcr/node/rule_node.rb', line 29

def add_ref
  @ref += 1
end

#debug_dump(indent = 0) ⇒ Object



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

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

#nodesObject



37
38
39
# File 'lib/packcr/node/rule_node.rb', line 37

def nodes
  [expr]
end

#setupObject



33
34
35
# File 'lib/packcr/node/rule_node.rb', line 33

def setup
  setup_rule(self)
end

#verify(ctx) ⇒ Object



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

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