Exception: Paco::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/paco/parse_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, expected) ⇒ ParseError

Returns a new instance of ParseError.

Parameters:



10
11
12
13
14
# File 'lib/paco/parse_error.rb', line 10

def initialize(ctx, expected)
  @ctx = ctx
  @pos = ctx.pos
  @expected = expected
end

Instance Attribute Details

#ctxObject (readonly)

Returns the value of attribute ctx.



7
8
9
# File 'lib/paco/parse_error.rb', line 7

def ctx
  @ctx
end

#expectedObject (readonly)

Returns the value of attribute expected.



7
8
9
# File 'lib/paco/parse_error.rb', line 7

def expected
  @expected
end

#posObject (readonly)

Returns the value of attribute pos.



7
8
9
# File 'lib/paco/parse_error.rb', line 7

def pos
  @pos
end

Instance Method Details

#callstackObject



16
17
18
# File 'lib/paco/parse_error.rb', line 16

def callstack
  ctx.callstack
end

#messageObject



20
21
22
23
24
25
26
27
28
# File 'lib/paco/parse_error.rb', line 20

def message
  index = ctx.index(pos)
  "    \\nParsing error\n    line \#{index.line}, column \#{index.column}:\n    unexpected \#{ctx.eof? ? \"end of file\" : ctx.input[pos].inspect}\n    expecting \#{expected}\n  MSG\nend\n"