Class: Panini::DerivationStrategy::Exhaustive
- Defined in:
- lib/derivation_strategy/exhaustive.rb
Instance Method Summary collapse
-
#initialize(grammar, length_limit = nil) ⇒ Exhaustive
constructor
A new instance of Exhaustive.
-
#sentence ⇒ Object
Generates a sentence.
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
#sentence ⇒ Object
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 |