Skip to main content
Module

x/ohm_js/index.d.ts>Grammar

A library and language for building parsers, interpreters, compilers, etc.
Go to Latest
interface Grammar
import { type Grammar } from "https://deno.land/x/ohm_js@v17.4.0/index.d.ts";

An Ohm Grammar.

Properties

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

Methods

isBuiltIn(): boolean

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

match(input: string, startRule?: string): MatchResult

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.

matcher(): Matcher

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

trace(input: string, startRule?: string): Object

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

createSemantics(): Semantics

Create a new Semantics object for this Grammar.

extendSemantics(superSemantics: Semantics): 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.