/**
  * Calculates the "goto" set for a given $item and $symbol.
  *
  * @param array $set A set (of rules) within the canonical collection
  * @param string $symbol A valid variable or terminal.
  * @return array
  */
 public function gotoSet($set, $symbol)
 {
     $forClosure = new RulesCollection();
     foreach ($set as $rule) {
         $rhs = $rule->rhs();
         if (preg_match('/\\.\\b(' . $symbol . ')\\b/', $rhs, $matches)) {
             $lhs = $rule->lhs();
             $rhs = str_replace(".{$matches[1]}", "{$matches[1]}.", $rhs);
             $rhs = str_replace('. ', ' .', $rhs);
             $forClosure->push(new Rule("{$lhs} -> {$rhs}"));
         }
     }
     $closure = $this->_closure($forClosure);
     return $closure;
 }
 public function __construct(array $collection = [])
 {
     parent::__construct($collection);
     $this->_terminals[] = '$';
 }