/**
* If the next token is of the given kind, return that token after advancing
* the parser. Otherwise, do not change the parser state and return false.
* @param string $kind
* @return Token
* @throws Exception
*/
function expect($kind)
{
$token = $this->token;
if ($token->kind === $kind) {
$this->advance();
return $token;
}
throw Exception::create($this->source, $token->start, "Expected " . Token::getKindDescription($kind) . ", found " . $token->getDescription());
}