Sha256: 8426ca7baf76ed7d45fc0f2270bd4967e4861dd96eec567c4cbd583f64f05204

Contents?: true

Size: 748 Bytes

Versions: 13

Compression:

Stored size: 748 Bytes

Contents

# coding: utf-8

require 'astrolabe/node'
require 'parser'

module Astrolabe
  # `Astrolabe::Builder` is an AST builder that is utilized to let `Parser` generate AST with
  # {Astrolabe::Node}.
  #
  # @example
  #   require 'astrolabe/builder'
  #   require 'parser/current'
  #
  #   buffer = Parser::Source::Buffer.new('(string)')
  #   buffer.source = 'puts :foo'
  #
  #   builder = Astrolabe::Builder.new
  #   parser = Parser::CurrentRuby.new(builder)
  #   root_node = parser.parse(buffer)
  class Builder < Parser::Builders::Default
    # Generates {Node} from the given information.
    #
    # @return [Node] the generated node
    def n(type, children, source_map)
      Node.new(type, children, location: source_map)
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/astrolabe-1.3.0/lib/astrolabe/builder.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/astrolabe-1.3.0/lib/astrolabe/builder.rb
astrolabe-1.3.1 lib/astrolabe/builder.rb
astrolabe-1.3.0 lib/astrolabe/builder.rb
astrolabe-1.2.1 lib/astrolabe/builder.rb
astrolabe-1.1.0 lib/astrolabe/builder.rb
astrolabe-1.0.0 lib/astrolabe/builder.rb
astrolabe-0.6.0 lib/astrolabe/builder.rb
astrolabe-0.5.2 lib/astrolabe/builder.rb
astrolabe-0.5.1 lib/astrolabe/builder.rb
astrolabe-0.5.0 lib/astrolabe/builder.rb
astrolabe-0.4.0 lib/astrolabe/builder.rb
astrolabe-0.3.0 lib/astrolabe/builder.rb