1 /*
2 * Copyright (c) 2012-2018 The ANTLR Project. All rights reserved.
3 * Use of this file is governed by the BSD 3-clause license that
4 * can be found in the LICENSE.txt file in the project root.
5 */6 7 moduleantlr.v4.runtime.Token;
8 9 importantlr.v4.runtime.IntStream;
10 importantlr.v4.runtime.CharStream;
11 importantlr.v4.runtime.TokenSource;
12 importstd.variant;
13 14 /**
15 * A token has properties: text, type, line, character position in the line
16 * (so we can ignore tabs), token channel, index, and source from which
17 * we obtained this token.
18 */19 interfaceToken20 {
21 22 /**
23 * Get the text of the token.
24 */25 publicVariantgetText();
26 27 /**
28 * Get the token type of the token
29 */30 publicintgetType();
31 32 /**
33 * The line number on which the 1st character of this token was matched,
34 * line=1..n
35 */36 publicintgetLine();
37 38 /**
39 * The index of the first character of this token relative to the
40 * beginning of the line at which it occurs, 0..n-1
41 */42 publicintgetCharPositionInLine();
43 44 /**
45 * Return the channel this token. Each token can arrive at the parser
46 * on a different channel, but the parser only "tunes" to a single channel.
47 * The parser ignores everything not on DEFAULT_CHANNEL.
48 */49 publicintgetChannel();
50 51 /**
52 * An index from 0..n-1 of the token object in the input stream.
53 * This must be valid in order to print token streams and
54 * use TokenRewriteStream.
55 *
56 * Return -1 to indicate that this token was conjured up since
57 * it doesn't have a valid index.
58 */59 publicsize_tgetTokenIndex();
60 61 publicsize_tstartIndex();
62 63 publicsize_tstopIndex();
64 65 /**
66 * Gets the {@link TokenSource} which created this token.
67 */68 publicTokenSourcegetTokenSource();
69 70 /**
71 * Gets the {@link CharStream} from which this token was derived.
72 */73 publicCharStreamgetInputStream();
74 75 }