class KPeg::ForeignInvokeRule

Attributes

arguments[R]
grammar_name[R]
rule_name[R]

Public Class Methods

new(grammar, name, args=nil) click to toggle source
Calls superclass method KPeg::Operator::new
# File lib/kpeg/grammar.rb, line 466
def initialize(grammar, name, args=nil)
  super()
  @grammar_name = grammar
  @rule_name = name
  if !args or args.empty?
    @arguments = nil
  else
    @arguments = args
  end
end

Public Instance Methods

==(obj) click to toggle source
Calls superclass method
# File lib/kpeg/grammar.rb, line 485
def ==(obj)
  case obj
  when ForeignInvokeRule
    @grammar_name == obj.grammar_name and \
      @rule_name == obj.rule_name and @arguments == obj.arguments
  else
    super
  end
end
inspect() click to toggle source
# File lib/kpeg/grammar.rb, line 495
def inspect
  if @arguments
    body = "%#{@grammar}.#{@rule_name} #{@arguments}"
  else
    body = "%#{@grammar}.#{@rule_name}"
  end
  inspect_type "invoke", body
end
match(x) click to toggle source
# File lib/kpeg/grammar.rb, line 479
def match(x)
  rule = x.grammar.find(@rule_name)
  raise "Unknown rule: '#{@rule_name}'" unless rule
  x.invoke rule
end