A pretty quick CharStream that pulls all data from an array directly. Every method call counts in the lexer. Java's strings aren't very good so I'm avoiding.

Hierarchy

Implements

Index

Constructors

constructor

  • new ANTLRStringStream(input?: string, data?: string[], numberOfActualCharsInArray?: number, sourceName?: string): ANTLRStringStream
  • Copy data in string to a local char array

    Parameters

    • Optional input: string
    • Default value data: string[] = input.split("")
    • Default value numberOfActualCharsInArray: number = input != null ? input.length : null
    • Default value sourceName: string = null

    Returns ANTLRStringStream

Properties

charPositionInLine

charPositionInLine: number = 0

The index of the character relative to the beginning of the this.line 0..n-1

Protected data

data: string[]

The data being scanned

Protected lastMarker

lastMarker: number

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

line

line: number = 1

this.line number 1..n within the input

Protected markDepth

markDepth: number = 0

tracks how deep mark() calls are nested

Protected markers

A list of CharStreamState objects that tracks the stream state values this.line, this.charPositionInLine, and this.p that can change as you move through the input stream. Indexed from 1..markDepth. A null is kept @ index 0. Create upon first call to mark().

Protected n

n: number

How many characters are actually in the buffer

name

name: string

What is name or source of this char stream?

Protected p

p: number = 0

0..n-1 index into string of next char

Accessors

count

  • get count(): number
  • Returns number

index

  • get index(): number
  • Return the current input symbol index 0..n where n indicates the last symbol has been read. The index is the index of char to be returned from LA(1).

    Returns number

sourceName

  • get sourceName(): string
  • Returns string

Methods

consume

  • consume(): void

implements

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

la

  • la(i: number): number
  • Parameters

    • i: number

    Returns number

lt

  • lt(i: number): number
  • Parameters

    • i: number

    Returns number

mark

  • mark(): number

release

  • release(marker: number): void

reset

  • reset(): void
  • Reset the stream so that it's in the same state it was when the object was created except the data array is not touched.

    Returns void

rewind

  • rewind(m?: number): void
  • Parameters

    • Default value m: number = this.lastMarker

    Returns void

seek

  • seek(index: number): void
  • consume() ahead until this.p==index; can't just set this.p=index as we must update this.line and this.charPositionInLine.

    Parameters

    • index: number

    Returns void

substring

  • substring(start: number, length: number): string

toString

  • toString(): string
  • Returns string

Generated using TypeDoc