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.



359
360
361
362
# File 'lib/kpeg/grammar.rb', line 359

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

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



364
365
366
# File 'lib/kpeg/grammar.rb', line 364

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



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

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

#inspectObject



383
384
385
# File 'lib/kpeg/grammar.rb', line 383

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

#match(x) ⇒ Object



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

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

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