TabScript - v2.0.2
    Preparing search index...

    Class Parser

    TabScript parser implementing recursive descent parsing.

    All parse* methods follow a contract:

    • Return truthy on success, falsy on failure
    • On failure, leave the state unchanged

    Plugins can modify parse* methods directly on the Parser instance.

    Index

    Constructors

    Properties

    options: Options

    Methods

    • Parse a class or interface definition.

      Parameters

      Returns boolean

      `class Foo extends Bar` or `interface IFoo` or `abstract class Base`
      
    • Parse an expression.

      Parameters

      • s: State
      • withinTag: boolean = false

      Returns boolean

      `x + 1` or `foo(bar)` or `obj.method.. arg1 arg2`
      
    • Parse function parameters.

      Parameters

      • s: State
      • isConstructor: boolean = false
      • parenthesis: boolean = false

      Returns string | boolean

      `|a, b: number, c = 3|` or `(a, b: number, c = 3)`
      
    • Parse a function definition.

      Parameters

      • s: State
      • declaration: boolean = false

      Returns boolean

      `|x| x * 2` or `async |x| await fetch(x)` or `function foo|x| x * 2`
      
    • Parse the TabScript header line. Header format: tabscript X.Y

      Parameters

      Returns boolean

    • Parse the main entry point - processes header and all statements.

      Parameters

      Returns boolean

    • Parse a class method or property.

      Parameters

      • s: State
      • typeOnly: boolean = false
      • isDerived: boolean = false

      Returns boolean

      `myMethod|x| x * 2` or `static count := 0` or `get name|| this._name`
      
    • Parse a single statement.

      Parameters

      Returns string | boolean

      `x := 5` or `if condition` or `for item: of items` or `return value`
      
    • Parse a type annotation.

      Parameters

      • s: State
      • allowFunction: boolean = true

      Returns boolean

      `number` or `string[]` or `{x: number, y: string}` or `Foo<Bar>`
      
    • Parse a variable declaration.

      Parameters

      • s: State
      • allowInit: boolean = true

      Returns boolean

      `x := 5` (const) or `x ::= 5` (let) or `x: number := 5` (with type)
      
    • Creates a token matcher regex with a descriptive name for error messages. Automatically adds the sticky (/y) flag if not present.

      This is the recommended way to create regex patterns for use with s.read(), s.accept(), s.peek(), and related methods in plugins.

      Parameters

      • regexp: RegExp

        The regular expression pattern to match tokens

      • name: string

        A descriptive name shown in error messages (e.g., "identifier", "number")

      Returns RegExp

      A new RegExp with the sticky flag and custom toString()