public function testGetKey() { $rule = new Rule(); $rule->setId(1); $object = new Situation(new Table(), $rule, 2); $this->assertEquals('1.2', $object->getKey()); }
public function testGetKey() { $state = new SituationSet(); $ruleA = new Rule(); $ruleA->setId(12); $ruleB = new Rule(); $ruleB->setId(13); $state->add(new Situation(new Table(), $ruleA, 1)); $state->add(new Situation(new Table(), $ruleB, 2)); $this->assertEquals('12.1|13.2', $state->getKey()); $this->assertEquals('12.1|13.2', $state->getKey()); }
/** * @param Syntax $syntax */ public function fromSyntax(Syntax $syntax) { $this->syntax = $syntax; $startRule = new Rule(); $startRule->setId(0); $startRule->setLeft(self::START_TOKEN); $startRule->setRight(array(self::GLOBAL_TOKEN)); $this->nonterminals[] = $startRule->getLeft(); $this->ordered->addRule($startRule); $this->left->getRuleSet($startRule->getLeft())->addRule($startRule); $this->right->getRuleSet(self::GLOBAL_TOKEN)->addRule($startRule); foreach ($this->addRules($syntax) as $token) { if ($this->left->hasRuleSet($token)) { $this->nonterminals[] = $token; } else { $this->terminals[] = $token; } } $this->transition = new TransitionSet($this); $this->transition->process(); $this->calculateTable(); }