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.



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

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

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



337
338
339
# File 'lib/kpeg/grammar.rb', line 337

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



347
348
349
350
351
352
353
354
# File 'lib/kpeg/grammar.rb', line 347

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

#inspectObject



356
357
358
# File 'lib/kpeg/grammar.rb', line 356

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

#match(x) ⇒ Object



339
340
341
342
343
344
345
# File 'lib/kpeg/grammar.rb', line 339

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

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