Options
All
  • Public
  • Public/Protected
  • All
Menu

parserlib

Index

Type aliases

NonterminalEnum

NonterminalEnum: {}

Type of the runtime object for an enumeration.

Type declaration

  • [enumSymbol: string]: string | number

Variables

VERSION

VERSION: "3.2.1" = "3.2.1"

Functions

compile

  • Compile a Parser from a grammar represented as a string.

    throws

    ParseError if the grammar has a syntax error

    Type parameters

    • UserNT

    Parameters

    • grammar: string

      the grammar to use

    • nonterminals: NonterminalEnum

      the runtime object of the nonterminals enum. For example, if enum Nonterminals { root, a, b, c }; then Nonterminals must be explicitly passed as this runtime parameter compile(grammar, Nonterminals, Nonterminals.root); (in addition to being implicitly used for the type parameter NT)

    • rootNonterminal: UserNT

      the desired root nonterminal in the grammar

    Returns Parser<UserNT>

    a parser for the given grammar that will start parsing at rootNonterminal.

visualizeAsHtml

  • Visualizes a parse tree as a string of HTML that can be displayed in a web browser.

    Type parameters

    • NT

      the enumeration of symbols in the parse tree's grammar

    Parameters

    Returns string

    string of HTML that shows a visualization of the parse tree

visualizeAsUrl

  • Visualizes a parse tree using a URL that can be pasted into your web browser.

    Type parameters

    • NT

      the enumeration of symbols in the parse tree's grammar

    Parameters

    Returns string

    url that shows a visualization of the parse tree

Generated using TypeDoc