1 | import { Token, TokenKind } from './Token';
|
2 | import { TokenSequence } from './TokenSequence';
|
3 | import { ParserContext } from './ParserContext';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare class TokenReader {
|
15 | readonly tokens: ReadonlyArray<Token>;
|
16 | private readonly _parserContext;
|
17 | private _readerStartIndex;
|
18 | private _readerEndIndex;
|
19 | private _currentIndex;
|
20 | private _accumulatedStartIndex;
|
21 | constructor(parserContext: ParserContext, embeddedTokenSequence?: TokenSequence);
|
22 | /**
|
23 | * Extracts and returns the TokenSequence that was accumulated so far by calls to readToken().
|
24 | * The next call to readToken() will start a new accumulated sequence.
|
25 | */
|
26 | extractAccumulatedSequence(): TokenSequence;
|
27 | /**
|
28 | * Returns true if the accumulated sequence has any tokens yet. This will be false
|
29 | * when the TokenReader starts, and it will be false immediately after a call
|
30 | * to extractAccumulatedSequence(). Otherwise, it will become true whenever readToken()
|
31 | * is called.
|
32 | */
|
33 | isAccumulatedSequenceEmpty(): boolean;
|
34 | /**
|
35 | * Like extractAccumulatedSequence(), but returns undefined if nothing has been
|
36 | * accumulated yet.
|
37 | */
|
38 | tryExtractAccumulatedSequence(): TokenSequence | undefined;
|
39 | /**
|
40 | * Asserts that isAccumulatedSequenceEmpty() should return false. If not, an exception
|
41 | * is throw indicating a parser bug.
|
42 | */
|
43 | assertAccumulatedSequenceIsEmpty(): void;
|
44 | /**
|
45 | * Returns the next token that would be returned by _readToken(), without
|
46 | * consuming anything.
|
47 | */
|
48 | peekToken(): Token;
|
49 | /**
|
50 | * Returns the TokenKind for the next token that would be returned by _readToken(), without
|
51 | * consuming anything.
|
52 | */
|
53 | peekTokenKind(): TokenKind;
|
54 | /**
|
55 | * Like peekTokenKind(), but looks ahead two tokens.
|
56 | */
|
57 | peekTokenAfterKind(): TokenKind;
|
58 | /**
|
59 | * Like peekTokenKind(), but looks ahead three tokens.
|
60 | */
|
61 | peekTokenAfterAfterKind(): TokenKind;
|
62 | /**
|
63 | * Extract the next token from the input stream and return it.
|
64 | * The token will also be appended to the accumulated sequence, which can
|
65 | * later be accessed via extractAccumulatedSequence().
|
66 | */
|
67 | readToken(): Token;
|
68 | /**
|
69 | * Returns the kind of the token immediately before the current token.
|
70 | */
|
71 | peekPreviousTokenKind(): TokenKind;
|
72 | /**
|
73 | * Remembers the current position in the stream.
|
74 | */
|
75 | createMarker(): number;
|
76 | /**
|
77 | * Rewinds the stream pointer to a previous position in the stream.
|
78 | */
|
79 | backtrackToMarker(marker: number): void;
|
80 | }
|
81 | //# sourceMappingURL=TokenReader.d.ts.map |
\ | No newline at end of file |