Exception: PETOOH::YY_SyntaxExpectationError

Inherits:
YY_SyntaxError show all
Defined in:
gen/lib/petooh.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from YY_SyntaxError

#pos

Instance Method Summary collapse

Constructor Details

#initialize(*expectations, pos) ⇒ YY_SyntaxExpectationError

expectations are String-s.



297
298
299
300
# File 'gen/lib/petooh.rb', line 297

def initialize(*expectations, pos)
  super(nil, pos)
  @expectations = expectations
end

Instance Method Details

#messageObject



314
315
316
317
318
319
320
321
# File 'gen/lib/petooh.rb', line 314

def message
  expectations = self.expectations.uniq
  (
    if expectations.size == 1 then expectations.first
    else [expectations[0...-1].join(", "), expectations[-1]].join(" or ")
    end
  ) + " is expected"
end

#or(other) ⇒ Object

returns other YY_SyntaxExpectationError with #expectations combined.

other is another YY_SyntaxExpectationError.

#pos of this YY_SyntaxExpectationError and other must be equal.



309
310
311
312
# File 'gen/lib/petooh.rb', line 309

def or other
  raise %(can not "or" #{YY_SyntaxExpectationError}s with different pos) unless self.pos == other.pos
  YY_SyntaxExpectationError.new(*(self.expectations + other.expectations), pos)
end