Class: Peggy::Negative

Inherits:
Positive show all
Defined in:
lib/builder.rb,
lib/Copy of builder.rb

Overview

An element which tries its single child but does not advance the index if not found. If found, however, it returns NO_MATCH. Used for a negative semantic predicate.

Instance Attribute Summary

Attributes inherited from Positive

#child

Instance Method Summary collapse

Methods inherited from Element

build, #report

Instance Method Details

#match(parser, index) ⇒ Object



151
152
153
154
155
# File 'lib/builder.rb', line 151

def match parser, index
  raise "negative element child not set" unless child
  found = child.match parser, index
  found ? NO_MATCH : index
end