Constructors

Properties

lexer: Lexer
selfReferential: {
    $locals: {
        type: 16;
    };
    this: {
        type: 15;
    };
}
text: string
tokens: Token[]

Methods

  • Parses the input text and generates an AST.

    Parameters

    • text: string

      The input text to parse.

    Returns ASTNode

    The root node of the AST.

  • Consumes a token if it matches the expected type.

    Parameters

    • Optionale1: string

      The expected token type.

    Returns Token

    The consumed token.

  • Consumes the next token if it matches any of the expected types.

    Parameters

    • Optional Rest...expected: string[]

      The expected token types.

    Returns boolean | Token

    The consumed token if it matches, otherwise false.

  • Checks if the next token matches any of the expected types.

    Parameters

    • Optional Rest...expected: string[]

      The expected token types.

    Returns boolean | Token

    The next token if it matches, otherwise false.

  • Checks if the token at the specified index matches any of the expected types.

    Parameters

    • i: number

      The index to check.

    • Optional Rest...expected: string[]

      The expected token types.

    Returns boolean | Token

    The token at the specified index if it matches, otherwise false.

  • Throws a syntax error.

    Parameters

    • msg: string

      The error message.

    • Optionaltoken: Token

      The token that caused the error.

    Returns void