Class: Neg::Parser::SequenceParser

Inherits:
CompositeParser show all
Defined in:
lib/neg/parser.rb

Instance Method Summary collapse

Methods inherited from CompositeParser

#initialize

Methods inherited from SubParser

#*, #[], #parse, #|

Constructor Details

This class inherits a constructor from Neg::Parser::CompositeParser

Instance Method Details

#+(pa) ⇒ Object



264
265
266
267
268
269
# File 'lib/neg/parser.rb', line 264

def +(pa)

  @children << pa

  self
end

#do_parse(i) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/neg/parser.rb', line 271

def do_parse(i)

  results = []

  @children.each do |c|

    results << c.parse(i)
    break unless results.last[1]
  end

  [ results.last[1], results ]
end

#to_s(parent = nil) ⇒ Object



284
285
286
287
# File 'lib/neg/parser.rb', line 284

def to_s(parent=nil)

  "(#{@children.collect { |c| c.to_s(self) }.join(' + ')})"
end