Class: Packcr::Node::EofNode
- Inherits:
-
Packcr::Node
show all
- Defined in:
- lib/packcr/node/eof_node.rb,
lib/packcr/generated/node/eof_node.rb
Instance Method Summary
collapse
#alt, #link_references, #nodes, #reversible?, #seq, #sequence?, #setup, #setup_rule, #verify_captures, #verify_variables
Instance Method Details
#debug_dump(indent = 0) ⇒ Object
4
5
6
|
# File 'lib/packcr/node/eof_node.rb', line 4
def debug_dump(indent = 0)
$stdout.print "#{" " * indent}Eof()\n"
end
|
#generate_code(gen, onfail, indent, bare, oncut: nil) ⇒ Object
8
9
10
|
# File 'lib/packcr/node/eof_node.rb', line 8
def generate_code(gen, onfail, indent, bare, oncut: nil)
gen.write Packcr.format_code(get_code(gen, onfail, indent, bare, oncut), indent: indent, unwrap: bare)
end
|
#get_code(gen, onfail, indent, bare, oncut) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/packcr/generated/node/eof_node.rb', line 4
def get_code(gen, onfail, indent, bare, oncut)
case gen.lang
when :c
erbout = +""
erbout << "if (packcr_refill_buffer(ctx, 1) >= 1) goto L#{format("%04d", onfail)};\n".freeze
erbout
when :rb
erbout = +""
erbout << "if refill_buffer(1) >= 1\n throw(#{onfail})\nend\n".freeze
erbout
end
end
|
#reachability ⇒ Object
12
13
14
|
# File 'lib/packcr/node/eof_node.rb', line 12
def reachability
Packcr::CODE_REACH__BOTH
end
|
#to_h ⇒ Object
16
17
18
19
20
|
# File 'lib/packcr/node/eof_node.rb', line 16
def to_h
{
type: :eof,
}
end
|