Class Scanner

Scans an input text string for character symbols.

This scanner provides a reference to the current and next characters when parsing a string.

Hierarchy

  • Scanner

Constructors

Properties

current: null | string = null

The current character read from the input.

index: number = 0

The current character index from the input.

input: string

The input string to read from.

next: null | string = null

The next character read from the input.

Methods

  • Consume any space and tab characters.

    This does not consume all different types of white space - just space and tab characters.

    Returns Scanner

    The scanner instance.

  • Expect the current character or throw an error.

    Parameters

    • expected: string

      The expected character.

    • id: string

      The expected id.

    Returns Scanner

    The scanner instance.

    Throws

    An error if the two values don't match.

  • Expect a new line character and consume it.

    This will handle carriage return line feeds as well.

    Parameters

    • id: string

      The expected id.

    Returns Scanner

    The scanner instance.

    Throws

    An error if a newline isn't found.

  • Return true if the specified character matches the current character.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if there's a match.

  • Return true if the current character is a valid digit.

    Returns boolean

    True if valid number.

  • Return true if the end of the data stream has been reached.

    Returns boolean

    True if EOF.

  • Return true if the current character is a valid hex character

    Returns boolean

    True if this is a hex character.

  • Return true if the current character is a valid letter (a-z and A-Z).

    Returns boolean

    True if valid letter.

  • Return true if the current character is a string and is lower case.

    Returns boolean

    True if lower case.

  • Return true if the current character is a newline.

    Returns boolean

    True if the current character is a new line.

  • Returns boolean

    true if the current character is a space or tab.

  • Return true if the current character is a string and is upper case.

    Returns boolean

    True if upper case.

  • Return true if the current character is considered white space.

    Returns boolean

    True if white space.

  • Return true if the character is a valid digit.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if valid number.

  • Return true if the character is a valid hex character

    Parameters

    • c: null | string

      The charcter to test.

    Returns boolean

    True if this is a hex character.

  • Return true if the character is a valid letter (a-z and A-Z).

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if valid letter.

  • Return true if the character is a string and is lower case.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if lower case.

  • Return true if the character is a newline.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if the character is a new line.

  • Return true if the character is a space or a tab.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if a space or a tab.

  • Return true if the character is a string and is upper case.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if upper case.

  • Return true if the character is considered white space.

    Parameters

    • c: null | string

      The character to test.

    Returns boolean

    True if white space.

Generated using TypeDoc