/** * Complete a token (namespace and representation). * It returns the next namespace. * * @param \Hoa\Compiler\Llk\Rule\Token $token Token. * @return string */ protected function completeToken(Compiler\Llk\Rule\Token $token) { if (null !== $token->getRepresentation()) { return $this->_currentNamespace; } $name = $token->getTokenName(); $token->setNamespace($this->_currentNamespace); $toNamespace = $this->_currentNamespace; if (isset($this->_tokens[$this->_currentNamespace][$name])) { $token->setRepresentation($this->_tokens[$this->_currentNamespace][$name]); } else { foreach ($this->_tokens[$this->_currentNamespace] as $_name => $regex) { if (false === strpos($_name, ':')) { continue; } list($_name, $toNamespace) = explode(':', $_name, 2); if ($_name === $name) { break; } } $token->setRepresentation($regex); } return $toNamespace; }