UNPKG

1.94 kBTypeScriptView Raw
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 */
5import { CharStream } from "./CharStream";
6import { Interval } from "./misc/Interval";
7/**
8 * Vacuum all input from a {@link Reader}/{@link InputStream} and then treat it
9 * like a `char[]` buffer. Can also pass in a {@link String} or
10 * `char[]` to use.
11 *
12 * If you need encoding, pass in stream/reader with correct encoding.
13 *
14 * @deprecated as of 4.7, please use `CharStreams` interface.
15 */
16export declare class ANTLRInputStream implements CharStream {
17 /** The data being scanned */
18 protected data: string;
19 /** How many characters are actually in the buffer */
20 protected n: number;
21 /** 0..n-1 index into string of next char */
22 protected p: number;
23 /** What is name or source of this char stream? */
24 name?: string;
25 /** Copy data in string to a local char array */
26 constructor(input: string);
27 /** Reset the stream so that it's in the same state it was
28 * when the object was created *except* the data array is not
29 * touched.
30 */
31 reset(): void;
32 consume(): void;
33 LA(i: number): number;
34 LT(i: number): number;
35 /** Return the current input symbol index 0..n where n indicates the
36 * last symbol has been read. The index is the index of char to
37 * be returned from LA(1).
38 */
39 get index(): number;
40 get size(): number;
41 /** mark/release do nothing; we have entire buffer */
42 mark(): number;
43 release(marker: number): void;
44 /** consume() ahead until p==index; can't just set p=index as we must
45 * update line and charPositionInLine. If we seek backwards, just set p
46 */
47 seek(index: number): void;
48 getText(interval: Interval): string;
49 get sourceName(): string;
50 toString(): string;
51}