| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class FirstBuilder |
||
| 10 | { |
||
| 11 | private $grammar; |
||
| 12 | |||
| 13 | private $first; |
||
| 14 | |||
| 15 | public function __construct(GrammarInterface $grammar) |
||
| 16 | { |
||
| 17 | $this->grammar = $grammar; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return FirstInterface |
||
| 22 | */ |
||
| 23 | public function getFirst(): FirstInterface |
||
| 24 | { |
||
| 25 | if (!isset($this->first)) { |
||
| 26 | $first = new First(); |
||
| 27 | $this->addTokensFromTerminalMap($first); |
||
| 28 | do { |
||
| 29 | $first->resetChangeCount(); |
||
| 30 | $this->mergeProductionsFromNonTerminalMap($first); |
||
| 31 | } while ($first->getChangeCount() > 0); |
||
| 32 | $this->first = $first; |
||
| 33 | } |
||
| 34 | return $this->first; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param First $first |
||
| 39 | */ |
||
| 40 | private function addTokensFromTerminalMap(First $first): void |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param First $first |
||
| 50 | */ |
||
| 51 | private function mergeProductionsFromNonTerminalMap(First $first): void |
||
| 56 | } |
||
| 57 | } |
||
| 59 |