Class: Analyst::Parser

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/analyst/parser.rb

Constant Summary collapse

PROCESSORS =

TODO: Empty -> Unhandled (or something like that)

Hash.new(Entities::Empty).merge!(
  :root => Entities::Root,
  :class => Entities::Class,
  :def => Entities::InstanceMethod,
  :defs => Entities::SingletonMethod,
  :begin => Entities::Begin,
  :module => Entities::Module,
  :send => Entities::MethodCall,
  :sclass => Entities::SingletonClass,
  :dstr => Entities::InterpolatedString
# :def => :method_node_parser,
# :send => :send_node_parser
# TODO: make a method parser, which pushes the the context_stack so that things inside method bodies
# are treated differently than those inside class or module bodies.  same with Block (right?)
)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast) ⇒ Parser

Returns a new instance of Parser.



36
37
38
# File 'lib/analyst/parser.rb', line 36

def initialize(ast)
  @ast = ast
end

Instance Attribute Details

#start_pathObject (readonly)

Returns the value of attribute start_path.



10
11
12
# File 'lib/analyst/parser.rb', line 10

def start_path
  @start_path
end

Class Method Details

.process_node(node, parent) ⇒ Object



31
32
33
34
# File 'lib/analyst/parser.rb', line 31

def self.process_node(node, parent)
  return if node.nil? # TODO: maybe a Entities:Nil would be appropriate? maybe?
  PROCESSORS[node.type].new(node, parent)
end

Instance Method Details

#inspectObject



40
41
42
# File 'lib/analyst/parser.rb', line 40

def inspect
  "\#<#{self.class}:#{object_id}>"
end