Class: Walrus::Grammar::NotPredicate
- Defined in:
- lib/walrus/grammar/not_predicate.rb
Instance Attribute Summary
Attributes inherited from Predicate
Instance Method Summary collapse
Methods inherited from Predicate
#eql?, #initialize, #to_parseable
Methods included from Memoizing
#check_left_recursion, #memoizing_parse
Methods included from ParsletCombining
#&, #>>, #and?, #and_predicate, #choice, #memoizing_parse, #merge, #not!, #not_predicate, #omission, #one_or_more, #optional, #repeat, #repeat_with_default, #repetition, #repetition_with_default, #sequence, #skip, #zero_or_more, #zero_or_one, #|
Constructor Details
This class inherits a constructor from Walrus::Grammar::Predicate
Instance Method Details
#parse(string, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/walrus/grammar/not_predicate.rb', line 22 def parse(string, = {}) raise ArgumentError if string.nil? catch :ZeroWidthParseSuccess do begin @parseable.memoizing_parse(string, ) rescue ParseError # failed to pass (which is just what we wanted) throw :NotPredicateSuccess end end # getting this far means that parsing succeeded (not what we wanted) raise ParseError.new('predicate not satisfied ("%s" not allowed) while parsing "%s"' % [@parseable.to_s, string], :line_end => [:line_start], :column_end => [:column_start]) end |