/*! * Copyright 2016 The ANTLR Project. All rights reserved. * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information. */ export declare namespace IntStream { /** * The value returned by {@link #LA LA()} when the end of the stream is * reached. */ const EOF: number; /** * The value returned by {@link #getSourceName} when the actual name of the * underlying source is not known. */ const UNKNOWN_SOURCE_NAME: string; } /** * A simple stream of symbols whose values are represented as integers. This * interface provides marked ranges with support for a minimum level * of buffering necessary to implement arbitrary lookahead during prediction. * For more information on marked ranges, see {@link #mark}. * *
Initializing Methods: Some methods in this interface have * unspecified behavior if no call to an initializing method has occurred after * the stream was constructed. The following is a list of initializing methods:
* *This method is guaranteed to succeed if any of the following are true:
* *If {@code i} represents a position at or beyond the end of the stream, * this method returns {@link #EOF}.
* *The return value is unspecified if {@code i<0} and fewer than {@code -i} * calls to {@link #consume consume()} have occurred from the beginning of * the stream before calling this method.
* * @throws UnsupportedOperationException if the stream does not support * retrieving the value of the specified symbol */ LA(i: number): number; /** * A mark provides a guarantee that {@link #seek seek()} operations will be * valid over a "marked range" extending from the index where {@code mark()} * was called to the current `index`. This allows the use of * streaming input sources by specifying the minimum buffering requirements * to support arbitrary lookahead during prediction. * *The returned mark is an opaque handle (type {@code int}) which is passed * to {@link #release release()} when the guarantees provided by the marked * range are no longer necessary. When calls to * {@code mark()}/{@code release()} are nested, the marks must be released * in reverse order of which they were obtained. Since marked regions are * used during performance-critical sections of prediction, the specific * behavior of invalid usage is unspecified (i.e. a mark is not released, or * a mark is released twice, or marks are not released in reverse order from * which they were created).
* *The behavior of this method is unspecified if no call to an * {@link IntStream initializing method} has occurred after this stream was * constructed.
* *This method does not change the current position in the input stream.
* *The following example shows the use of {@link #mark mark()}, * {@link #release release(mark)}, `index`, and * {@link #seek seek(index)} as part of an operation to safely work within a * marked region, then restore the stream position to its original value and * release the mark.
*
* IntStream stream = ...;
* int index = -1;
* int mark = stream.mark();
* try {
* index = stream.index;
* // perform work here...
* } finally {
* if (index != -1) {
* stream.seek(index);
* }
* stream.release(mark);
* }
*
*
* @return An opaque marker which should be passed to
* {@link #release release()} when the marked range is no longer required.
*/
mark(): number;
/**
* This method releases a marked range created by a call to
* {@link #mark mark()}. Calls to {@code release()} must appear in the
* reverse order of the corresponding calls to {@code mark()}. If a mark is
* released twice, or if marks are not released in reverse order of the
* corresponding calls to {@code mark()}, the behavior is unspecified.
*
* For more information and an example, see {@link #mark}.
* * @param marker A marker returned by a call to {@code mark()}. * @see #mark */ release(marker: number): void; /** * Return the index into the stream of the input symbol referred to by * {@code LA(1)}. * *The behavior of this method is unspecified if no call to an * {@link IntStream initializing method} has occurred after this stream was * constructed.
*/ readonly index: number; /** * Set the input cursor to the position indicated by {@code index}. If the * specified index lies past the end of the stream, the operation behaves as * though {@code index} was the index of the EOF symbol. After this method * returns without throwing an exception, then at least one of the following * will be true. * *