class Hjson::AST::Node

Public Class Methods

[](type) click to toggle source
# File lib/hjson/ast/node.rb, line 7
def self.[](type)
  @names       ||= {}
  @names[type] ||= begin
    namespace  = name.split(/::/).slice(0..-2).join('::')
    const_name = parser_name(type, namespace)
    AST.const_get(const_name) if AST.const_defined?(const_name)
  end
end
parser_name(type, namespace) click to toggle source
# File lib/hjson/ast/node.rb, line 16
def self.parser_name(type, namespace)
  type.to_s.split(?_).map(&:capitalize).join
end

Public Instance Methods

node(type, *args, &block) click to toggle source
# File lib/hjson/ast/node.rb, line 26
def node(type, *args, &block)
  args.unshift(buffer)
  Node[type].new(*args).parse
end
with_whitespaces() { || ... } click to toggle source
# File lib/hjson/ast/node.rb, line 20
def with_whitespaces
  node(:whitespace)
  yield
  node(:whitespace)
end