/** * @return array|NormalizedProduction[] */ public static function normalizedProductions() { $productions = self::productions(); $normalizer = new Normalizer(); $normalized = $normalizer->normalizeList($productions); return $normalized; }
public function testGeneratePredictSets() { $setGenerator = $this->createSetGenerator(); $grammar = TestGrammar::grammar(); $normalizer = new Normalizer(); $productions = $normalizer->normalize($grammar); $expectedSets = TestGrammar::predictSets(); $firstSets = TestGrammar::firstSets(); $followSets = TestGrammar::followSets(); $hashFactory = new SimpleHashKeyFactory(); $actualSets = new LookAheadSets($hashFactory); $setGenerator->generateLookAheadSets($productions, $actualSets, $followSets, $firstSets); /** @var LookAheadSetEntry $expectedEntry */ /** @var NormalizedProduction $production */ foreach ($expectedSets->getEntrySetIterator() as $production => $expected) { $actual = $actualSets->getSet($production); $actualCountBefore = $actual->count(); $actual->addAll($expected); $actualCountAfter = $actual->count(); $this->assertEquals($actualCountBefore, $actualCountAfter); $expectedCountBefore = $expected->count(); $expected->addAll($actual); $expectedCountAfter = $expected->count(); $this->assertEquals($expectedCountBefore, $expectedCountAfter); } }