public function testExpectedTokenWithLookahead() { $lexer = new DocLexer(); $lexer->lookahead = array('position' => 123, 'value' => 'abc'); $exception = SyntaxException::expectedToken('test', null, $lexer); $this->assertEquals('Expected test, received \'abc\' at position 123.', $exception->getMessage()); }
/** * 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(); }