Class: SyntaxTree::Bf::Format
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Visitor
#visit, #visit_all, #visit_child_nodes
Constructor Details
#initialize(q) ⇒ Format
Returns a new instance of Format.
8
9
10
|
# File 'lib/syntax_tree/bf/format.rb', line 8
def initialize(q)
@q = q
end
|
Instance Attribute Details
#q ⇒ Object
Returns the value of attribute q.
6
7
8
|
# File 'lib/syntax_tree/bf/format.rb', line 6
def q
@q
end
|
Instance Method Details
#visit_decrement(node) ⇒ Object
33
34
35
|
# File 'lib/syntax_tree/bf/format.rb', line 33
def visit_decrement(node)
q.text("-")
end
|
#visit_increment(node) ⇒ Object
29
30
31
|
# File 'lib/syntax_tree/bf/format.rb', line 29
def visit_increment(node)
q.text("+")
end
|
45
46
47
|
# File 'lib/syntax_tree/bf/format.rb', line 45
def visit_input(node)
q.text(",")
end
|
#visit_loop(node) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/syntax_tree/bf/format.rb', line 17
def visit_loop(node)
q.group do
q.text("[")
q.nest(2) do
q.breakable("")
super
end
q.breakable("")
q.text("]")
end
end
|
#visit_output(node) ⇒ Object
49
50
51
|
# File 'lib/syntax_tree/bf/format.rb', line 49
def visit_output(node)
q.text(".")
end
|
#visit_root(node) ⇒ Object
12
13
14
15
|
# File 'lib/syntax_tree/bf/format.rb', line 12
def visit_root(node)
super
q.breakable(force: true)
end
|
#visit_shift_left(node) ⇒ Object
41
42
43
|
# File 'lib/syntax_tree/bf/format.rb', line 41
def visit_shift_left(node)
q.text("<")
end
|
#visit_shift_right(node) ⇒ Object
37
38
39
|
# File 'lib/syntax_tree/bf/format.rb', line 37
def visit_shift_right(node)
q.text(">")
end
|