Class: TDParser::ConcatParser
- Inherits:
-
CompositeParser
- Object
- Parser
- CompositeParser
- TDParser::ConcatParser
- Defined in:
- lib/tdp.rb
Instance Attribute Summary
Attributes inherited from CompositeParser
Instance Method Summary collapse
- #-(r) ⇒ Object
- #call(tokens, buff) ⇒ Object
-
#initialize(r1, r2) ⇒ ConcatParser
constructor
A new instance of ConcatParser.
- #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(r1, r2) ⇒ ConcatParser
Returns a new instance of ConcatParser.
374 375 376 |
# File 'lib/tdp.rb', line 374 def initialize(r1, r2) super(r1, r2) end |
Instance Method Details
#-(r) ⇒ Object
390 391 392 |
# File 'lib/tdp.rb', line 390 def -(r) @parsers[0] - (@parsers[1] - r) end |
#call(tokens, buff) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/tdp.rb', line 378 def call(tokens, buff) if( (x = @parsers[0].call(tokens, buff)).nil? ) nil else if( (y = @parsers[1].call(tokens, buff)).nil? ) nil else x + y end end end |
#to_s ⇒ Object
394 395 396 |
# File 'lib/tdp.rb', line 394 def to_s() "(#{@parsers[0].to_s()} #{@parsers[1].to_s()})" end |