Exception: Minjs::Lex::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/minjs/lex/exceptions.rb

Overview

ParseError

Instance Method Summary collapse

Constructor Details

#initialize(error_message = nil, lex = nil) ⇒ ParseError

Returns a new instance of ParseError.



4
5
6
7
8
9
10
# File 'lib/minjs/lex/exceptions.rb', line 4

def initialize(error_message = nil, lex = nil)
  super(error_message)
  if lex
    @lex = lex
    @lex_pos = lex.pos
  end
end

Instance Method Details

#to_sObject

to string



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/minjs/lex/exceptions.rb', line 13

def to_s
  t = ''
  t << super
  t << "\n"
  if @lex
    row, col = @lex.row_col(@lex_pos)
    t << "row: #{row}, col: #{col}\n"
    t << @lex.debug_str(@lex_pos, row, col)
  end
  t
end