Class: TDParser::LabelParser
- Inherits:
-
CompositeParser
- Object
- Parser
- CompositeParser
- TDParser::LabelParser
- Defined in:
- lib/tdp.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Attributes inherited from CompositeParser
Instance Method Summary collapse
- #==(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(parser, label) ⇒ LabelParser
constructor
A new instance of LabelParser.
- #to_s ⇒ Object
Methods inherited from CompositeParser
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(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
#label ⇒ Object (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_s ⇒ Object
341 342 343 |
# File 'lib/tdp.rb', line 341 def to_s() "(#{@parsers[0].to_s()}/#{@label})" end |