Class: TDParser::StackrefParser
- Inherits:
-
ReferenceParser
- Object
- Parser
- ReferenceParser
- TDParser::StackrefParser
- Defined in:
- lib/tdp.rb
Instance Attribute Summary collapse
-
#equality ⇒ Object
readonly
Returns the value of attribute equality.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(stack, eqsym) ⇒ StackrefParser
constructor
A new instance of StackrefParser.
- #to_s ⇒ Object
Methods inherited from ReferenceParser
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
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
#equality ⇒ Object (readonly)
Returns the value of attribute equality.
716 717 718 |
# File 'lib/tdp.rb', line 716 def equality @equality end |
#stack ⇒ Object (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_s ⇒ Object
732 733 734 |
# File 'lib/tdp.rb', line 732 def to_s() "<stackref:#{@stack.object_id}>" end |