An Ohm Grammar.

interface Grammar {
    name: string;
    rules: {
        [ruleName: string]: RuleInfo;
    };
    superGrammar: Grammar;
    createSemantics(): Semantics;
    extendSemantics(superSemantics): Semantics;
    isBuiltIn(): boolean;
    match(input, startRule?): MatchResult;
    matcher(): Matcher;
    trace(input, startRule?): Object;
}

Properties

name: string
rules: {
    [ruleName: string]: RuleInfo;
}

Type declaration

superGrammar: Grammar

Methods

  • Create a new Semantics object for this Grammar.

    Returns Semantics

  • Create a new Semantics object for this Grammar that inherits all of the operations and attributes in superSemantics. This Grammar must be a descendant of the grammar associated with superSemantics.

    Parameters

    Returns Semantics

  • Return true if the grammar is a built-in grammar, otherwise false.

    Returns boolean

  • Try to match input with this grammar, returning a MatchResult. If startRule is given, it specifies the rule on which to start matching. By default, the start rule is inherited from the supergrammar, or if there is no supergrammar specified, it is the first rule in this grammar.

    Parameters

    • input: string
    • Optional startRule: string

    Returns MatchResult

  • Create a new Matcher object which supports incrementally matching this grammar against a changing input string.

    Returns Matcher

  • Like match() except returns a trace object whose toString() returns a summary of each parsing step useful for debugging.

    Parameters

    • input: string
    • Optional startRule: string

    Returns Object

Generated using TypeDoc