/** * Matches the next token and advances. * * @param integer $token The next token to match. * * @return array|null TRUE if the next token matches, FALSE if not. * * @throws Exception * @throws SyntaxException If a syntax error is found. */ private function match($token) { if (!$this->lexer->isNextToken($token)) { throw SyntaxException::expectedToken($this->lexer->getLiteral($token), null, $this->lexer); } return $this->lexer->moveNext(); }
/** * ArrayEntry ::= Value | KeyValuePair * KeyValuePair ::= Key ("=" | ":") PlainValue | Constant * Key ::= string | integer | Constant * * @return array */ private function ArrayEntry() { $peek = $this->lexer->glimpse(); if (DocLexer::T_EQUALS === $peek['type'] || DocLexer::T_COLON === $peek['type']) { if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) { $key = $this->Constant(); } else { $this->matchAny(array(DocLexer::T_INTEGER, DocLexer::T_STRING)); $key = $this->lexer->token['value']; } $this->matchAny(array(DocLexer::T_EQUALS, DocLexer::T_COLON)); return array($key, $this->PlainValue()); } return array(null, $this->Value()); }