Class: Deadlyzer::AST::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/deadlyzer/ast_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser: nil) ⇒ Parser

Returns a new instance of Parser.



18
19
20
# File 'lib/deadlyzer/ast_parser.rb', line 18

def initialize(parser: nil)
  @parser = parser || default_parser
end

Instance Attribute Details

#astObject (readonly)

Since:

  • 0.1.0



13
14
15
# File 'lib/deadlyzer/ast_parser.rb', line 13

def ast
  @ast
end

#fileObject (readonly)

Since:

  • 0.1.0



16
17
18
# File 'lib/deadlyzer/ast_parser.rb', line 16

def file
  @file
end

#parserObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



10
11
12
# File 'lib/deadlyzer/ast_parser.rb', line 10

def parser
  @parser
end

Instance Method Details

#parse(code, file = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



24
25
26
27
28
29
# File 'lib/deadlyzer/ast_parser.rb', line 24

def parse(code, file = nil)
  processed_source = parse_code(code, file)
  @ast             = processed_source.ast
  @file            = processed_source.path
  self
end