/** * Attempts to match the current lookahead token with any of the given tokens. * * If any of them matches, this method updates the lookahead token; otherwise * a syntax error is raised. * * @param array $tokens * * @return boolean */ private function matchAny(array $tokens) { if (!$this->lexer->isNextTokenAny($tokens)) { $this->syntaxError(implode(' or ', array_map(array($this->lexer, 'getLiteral'), $tokens))); } return $this->lexer->moveNext(); }
/** * Matches any one of the tokens and advances. * * @param array $tokens The list of tokens. * * @return boolean TRUE if the next token matches, FALSE if not. * * @throws Exception * @throws SyntaxException If a syntax error is found. */ private function matchAny(array $tokens) { if (!$this->lexer->isNextTokenAny($tokens)) { throw SyntaxException::expectedToken(implode(' or ', array_map(array($this->lexer, 'getLiteral'), $tokens)), null, $this->lexer); } return $this->lexer->moveNext(); }
/** * Identifier ::= string * * @return string */ private function Identifier() { // check if we have an annotation if (!$this->lexer->isNextTokenAny(self::$classIdentifiers)) { $this->syntaxError('namespace separator or identifier'); } $this->lexer->moveNext(); $className = $this->lexer->token['value']; while ($this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value']) && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { $this->match(DocLexer::T_NAMESPACE_SEPARATOR); $this->matchAny(self::$classIdentifiers); $className .= '\\' . $this->lexer->token['value']; } return $className; }