Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InputStream

Class for traversing and analyzing strings.

Hierarchy

  • InputStream

Index

Constructors

constructor

Properties

position

position: number = 0

Current position in the source string.

source

source: string

The source string.

Accessors

current

  • get current(): string

currentLine

  • get currentLine(): string

isEof

  • get isEof(): boolean
  • Whether the current position is reached the end of the source string.

    Returns boolean

isValid

  • get isValid(): boolean
  • Whether the current position is within the string bounds.

    Returns boolean

length

  • get length(): number

location

next

  • get next(): string

rest

  • get rest(): string
  • The substring from the current position to the end of the source string.

    Returns string

Methods

checkBounds

  • checkBounds(offset: number): boolean
  • Checks whether the current position is within the string bounds.

    Parameters

    • offset: number

    Returns boolean

checkEof

  • checkEof(offset: number): boolean
  • Checks whether the current position is reached the end of the source string.

    Parameters

    • offset: number

      The offset relative the current position.

    Returns boolean

findMatching

  • findMatching(lexemes: string[], offset?: number): string | undefined
  • Returns the first matched lexeme, and undefined otherwise.

    Parameters

    • lexemes: string[]

      Lexemes to match with.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns string | undefined

findPresenting

  • findPresenting(lexemes: string[], offset?: number): string | undefined
  • Returns the first presenting lexeme, and undefined otherwise.

    Parameters

    • lexemes: string[]

      Lexemes to check for.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns string | undefined

lookFor

  • lookFor(lexeme: string | string[], offset?: number): boolean
  • Checks whether a lexeme is present at the current position of the source string.

    Parameters

    • lexeme: string | string[]

      One or more lexemes to look for.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns boolean

match

  • match(lexeme: string | string[], offset?: number): boolean
  • Matches a lexeme at the current position of the source string. I.e if a lexeme is present, moves the stream by the length of the lexeme.

    Parameters

    • lexeme: string | string[]

      One or more lexemes to match.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns boolean

    Whether a lexeme was matched.

matchRegExp

  • matchRegExp(regexp: RegExp, offset?: number): RegExpMatchArray | null
  • Matches a regex pattern with the rest of the source string.

    Parameters

    • regexp: RegExp

      A regular expression to match with.

    • Default value offset: number = 0

      The offset relative to the current value.

    Returns RegExpMatchArray | null

move

  • move(offset: number): number
  • Adjusts the current position by the specified value.

    Parameters

    • offset: number

      The offset to move by.

    Returns number

    New position.

moveTo

  • moveTo(position: number): number
  • Sets the current position.

    Parameters

    • position: number

      The new position.

    Returns number

    New position.

peek

  • peek(offset?: number): string
  • Returns the current character from the source string.

    Parameters

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns string

peekMany

  • peekMany(length: number, offset?: number): string
  • Returns the source substring of the specified length staring from current position with an offset.

    Parameters

    • length: number

      The number of characters to peek.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns string

peekTo

  • peekTo(end?: undefined | number, offset?: number): string
  • Returns the source substring from the current position to the specified one. The substring includes the characters up to, but not including, the character indicated by end.

    Parameters

    • Optional end: undefined | number

      The zero-based index number to peek to. If this value is not specified, the substring continues to the end of the source string.

    • Default value offset: number = 0

      The offset relative to the current position

    Returns string

reset

  • reset(): void

slice

  • slice(start?: undefined | number, end?: undefined | number): string
  • Returns a section of the source string.

    Parameters

    • Optional start: undefined | number

      The index to the beginning of the specified portion of the source string.

    • Optional end: undefined | number

      The index to the end of the specified portion of the source string. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of the source string.

    Returns string

testFor

  • testFor(regexp: RegExp | RegExp[], offset?: number): boolean
  • Checks whether a regex pattern exists in the rest of the source string.

    Parameters

    • regexp: RegExp | RegExp[]

      One or more regular expressions to test for.

    • Default value offset: number = 0

      The offset relative to the current position.

    Returns boolean

Generated using TypeDoc