class Maps::Parser

Public Class Methods

format_error(input, offset, expected) click to toggle source
# File lib/rookout/processor/paths/canopy/maps.rb, line 2819
def self.format_error(input, offset, expected)
  lines, line_no, position = input.split(/\n/), 0, 0
  while position <= offset
    position += lines[line_no].size + 1
    line_no += 1
  end
  message, line = "Line #{line_no}: expected #{expected * ", "}\n", lines[line_no - 1]
  message += "#{line}\n"
  position -= line.size + 1
  message += " " * (offset - position)
  return message + "^"
end
new(input, actions, types) click to toggle source
# File lib/rookout/processor/paths/canopy/maps.rb, line 2796
def initialize(input, actions, types)
  @input = input
  @input_size = input.size
  @actions = actions
  @types = types
  @offset = 0
  @cache = Hash.new { |h,k| h[k] = {} }
  @failure = 0
  @expected = []
end

Public Instance Methods

parse() click to toggle source
# File lib/rookout/processor/paths/canopy/maps.rb, line 2807
def parse
  tree = _read_comp_expression
  if tree != FAILURE and @offset == @input_size
    return tree
  end
  if @expected.empty?
    @failure = @offset
    @expected << "<EOF>"
  end
  raise ParseError, Parser.format_error(@input, @failure, @expected)
end