Class: Gullah::LoopCheck
- Inherits:
-
Object
- Object
- Gullah::LoopCheck
- Defined in:
- lib/gullah.rb
Instance Method Summary collapse
- #add(link, grammar) ⇒ Object
-
#initialize(link) ⇒ LoopCheck
constructor
A new instance of LoopCheck.
Constructor Details
#initialize(link) ⇒ LoopCheck
Returns a new instance of LoopCheck.
586 587 588 589 |
# File 'lib/gullah.rb', line 586 def initialize(link) @seen = Set.new(link) @seeking = link.last end |
Instance Method Details
#add(link, grammar) ⇒ Object
591 592 593 594 595 596 597 598 599 |
# File 'lib/gullah.rb', line 591 def add(link, grammar) if @seeking == link.first if @seen.include? link.last grammar.instance_variable_set :@do_unary_branch_check, true throw :looped end LoopCheck.new(@seen.to_a + [link.last]) end end |