Exception: DataMetaParse::Err

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/dataMetaParse.rb

Overview

Parsing error, RuntimeError augmented with report feature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, parser) ⇒ Err

Constructor, constructs also the error message passed to the super.

Parameters:

  • source (String)

    the next have been parsed to get this error

  • parser (Object)

    Treetop compiled parser whichever class it is. It may be Treetop::Runtime::CompiledParser



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dataMetaParse.rb', line 25

def initialize(source, parser)
    @source, @parser = source, parser
    parser.failure_reason =~ /^(Expected .+) after/m
    reason = $1 || 'REASONLESS'
    # replace newlines with <EOL> to make them stand out
    super %Q<ERROR at index #{parser.index}
#{reason.gsub("\n", '<EOL>')}:
#{source.lines.to_a[parser.failure_line - 1]}
#{'~' * (parser.failure_column - 1)}^
>
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end