The most common stream of this.tokens is one where every token is buffered up and this.tokens are prefiltered for a certain channel (the parser will only see these this.tokens and cannot change the filter channel number during the parse).

TODO: how to access the full token stream? How to track all this.tokens matched per rule?

Hierarchy

  • LegacyCommonTokenStream

Implements

Index

Constructors

constructor

Properties

_tokenSource

_tokenSource: ITokenSource

Protected channel

channel: number = TokenChannels.default

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

Protected channelOverrideMap

channelOverrideMap: Dictionary<number, number>

Map from token type to channel to override some Tokens' channel numbers

Protected discardOffChannelTokens

discardOffChannelTokens: boolean = false

By default, track all incoming this.tokens

Protected discardSet

discardSet: List<number>

Set of token types; discard any this.tokens with this type

Protected lastMarker

lastMarker: number

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

Protected p

p: number = -1

The index into the this.tokens list of the current token (next token to consume). p==-1 indicates that the this.tokens list is empty

range

range: number = 0

How deep have we gone?

tokenSource

tokenSource: ITokenSource

Protected tokens

tokens: List<IToken>

Record every single token pulled from the source so we can reproduce chunks of it later.

Accessors

count

  • get count(): number
  • Returns number

index

  • get index(): number
  • Returns number

sourceName

  • get sourceName(): string
  • Returns string

Methods

consume

  • consume(): void
  • Move the input pointer to the next incoming token. The stream must become active with LT(1) available. consume() simply moves the input pointer so that LT(1) points at the next input symbol. Consume at least one token.

    Walk past any token not on the channel the parser is listening to.

    Returns void

discardTokenType

  • discardTokenType(ttype: number): void
  • Parameters

    • ttype: number

    Returns void

fillBuffer

  • fillBuffer(): void
  • Load all this.tokens from the token source and put in this.tokens. This is done upon first LT request because you might want to set some token type / channel overrides before filling buffer.

    Returns void

get

  • Return absolute token i; ignore which channel the this.tokens are on; that is, count all this.tokens not just on-channel this.tokens.

    Parameters

    • i: number

    Returns IToken

getTokens

getTokens2

  • Given a start and stop index, return a List of all this.tokens in the token type BitSet. Return null if no this.tokens were found. This method looks at both on and off channel this.tokens.

    Parameters

    • start: number
    • stop: number
    • Optional types: BitSet

    Returns List<IToken>

implements

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

la

  • la(i: number): number
  • Parameters

    • i: number

    Returns number

Protected lb

  • Look backwards k this.tokens on-channel this.tokens

    Parameters

    • k: number

    Returns IToken

lt

  • Get the ith token from the current position 1..n where k=1 is the first symbol of lookahead.

    Parameters

    • k: number

    Returns IToken

mark

  • mark(): number

release

  • release(marker: number): void

reset

  • reset(): void
  • Returns void

rewind

  • rewind(marker?: number): void

seek

  • seek(index: number): void

setDiscardOffChannelTokens

  • setDiscardOffChannelTokens(discardOffChannelTokens: boolean): void
  • Parameters

    • discardOffChannelTokens: boolean

    Returns void

setTokenSource

  • Reset this token stream by setting its token source.

    Parameters

    Returns void

setTokenTypeChannel

  • setTokenTypeChannel(ttype: number, channel: number): void
  • A simple filter mechanism whereby you can tell this token stream to force all this.tokens of type ttype to be on channel. For example, when interpreting, we cannot exec actions so we need to tell the stream to force all WS and NEWLINE to be a different, ignored channel.

    Parameters

    • ttype: number
    • channel: number

    Returns void

Protected skipOffTokenChannels

  • skipOffTokenChannels(i: number): number
  • Given a starting index, return the index of the first on-channel token.

    Parameters

    • i: number

    Returns number

Protected skipOffTokenChannelsReverse

  • skipOffTokenChannelsReverse(i: number): number
  • Parameters

    • i: number

    Returns number

toString

  • toString(): string
  • Returns string

toString2

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

    • start: number
    • stop: number

    Returns string

toString3

Generated using TypeDoc