예제 #1
0
 public function testClosure()
 {
     $ruleA = new Rule('a', ['b', 'c']);
     $ruleB = new Rule('b', ['a']);
     $ruleC = new Rule('c', ['b']);
     $table = new Table();
     $table->addRule($ruleA, 'a');
     $table->addRule($ruleB, 'b');
     $table->addRule($ruleC, 'c');
     $situation = new Situation($table, $ruleA);
     $state = new SituationSet();
     $state->add($situation);
     $result = $state->closure();
     $this->assertInstanceOf('Jungle\\SLR\\SituationSet', $result);
     $this->assertCount(2, $result);
 }
예제 #2
0
 /**
  * @return SituationSet
  */
 public function closure()
 {
     $state = new SituationSet();
     $state->add($this);
     return $state->closure();
 }
예제 #3
0
 /**
  * @param string $token
  *
  * @return SituationSet
  */
 public function transition($token)
 {
     $set = new SituationSet();
     foreach ($this->situations as $situation) {
         if ($situation->next() == $token) {
             $next = $situation->step();
             if ($next) {
                 $set->add($next);
             }
         }
     }
     return $set->closure();
 }