Module

x/ohm_js/index.d.ts>Semantics

A library and language for building parsers, interpreters, compilers, etc.
Latest
interface Semantics
import { type Semantics } from "https://dotland.deno.dev/x/ohm_js@v17.1.0/index.d.ts";

A Semantics is a family of operations and/or attributes for a given grammar. Each operation/attribute has a unique name within the Semantics. A grammar may have any number of Semantics instances associated with it -- this means that the clients of a grammar (even in the same program) never have to worry about operation/attribute name clashes.

Call Signatures

(match: MatchResult): Dict

Returns a dictionary containing operations and attributes defined by this Semantics on the result of a matched grammar. Operations are no-arg functions and attributes are properties.

Methods

addOperation<T>(name: string, actionDict: ActionDict<T>): Semantics

Add a new operation named name to this Semantics, using the semantic actions contained in actionDict. It is an error if there is already an operation or attribute called name in this semantics. Returns this Semantics.

addAttribute<T>(name: string, actionDict: ActionDict<T>): Semantics

Add a new attribute named name to this Semantics, using the semantic actions contained in actionDict. It is an error if there is already an operation or attribute called name in this semantics. Returns this Semantics.

extendOperation<T>(name: string, actionDict: ActionDict<T>): Semantics

Extend the operation named name with the semantic actions contained in actionDict. name must be the name of an operation in the super semantics. Returns this Semantics.

extendAttribute<T>(name: string, actionDict: ActionDict<T>): Semantics

Extend the attribute named name with the semantic actions contained in actionDict. name must be the name of an attribute in the super semantics. Returns this Semantics.