Class: Packcr::Node::ActionNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActionNode

Returns a new instance of ActionNode.



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

def initialize
  super
  self.vars = []
  self.capts = []
end

Instance Attribute Details

#captsObject

Returns the value of attribute capts.



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

def capts
  @capts
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#varsObject

Returns the value of attribute vars.



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

def vars
  @vars
end

Instance Method Details

#debug_dump(indent = 0) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/packcr/node/action_node.rb', line 12

def debug_dump(indent = 0)
  $stdout.print "#{" " * indent}Action(index:"
  Packcr.dump_integer_value(index)
  $stdout.print ", code:{"
  Packcr.dump_escaped_string(code.text)
  $stdout.print "}, vars:"

  vars = self.vars
  capts = self.capts
  if vars.length + capts.length > 0
    $stdout.print "\n"
    vars.each do |ref|
      $stdout.print "#{" " * (indent + 2)}'#{ref.var}'\n"
    end
    capts.each do |capt|
      $stdout.print "#{" " * (indent + 2)}$#{capt.index + 1}\n"
    end
    $stdout.print "#{" " * indent})\n"
  else
    $stdout.print "none)\n"
  end
end

#generate_code(gen, onfail, indent, bare) ⇒ Object



35
36
37
38
# File 'lib/packcr/node/action_node.rb', line 35

def generate_code(gen, onfail, indent, bare)
  gen.write Packcr.template("node/action.#{gen.lang}.erb", binding, indent: indent, unwrap: bare)
  return Packcr::CODE_REACH__ALWAYS_SUCCEED
end


48
49
# File 'lib/packcr/node/action_node.rb', line 48

def link_references(ctx)
end

#verify_captures(ctx, capts) ⇒ Object



44
45
46
# File 'lib/packcr/node/action_node.rb', line 44

def verify_captures(ctx, capts)
  @capts = capts
end

#verify_variables(vars) ⇒ Object



40
41
42
# File 'lib/packcr/node/action_node.rb', line 40

def verify_variables(vars)
  @vars = vars
end