1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime\Error\Exceptions;
6
7use Antlr\Antlr4\Runtime\Parser;
8use Antlr\Antlr4\Runtime\ParserRuleContext;
9
10/**
11 * This signifies any kind of mismatched input exceptions such as when
12 * the current input does not match the expected token.
13 */
14class InputMismatchException extends RecognitionException
15{
16    public function __construct(Parser $recognizer, ?int $state = null, ?ParserRuleContext $ctx = null)
17    {
18        parent::__construct(
19            $recognizer,
20            $recognizer->getInputStream(),
21            $ctx ?? $recognizer->getContext()
22        );
23
24        if ($state !== null) {
25            $this->setOffendingState($state);
26        }
27
28        $this->setOffendingToken($recognizer->getCurrentToken());
29    }
30}
31