Class: Astrolabe::Builder

Inherits:
Parser::Builders::Default
  • Object
show all
Defined in:
lib/astrolabe/builder.rb

Overview

Astrolabe::Builder is an AST builder that is utilized to let Parser generate AST with Node.

Examples:

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)

Instance Method Summary collapse

Instance Method Details

#n(type, children, source_map) ⇒ Node

Generates Node from the given information.

Returns:

  • (Node)

    the generated node


24
25
26
# File 'lib/astrolabe/builder.rb', line 24

def n(type, children, source_map)
  Node.new(type, children, location: source_map)
end