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

- (NotPredicate) initialize(op)

A new instance of NotPredicate



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

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

Instance Attribute Details

- (Object) op (readonly)

Returns the value of attribute op



367
368
369
# File 'lib/kpeg/grammar.rb', line 367

def op
  @op
end

Instance Method Details

- (Object) ==(obj)



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

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

- (Object) inspect



386
387
388
# File 'lib/kpeg/grammar.rb', line 386

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

- (Object) match(x)



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

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

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