Interface ILexer

Hierarchy

  • ILexer

Implemented by

Properties

debug: boolean
logger: Logger

Accessors

Methods

  • Clone a new lexer with the same state and definitions. If options.debug/logger is omitted, the new lexer will inherit from the original one.

    Parameters

    • Optional options: {
          debug?: boolean;
          logger?: Logger;
      }
      • Optional debug?: boolean
      • Optional logger?: Logger

    Returns ILexer

  • Clone a new lexer with the same definitions, without states. If options.debug/logger is omitted, the new lexer will inherit from the original one.

    Parameters

    • Optional options: {
          debug?: boolean;
          logger?: Logger;
      }
      • Optional debug?: boolean
      • Optional logger?: Logger

    Returns ILexer

  • Get how many chars in each line.

    Returns readonly number[]

  • Get line number (starts from 1) and column number (starts from 1) from the index (starts from 0) of the input string.

    Parameters

    • index: number

    Returns {
        column: number;
        line: number;
    }

    • column: number
    • line: number
  • Get all defined token types.

    Returns Set<string>

  • Try to retrieve a token. If nothing match, return null.

    You can provide expect to limit the token type/content to be accepted.

    Parameters

    • Optional input: string | Readonly<{
          expect?: Readonly<{
              text?: string;
              type?: string;
          }>;
          input?: string;
      }>

    Returns null | Token

  • Try to retrieve a token list exhaustively.

    Parameters

    • Optional input: string | {
          input?: string;
          stopOnError?: boolean;
      }

    Returns Token[]

  • Take n chars from the rest of buffer and update state. This is useful when you have external logic to handle the token.

    Parameters

    • Optional n: number

    Returns string

  • Remove ignored chars from the start of the rest of buffer.

    Parameters

    • Optional input: string

    Returns ILexer

Generated using TypeDoc