@r47onfire/nebula - v0.0.0
    Preparing search index...

    Variable defineGrammarConst

    defineGrammar: <
        M = unknown,
        G extends GrammarEntries<G, M> = Record<string, GrammarEntry<string, M>>,
    >(
        grammar: G,
    ) => Grammar<keyof G & string, M> = id

    Purely for type checking, at runtime this is literally the identity function.

    Defines a grammar, inferring the rule names from the definition's own keys, so that rule references and parameter references can be checked at the definition site without having to write an explicit Grammar<...> annotation with all the rule names.

    A metadata type for the entries' extra fields can be given explicitly as the first type argument; it defaults to unknown, which allows no extra fields.

    Type Declaration

      • <
            M = unknown,
            G extends GrammarEntries<G, M> = Record<string, GrammarEntry<string, M>>,
        >(
            grammar: G,
        ): Grammar<keyof G & string, M>
      • Type Parameters

        • M = unknown
        • G extends GrammarEntries<G, M> = Record<string, GrammarEntry<string, M>>

        Parameters

        • grammar: G

        Returns Grammar<keyof G & string, M>