1 | /*!
|
2 | * Copyright 2016 The ANTLR Project. All rights reserved.
|
3 | * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
|
4 | */
|
5 | import { CharStream } from "./CharStream";
|
6 | import { Token } from "./Token";
|
7 | import { TokenSource } from "./TokenSource";
|
8 | /** The default mechanism for creating tokens. It's used by default in Lexer and
|
9 | * the error handling strategy (to create missing tokens). Notifying the parser
|
10 | * of a new factory means that it notifies its token source and error strategy.
|
11 | */
|
12 | export interface TokenFactory {
|
13 | /** This is the method used to create tokens in the lexer and in the
|
14 | * error handling strategy. If text!=undefined, than the start and stop positions
|
15 | * are wiped to -1 in the text override is set in the CommonToken.
|
16 | */
|
17 | create(source: {
|
18 | source?: TokenSource;
|
19 | stream?: CharStream;
|
20 | }, type: number, text: string | undefined, channel: number, start: number, stop: number, line: number, charPositionInLine: number): Token;
|
21 | /** Generically useful */
|
22 | createSimple(type: number, text: string): Token;
|
23 | }
|