Class: TDParser::BackrefParser

Inherits:
ReferenceParser show all
Defined in:
lib/tdp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReferenceParser

#__backref__, #same?

Methods inherited from Parser

#%, #*, #+, #-, #/, #>, #>>, #do, #optimize, #parse, #peek, #same?, #to_proc, #|, #~@

Methods included from TDParser

#any_rule, #backref, #chainl, #chainr, #condition_rule, define, #empty_rule, #fail_rule, #leftrec, #none_rule, #rightrec, #rule, #stackref, #state, #token

Methods included from BufferUtils

#prepare, #recover

Constructor Details

#initialize(label, eqsym) ⇒ BackrefParser

Returns a new instance of BackrefParser.



690
691
692
693
# File 'lib/tdp.rb', line 690

def initialize(label, eqsym)
  @label = label
  @equality  = eqsym
end

Instance Attribute Details

#equalityObject (readonly)

Returns the value of attribute equality.



688
689
690
# File 'lib/tdp.rb', line 688

def equality
  @equality
end

#labelObject (readonly)

Returns the value of attribute label.



688
689
690
# File 'lib/tdp.rb', line 688

def label
  @label
end

Instance Method Details

#==(r) ⇒ Object



708
709
710
711
712
# File 'lib/tdp.rb', line 708

def ==(r)
  super(r) &&
  (@label == r.label) &&
  (@equality == r.equality)
end

#call(tokens, buff) ⇒ Object



695
696
697
698
699
700
701
702
# File 'lib/tdp.rb', line 695

def call(tokens, buff)
  ys = buff.map[@label]
  if (ys.nil? || ys.empty?)
    nil
  else
    __backref__(ys.dup(), @equality).call(tokens,buff)
  end
end

#to_sObject



704
705
706
# File 'lib/tdp.rb', line 704

def to_s()
  "<backref:#{@label}>"
end