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); }
/** * @return SituationSet */ public function closure() { $state = new SituationSet(); $state->add($this); return $state->closure(); }
/** * @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(); }