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 { BufferedTokenStream } from "./BufferedTokenStream";
|
6 | import { Token } from "./Token";
|
7 | import { TokenSource } from "./TokenSource";
|
8 | /**
|
9 | * This class extends {@link BufferedTokenStream} with functionality to filter
|
10 | * token streams to tokens on a particular channel (tokens where
|
11 | * {@link Token#getChannel} returns a particular value).
|
12 | *
|
13 | * This token stream provides access to all tokens by index or when calling
|
14 | * methods like {@link #getText}. The channel filtering is only used for code
|
15 | * accessing tokens via the lookahead methods {@link #LA}, {@link #LT}, and
|
16 | * {@link #LB}.
|
17 | *
|
18 | * By default, tokens are placed on the default channel
|
19 | * ({@link Token#DEFAULT_CHANNEL}), but may be reassigned by using the
|
20 | * `->channel(HIDDEN)` lexer command, or by using an embedded action to
|
21 | * call {@link Lexer#setChannel}.
|
22 | *
|
23 | * Note: lexer rules which use the `->skip` lexer command or call
|
24 | * {@link Lexer#skip} do not produce tokens at all, so input text matched by
|
25 | * such a rule will not be available as part of the token stream, regardless of
|
26 | * channel.
|
27 | */
|
28 | export declare class CommonTokenStream extends BufferedTokenStream {
|
29 | /**
|
30 | * Specifies the channel to use for filtering tokens.
|
31 | *
|
32 | * The default value is {@link Token#DEFAULT_CHANNEL}, which matches the
|
33 | * default channel assigned to tokens created by the lexer.
|
34 | */
|
35 | protected channel: number;
|
36 | /**
|
37 | * Constructs a new {@link CommonTokenStream} using the specified token
|
38 | * source and filtering tokens to the specified channel. Only tokens whose
|
39 | * {@link Token#getChannel} matches `channel` or have the
|
40 | * `Token.type` equal to {@link Token#EOF} will be returned by the
|
41 | * token stream lookahead methods.
|
42 | *
|
43 | * @param tokenSource The token source.
|
44 | * @param channel The channel to use for filtering tokens.
|
45 | */
|
46 | constructor(tokenSource: TokenSource, channel?: number);
|
47 | protected adjustSeekIndex(i: number): number;
|
48 | protected tryLB(k: number): Token | undefined;
|
49 | tryLT(k: number): Token | undefined;
|
50 | /** Count EOF just once. */
|
51 | getNumberOfOnChannelTokens(): number;
|
52 | }
|