Class: TDParser::LabelParser

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

Instance Attribute Summary collapse

Attributes inherited from CompositeParser

#parsers

Instance Method Summary collapse

Methods inherited from CompositeParser

#optimize, #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(parser, label) ⇒ LabelParser

Returns a new instance of LabelParser.



325
326
327
328
# File 'lib/tdp.rb', line 325

def initialize(parser, label)
  @label = label
  super(parser)
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



323
324
325
# File 'lib/tdp.rb', line 323

def label
  @label
end

Instance Method Details

#==(r) ⇒ Object



336
337
338
339
# File 'lib/tdp.rb', line 336

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

#call(tokens, buff) ⇒ Object



330
331
332
333
334
# File 'lib/tdp.rb', line 330

def call(tokens, buff)
  x = @parsers[0].call(tokens, buff)
  buff.map[@label] = x
  x
end

#to_sObject



341
342
343
# File 'lib/tdp.rb', line 341

def to_s()
  "(#{@parsers[0].to_s()}/#{@label})"
end