class Atomy::Pattern::QuasiQuote::Walker
Public Class Methods
new()
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 31 def initialize @depth = 0 end
Public Instance Methods
go(x)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 35 def go(x) x.accept(self) end
push_literal(x)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 62 def push_literal(x) case x when Array x.each { |v| push_literal(v) } @gen.make_array(x.size) when String @gen.push_literal(x) @gen.string_dup else @gen.push_literal(x) end end
unquote(_)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 58 def unquote(_) raise NotImplementedError end
unsplat(pats)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 75 def unsplat(pats) if pats.last.is_a?(Atomy::Grammar::AST::Unquote) && \ pats.last.node.is_a?(Atomy::Pattern::Splat) [pats[0..-2], pats[-1]] else [pats, nil] end end
visit_quasiquote(qq)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 39 def visit_quasiquote(qq) @depth += 1 visit(qq) ensure @depth -= 1 end
visit_unquote(x)
click to toggle source
# File lib/atomy/pattern/quasi_quote.rb, line 46 def visit_unquote(x) @depth -= 1 if @depth == 0 unquote(x) else visit(x) end ensure @depth += 1 end