Class: TDParser::StackrefParser

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(stack, eqsym) ⇒ StackrefParser

Returns a new instance of StackrefParser.



718
719
720
721
# File 'lib/tdp.rb', line 718

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

Instance Attribute Details

#equalityObject (readonly)

Returns the value of attribute equality.



716
717
718
# File 'lib/tdp.rb', line 716

def equality
  @equality
end

#stackObject (readonly)

Returns the value of attribute stack.



716
717
718
# File 'lib/tdp.rb', line 716

def stack
  @stack
end

Instance Method Details

#==(r) ⇒ Object



736
737
738
739
740
# File 'lib/tdp.rb', line 736

def ==(r)
  super(r) &&
  (@stack.object_id == r.stack.object_id) &&
  (@equality == r.equality)
end

#call(tokens, buff) ⇒ Object



723
724
725
726
727
728
729
730
# File 'lib/tdp.rb', line 723

def call(tokens, buff)
  ys = @stack.pop()
  if (ys.nil? || ys.empty?)
    nil
  else
    __backref__(ys.dup(), @equality).call(tokens,buff)
  end
end

#to_sObject



732
733
734
# File 'lib/tdp.rb', line 732

def to_s()
  "<stackref:#{@stack.object_id}>"
end