class RuboCop::AST::Builder
root_node = parser.parse(buffer)
parser = Parser::Ruby25.new(builder)
require ‘parser/ruby25’
builder = RuboCop::AST::Builder.new
buffer.source = ‘puts :foo’
buffer = Parser::Source::Buffer.new(‘(string)’)
@example
generate ASTs with {RuboCop::AST::Node}.
‘RuboCop::AST::Builder` is an AST builder that is utilized to let `Parser`
def n(type, children, source_map)
-
(Node)
- the generated node
def n(type, children, source_map) node_klass(type).new(type, children, location: source_map) end
def node_klass(type)
def node_klass(type) NODE_MAP[type] || Node end
def string_value(token)
TODO: Figure out what to do about literal encoding handling...
def string_value(token) value(token) end