Class Parser

The Parser class parses a series of tokens generated by the Tokenizer. It supports parsing loops, blocks, files, and reserved tokens, while handling errors and file validation.

Constructors

Properties

options: ParserOptions

Parser configuration options.

List of parsed tokens of various types.

LoopValues: { "!": number; "?": number; "&": number } = ...

Mapping of special loop symbols to their respective loop counts.

Accessors

  • get size(): number
  • The total number of parsed tokens.

    Returns number

Methods

  • Returns the original code processed by the parser.

    Returns string

    The original code string.

  • Converts the entire parsed token list to a string representation.

    Parameters

    • indent: number = 2

      The indentation level for nested tokens (default is 2 spaces).

    Returns string

    A string representing the parsed tokens.

  • Parses a string of code into a Parser instance with parsed tokens.

    Parameters

    • code: string

      The input code to parse.

    • Optionaloptions: Partial<ParserOptions>

      Optional parser configuration.

    Returns Parser

    A new instance of the Parser with parsed tokens.

  • Parses a loop count from a token containing loop symbols. Supports special syntax with [ and ] brackets.

    Parameters

    • token: string

      The token containing loop symbols (&, ?, !).

    Returns number

    The total loop count based on the token.