Class: KPeg::NotPredicate

Inherits:
Operator show all
Defined in:
lib/kpeg/grammar.rb

Instance Attribute Summary collapse

Attributes inherited from Operator

#action

Instance Method Summary collapse

Methods inherited from Operator

#detect_tags, #inspect_type, #prune_values, #set_action, #|

Constructor Details

#initialize(op) ⇒ NotPredicate

Returns a new instance of NotPredicate.



369
370
371
372
# File 'lib/kpeg/grammar.rb', line 369

def initialize(op)
  super()
  @op = op
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



374
375
376
# File 'lib/kpeg/grammar.rb', line 374

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



384
385
386
387
388
389
390
391
# File 'lib/kpeg/grammar.rb', line 384

def ==(obj)
  case obj
  when NotPredicate
    @op == obj.op
  else
    super
  end
end

#inspectObject



393
394
395
# File 'lib/kpeg/grammar.rb', line 393

def inspect
  inspect_type "notp", @op.inspect
end

#match(x) ⇒ Object



376
377
378
379
380
381
382
# File 'lib/kpeg/grammar.rb', line 376

def match(x)
  pos = x.pos
  m = @op.match(x)
  x.pos = pos

  return m ? nil : MatchString.new(self, "")
end