class KPeg::Tag

Attributes

op[R]
tag_name[R]

Public Class Methods

new(op, tag_name) click to toggle source
Calls superclass method KPeg::Operator::new
# File lib/kpeg/grammar.rb, line 506
def initialize(op, tag_name)
  super()
  if op.kind_of? Multiple
    op.save_values!
  end

  @op = op
  @tag_name = tag_name
end

Public Instance Methods

==(obj) click to toggle source
Calls superclass method
# File lib/kpeg/grammar.rb, line 524
def ==(obj)
  case obj
  when Tag
    @op == obj.op and @tag_name == obj.tag_name
  when Operator
    @op == obj
  else
    super
  end
end
inspect() click to toggle source
# File lib/kpeg/grammar.rb, line 535
def inspect
  if @tag_name
    body = "@#{tag_name} "
  else
    body = ""
  end

  body << @op.inspect

  inspect_type "tag", body
end
match(x) click to toggle source
# File lib/kpeg/grammar.rb, line 518
def match(x)
  if m = @op.match(x)
    MatchComposition.new(self, [m])
  end
end