class DeepAlgo::IL::Parser

Constants

BASE_PATH

Public Class Methods

new(curr_backend) click to toggle source
# File lib/parser.rb, line 12
def initialize(curr_backend)
  @curr_backend = curr_backend
  Treetop.load(File.join(BASE_PATH, 'il_parser.treetop'))
  @parser = IlParser.new
end

Public Instance Methods

parse(input) click to toggle source
# File lib/parser.rb, line 18
def parse(input)
  data = input.gsub(/(?:#.+?#)/, '')
  tree = nil
  begin
    tree = @parser.parse(data)
  rescue StandardError
    DeepAlgo::IL.log.debug('Error when parsing the file')
    DeepAlgo::IL.log.debug(input.to_s)
  end
  DeepAlgo::IL.log.debug(@parser.failure_reason) if tree.nil?
  tree
end