Class StringReader

This reader is used to read from a string. This is usually worse for performance than reading from a buffer, as buffer indexes are loaded lazily, but for most cases it is good enough.

In most cases, you would want to use the regular parse function, which uses a dynamic reader from the input.

If you still want to create a string reader, you can do so by using the StringReader class.

Example

const reader = new StringReader('(apple OR orange) AND (drink OR juice)')
const lexer = new Lexer(reader)
const parser = new Parser(lexer)
const tokens = parser.parse()

Hierarchy

  • StringReader

Implements

Constructors

Properties

Methods

Constructors

Properties

index: number = 0

The current index of the input stream

Methods

  • Peek at the next character in the input stream

    Parameters

    • n: number = 0

    Returns string

  • Consume the next character in the input stream

    Parameters

    • n: number = 0

    Returns string

  • Check if the input stream is at the end of the file

    Returns boolean

Generated using TypeDoc