Class: TDParser::StackParser
- Inherits:
-
CompositeParser
- Object
- Parser
- CompositeParser
- TDParser::StackParser
- Defined in:
- lib/tdp.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Attributes inherited from CompositeParser
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(parser, stack) ⇒ StackParser
constructor
A new instance of StackParser.
- #same?(r) ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from CompositeParser
Methods inherited from Parser
#%, #*, #+, #-, #/, #>, #>>, #do, #optimize, #parse, #peek, #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(parser, stack) ⇒ StackParser
Returns a new instance of StackParser.
348 349 350 351 |
# File 'lib/tdp.rb', line 348 def initialize(parser, stack) @stack = stack super(parser) end |
Instance Attribute Details
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
347 348 349 |
# File 'lib/tdp.rb', line 347 def stack @stack end |
Instance Method Details
#==(r) ⇒ Object
359 360 361 362 |
# File 'lib/tdp.rb', line 359 def ==(r) super(r) && (@stack == r.stack) end |
#call(tokens, buff) ⇒ Object
353 354 355 356 357 |
# File 'lib/tdp.rb', line 353 def call(tokens, buff) x = @parsers[0].call(tokens, buff) @stack.push(x) x end |
#same?(r) ⇒ Boolean
364 365 366 |
# File 'lib/tdp.rb', line 364 def same?(r) false end |
#to_s ⇒ Object
368 369 370 |
# File 'lib/tdp.rb', line 368 def to_s() "<stack:#{@stack.object_id}>" end |