A token stream that pulls tokens from the code source on-demand and without tracking a complete buffer of the tokens. This stream buffers the minimum number of tokens possible. It's the same as OnDemandTokenStream except that OnDemandTokenStream buffers all tokens.

You can't use this stream if you pass whitespace or other off-channel tokens to the parser. The stream can't ignore off-channel tokens.

You can only look backwards 1 token: LT(-1).

Use this when you need to read from a socket or other infinite stream.

see

BufferedTokenStream

see

CommonTokenStream

Hierarchy

Implements

Index

Constructors

constructor

Properties

_data

_data: List<T> = new List<T>()

dynamically-sized buffer of elements

_eof

_eof: IToken = null

Track object returned by nextElement upon end of stream; Return it later when they ask for LT passed end of input.

_lastMarker

_lastMarker: number
Track the last mark() call result value for use in rewind().

_markDepth

_markDepth: number
tracks how deep mark() calls are nested

_p

_p: number = 0

index of next element to fill

Protected channel

channel: number = TokenChannels.default

Skip tokens on any channel but this one; this is how we skip whitespace...

maxLookBehind

maxLookBehind: number = 1

range

range: number = 0

How deep have we gone?

Protected tokenIndex

tokenIndex: number

tokenSource

tokenSource: ITokenSource

Accessors

count

  • get count(): number

endOfFile

  • get endOfFile(): IToken
  • set endOfFile(value: IToken): void

index

  • get index(): number

lastRealToken

lastToken

previousElement

  • get previousElement(): IToken

sourceName

  • get sourceName(): string
  • Returns string

Methods

clear

  • clear(): void

consume

  • consume(): void

dequeue

enqueue

extElement

fill

  • fill(n: number): void
  • add n elements to buffer

    Parameters

    • n: number

    Returns void

get

implements

  • implements(): any[]
  • Returns any[]

isEndOfFile

  • isEndOfFile(o: IToken): boolean

la

  • la(i: number): number
  • Parameters

    • i: number

    Returns number

lb

lt

mark

  • mark(): number

nextElement

  • Implement nextElement to supply a stream of elements to this lookahead buffer. Return EOF upon end of the stream we're pulling from.

    Returns IToken

peek

release

  • release(marker: number): void

reset

  • reset(): void

rewind

  • rewind(): void

rewind2

  • rewind2(marker: number): void

seek

  • seek(index: number): void
  • Seek to a 0-indexed absolute token index. Normally used to seek backwards in the buffer. Does not force loading of nodes. To preserve backward compatibility, this method allows seeking past the end of the currently buffered data. In this case, the input pointer will be moved but the data will only actually be loaded upon the next call to {@link #consume} or {@link #LT} for {@code k>0}.

    Parameters

    • index: number

    Returns void

syncAhead

  • syncAhead(need: number): void
  • Make sure we have 'need' elements from current position p. Last valid p index is data.size()-1. p+need-1 is the data index 'need' elements ahead. If we need 1 element, (p+1-1)==p must be < data.size().

    Parameters

    • need: number

    Returns void

toString

  • toString(): string
  • Return string of current buffer contents; non-destructive

    Returns string

toString2

  • toString2(start: IToken | number, stop: IToken | number): string
  • Parameters

    Returns string

Generated using TypeDoc