Class: Panini::DerivationStrategy::Exhaustive

Inherits:
Base
  • Object
show all
Defined in:
lib/derivation_strategy/exhaustive.rb

Instance Method Summary collapse

Constructor Details

#initialize(grammar, length_limit = nil) ⇒ Exhaustive

Returns a new instance of Exhaustive.



25
26
27
28
29
# File 'lib/derivation_strategy/exhaustive.rb', line 25

def initialize(grammar, length_limit = nil)
  super(grammar)
  @in_progress_work = [].push([@grammar.start])
  @length_limit = length_limit
end

Instance Method Details

#sentenceObject

Generates a sentence.



32
33
34
35
36
37
38
39
# File 'lib/derivation_strategy/exhaustive.rb', line 32

def sentence
  # unless @in_progress_work.empty?
  while !@in_progress_work.empty? && @in_progress_work.top.has_nonterminals?
    generate_work(@in_progress_work.pop)
  end
  @in_progress_work.pop
  # end
end