1<?php
2
3declare(strict_types=1);
4
5namespace Antlr\Antlr4\Runtime;
6
7use Antlr\Antlr4\Runtime\Utils\Pair;
8
9/**
10 * The default mechanism for creating tokens. It's used by default in Lexer and
11 * the error handling strategy (to create missing tokens). Notifying the parser
12 * of a new factory means that it notifies its token source and error strategy.
13 */
14interface TokenFactory
15{
16    /**
17     * This is the method used to create tokens in the lexer and in
18     * the error handling strategy. If `text !== null`, than the start and stop
19     * positions are wiped to -1 in the text override is set in the CommonToken.
20     */
21    public function createEx(
22        Pair $source,
23        int $type,
24        ?string $text,
25        int $channel,
26        int $start,
27        int $stop,
28        int $line,
29        int $charPositionInLine
30    ) : Token;
31
32    /**
33     * Generically useful.
34     */
35    public function create(int $type, string $text) : Token;
36}
37