public function _expr($precedence = 0, $opt = false)
{
$token = $this->parser->lookahead;
$prefix = $this->parser->prefixParseletForToken($token);
if (is_null($prefix)) {
if (!$opt) {
throw new SyntaxError(['expected' => 'expression', 'found' => $token, 'parser' => $this->parser]);
}
return null;
}
// We consume the token only when ensure it has a parselet, thus,
// avoiding to rollback in the tape
$this->parser->consume();
$left = $prefix->parse($this, $token);
while ($precedence < $this->getPrecedence()) {
$token = $this->parser->consumeAndFetch();
$infix = $this->parser->infixParseletForToken($token);
$left = $infix->parse($this, $left, $token);
}
return $left;
}