Class: KPeg::AndPredicate

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) ⇒ AndPredicate

Returns a new instance of AndPredicate.



329
330
331
332
# File 'lib/kpeg/grammar.rb', line 329

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

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



334
335
336
# File 'lib/kpeg/grammar.rb', line 334

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



344
345
346
347
348
349
350
351
# File 'lib/kpeg/grammar.rb', line 344

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

#inspectObject



353
354
355
# File 'lib/kpeg/grammar.rb', line 353

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

#match(x) ⇒ Object



336
337
338
339
340
341
342
# File 'lib/kpeg/grammar.rb', line 336

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

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