Class: Packcr::Node::ExpandNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colObject

Returns the value of attribute col.



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

def col
  @col
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#lineObject

Returns the value of attribute line.



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

def line
  @line
end

Instance Method Details

#debug_dump(indent = 0) ⇒ Object



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

def debug_dump(indent = 0)
  $stdout.print "#{" " * indent}Expand(index:"
  Packcr.dump_integer_value(index)
  $stdout.print ")\n"
end

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



12
13
14
15
# File 'lib/packcr/node/expand_node.rb', line 12

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


32
33
# File 'lib/packcr/node/expand_node.rb', line 32

def link_references(ctx)
end

#verify_captures(ctx, capts) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/packcr/node/expand_node.rb', line 20

def verify_captures(ctx, capts)
  found = capts.any? do |capt|
    unless capt.is_a?(Packcr::Node::CaptureNode)
      raise "unexpected capture: #{capt.class}"
    end
    index == capt.index
  end
  if !found && index != nil
    ctx.error line + 1, col + 1, "Capture #{index + 1} not available at this position"
  end
end

#verify_variables(vars) ⇒ Object



17
18
# File 'lib/packcr/node/expand_node.rb', line 17

def verify_variables(vars)
end