Sha256: 33b01d5a7d887664f332b8315d013500e1553a46b74674f4706b25d20f21542d

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

# infix visitor
#
# use this visitor in a processor to get infix visiting order
#
#  visitor     node     deps
#    accept ->   visit left ->
#                process
#                visit right ->
module Dentaku
  module Visitor
    module Infix
      def visit(ast)
        ast.accept(self)
      end

      def process(_ast)
        raise NotImplementedError
      end

      def visit_function(node)
        node.args.each do |arg|
          visit(arg)
        end
        process(node)
      end

      def visit_identifier(node)
        process(node)
      end

      def visit_operation(node)
        visit(node.left) if node.left
        process(node)
        visit(node.right) if node.right
      end

      def visit_operand(node)
        process(node)
      end

      def visit_case(node)
        process(node)
      end

      def visit_switch(node)
        process(node)
        end

      def visit_case_conditional(node)
        process(node)
      end

      def visit_when(node)
        process(node)
      end

      def visit_then(node)
        process(node)
      end

      def visit_else(node)
        process(node)
      end

      def visit_negation(node)
        process(node)
      end

      def visit_access(node)
        process(node)
      end

      def visit_literal(node)
        process(node)
      end

      def visit_nil(node)
        process(node)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
dentaku_zevo-3.5.2 lib/dentaku/visitor/infix.rb
dentaku-3.5.1 lib/dentaku/visitor/infix.rb
dentaku-3.5.0 lib/dentaku/visitor/infix.rb