module Rubasteme::AST

Public Class Methods

instantiate(ast_node_type, literal = nil) click to toggle source
# File lib/rubasteme/ast.rb, line 62
def self.instantiate(ast_node_type, literal = nil)
  type_name = Utils.camel_case(ast_node_type.to_s.delete_prefix("ast_"))
  klass = AST.const_get("#{type_name}Node")

  if klass.nil? or klass == IllegalNode
    IllegalNode.new(ast_node_type, literal)
  else
    klass.new(literal)
  end
end