MCPcopy
hub / github.com/antlr/antlr4 / BufferedTokenStream

Class BufferedTokenStream

runtime/JavaScript/src/antlr4/BufferedTokenStream.js:23–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 * {@link CommonTokenStream}.</p>
22 */
23export default class BufferedTokenStream extends TokenStream {
24 constructor(tokenSource) {
25
26 super();
27 // The {@link TokenSource} from which tokens for this stream are fetched.
28 this.tokenSource = tokenSource;
29 /**
30 * A collection of all tokens fetched from the token source. The list is
31 * considered a complete view of the input once {@link //fetchedEOF} is set
32 * to {@code true}.
33 */
34 this.tokens = [];
35
36 /**
37 * The index into {@link //tokens} of the current token (next token to
38 * {@link //consume}). {@link //tokens}{@code [}{@link //p}{@code ]} should
39 * be
40 * {@link //LT LT(1)}.
41 *
42 * <p>This field is set to -1 when the stream is first constructed or when
43 * {@link //setTokenSource} is called, indicating that the first token has
44 * not yet been fetched from the token source. For additional information,
45 * see the documentation of {@link IntStream} for a description of
46 * Initializing Methods.</p>
47 */
48 this.index = -1;
49
50 /**
51 * Indicates whether the {@link Token//EOF} token has been fetched from
52 * {@link //tokenSource} and added to {@link //tokens}. This field improves
53 * performance for the following cases:
54 *
55 * <ul>
56 * <li>{@link //consume}: The lookahead check in {@link //consume} to
57 * prevent
58 * consuming the EOF symbol is optimized by checking the values of
59 * {@link //fetchedEOF} and {@link //p} instead of calling {@link
60 * //LA}.</li>
61 * <li>{@link //fetch}: The check to prevent adding multiple EOF symbols
62 * into
63 * {@link //tokens} is trivial with this field.</li>
64 * <ul>
65 */
66 this.fetchedEOF = false;
67 }
68
69 mark() {
70 return 0;
71 }
72
73 release(marker) {
74 // no resources to release
75 }
76
77 reset() {
78 this.seek(0);
79 }
80

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…