Exception: Walrus::Grammar::SkippedSubstringException

Inherits:
Exception
  • Object
show all
Includes:
LocationTracking
Defined in:
lib/walrus/grammar/skipped_substring_exception.rb

Overview

I don’t really like using Exceptions for non-error situations, but it seems that using throw/catch here would not be adequate (not possible to embed information in the thrown symbol).

Instance Attribute Summary

Attributes included from LocationTracking

#outer_end, #outer_source_text, #outer_start, #source_text

Instance Method Summary collapse

Methods included from LocationTracking

#column_end, #column_end=, #column_start, #column_start=, #end, #end=, #line_end, #line_end=, #line_start, #line_start=, #rightmost?, #start, #start=

Constructor Details

#initialize(substring, info = {}) ⇒ SkippedSubstringException

Returns a new instance of SkippedSubstringException.



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

def initialize(substring, info = {})
  super substring
  
  # TODO: this code is just like the code in ParseError. could save repeating it by setting up inheritance
  # but would need to pay careful attention to the ordering of my rescue blocks
  # and also change many instances of "kind_of" in my specs to "instance_of "
  # alternatively, could look at using a mix-in
  self.line_start     = info[:line_start]
  self.column_start   = info[:column_start]
  self.line_end       = info[:line_end]
  self.column_end     = info[:column_end]
end