Package grammarkdown

    grammarkdown has an API that can be consumed:

    var grammarkdown = require("grammarkdown")
      , Grammar = grammarkdown.Grammar
      , EmitFormat = grammarkdown.EmitFormat
    
    var filename = "...";
    var source = "...";
    var output;
    
    // parse
    var grammar = new Grammar(
      [filename],
      { format: EmitFormat.markdown },
      function () { return source; });
    
    // bind (optional, bind happens automatically during check)
    grammar.bindSync();
    
    // check (optional, check happens automatically during emit)
    grammar.checkSync();
    
    // emit
    grammar.emitSync(undefined, function (file, text) { output = text; });
    
    console.log(output);
    

    Classes

    Argument

    ArgumentList

    AssertionBase

    Binder

    BindingTable

    ButNotSymbol

    The `but not` operator allows you to reference a *Nonterminal* on the left, excluding some part of that production.

    A but not B
    

    Checker

    CommentTriviaBase

    Constraints

    Represents a set of constraints for a right-hand-side of a Production.

    Production[A] ::
      [+A] A
      [~A] B
    

    CoreAsyncHost

    A Host is a user-provided service that indicates how various Grammarkdown services can interact with a file system. The CoreAsyncHost class provides the API surface that Grammarkdown uses to interact with a host that is able to access the file system asynchronously.

    Define

    DiagnosticMessages

    EcmarkupEmitter

    Emitter

    EmptyAssertion

    Represents the empty assertion, which matches exactly zero tokens.

    [empty]
    

    Grammar

    The primary service used to interact with one or more Grammarkdown SourceFiles.

    GrammarkdownEmitter

    HtmlCloseTagTrivia

    Represents an HTML close-tag trivia token:

    Production ::
      <ins>Inserted</ins>
      <del>Deleted</del>
    

    HtmlEmitter

    HtmlOpenTagTrivia

    Represents an HTML open-tag trivia token:

    Production ::
      <ins>Inserted</ins>
      <del>Deleted</del>
    

    HtmlTriviaBase

    Identifier

    Represents an identifier such as a Production or Parameter.

    Import

    InvalidAssertion

    InvalidSymbol

    LexicalGoalAssertion

    Represens a lexical-goal assertion which verifies that current lexical goal is the supplied *Nonterminal*.

    [lexical goal Module]
    

    LexicalSymbolBase

    Line

    LineMap

    LineOffsetMap

    LinkReference

    LookaheadAssertion

    Represents a lookahead assertion, which is a zero-width assertion that only matches if the next token is in the requested set.

    [lookahead ∉ { `class`, `let` }]
    

    MarkdownEmitter

    MetaElementBase

    MultiLineCommentTrivia

    Represents a multi-line comment trivia token.

    Node

    NodeAsyncHost

    NodeNavigator

    Navigates the syntax-tree of a SourceFile.

    NodeVisitor

    Nonterminal

    Represents a non-terminal reference to another Production.

    IdentifierReference[~Yield, ~Await]
    

    NoSymbolHereAssertion

    Represents a no Symbol here assertion, which disallows the provided symbol.

    [no LineTerminator here]
    

    NullDiagnosticMessages

    NumberLiteral

    Represents a number literal (used by @line)

    @line 500
    Production :: Nonterminal
    

    OneOfList

    OneOfSymbol

    Represents a set of symbols used to restrict a but not operator.

    A but not one of `a` or `b`
    

    OptionalSymbolBase

    Parameter

    ParameterList

    Parser

    PlaceholderSymbol

    Represents a placeholder symbol (@) used in some grammars.

    PrimarySymbolBase

    Production

    ProductionBodyBase

    Prose

    Represents a section of Prose, which indicates handling of syntax outside the scope of the Grammarkdown parser.

    > This is a section of Prose with |Nonterminals| and `terminals`
    

    ProseAssertion

    Represents an assertion containing Prose, which indicates handling of syntax outside the scope of the Grammarkdown parser.

    HexDigits [> but only if MV of |HexDigits| > 0x10FFFF]
    

    ProseFragmentLiteral

    Resolver

    RightHandSide

    RightHandSideList

    Scanner

    SingleLineCommentTrivia

    Represent a single-line comment trivia token.

    // comment
    

    SourceElementBase

    SourceFile

    StringAsyncHost

    An implementation of a CoreAsyncHost to simplify creating a host for a single file.

    StringLiteral

    Represents a single- or double-quoted string literal (used by @import and @line)

    @import "file"
    

    StringWriter

    Symbol

    SymbolSet

    Represents a set of symbols in a lookahead assertion.

    [lookahead ∈ { `a`, `b` }]
    

    SymbolSpan

    SymbolTable

    Terminal

    Represents a terminal token in the grammar.

    `yield` `*`?
    

    TerminalLiteral

    Represents a terminal token in the grammar.

    `yield`
    

    Token

    Represents a token such as a keyword or operator.

    TriviaBase

    UnicodeCharacterLiteral

    Represents a Unicode character literal in one of two forms:

    <TAB>
    U+0000
    

    UnicodeCharacterRange

    Represents a range of unicode characters.

    U+0000 through U+001F
    

    Interfaces

    CompilerOptions

    Options that control the behavior of the compiler.

    CoreAsyncHostOptions

    Options used to configure a CoreAsyncHost.

    Diagnostic

    DiagnosticInfo

    NodeAsyncHostOptions

    Position

    Range

    TextChange

    TextContent

    TextRange

    Enums

    CharacterCodes

    EmitFormat

    Indicates the emit output format.

    NewLineKind

    Indicates the token to use for line terminators during emit.

    SymbolKind

    SyntaxKind

    Functions

    forEachChild(node, cbNode)

    Declaration
    export declare function forEachChild<T>(node: Node | undefined, cbNode: (node: Node) => T | undefined): T | undefined;
    Type Parameters
    T

    Parameters
    node
    Node | undefined

    cbNode
    (node: Node) => T | undefined

    Returns
    T | undefined

    formatList(tokens)

    Declaration
    export declare function formatList(tokens: (SyntaxKind | string)[]): string;
    Parameters
    tokens
    (SyntaxKind | string)[]

    Returns
    string

    formatString(format, args)

    Declaration
    export declare function formatString(format: string, args?: any[]): string;
    Parameters
    format
    string

    args
    any[]

    Returns
    string

    formatString(format, args)

    Declaration
    export declare function formatString(format: string, ...args: any[]): string;
    Parameters
    format
    string

    args
    any[]

    Returns
    string

    getDefaultOptions()

    Gets the default options for the compiler.

    Declaration
    export declare function getDefaultOptions(): CompilerOptions;
    Returns
    CompilerOptions

    isAssertionKind(kind)

    Declaration
    export declare function isAssertionKind(kind: SyntaxKind): kind is AssertionKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is AssertionKind

    isCommentTriviaKind(kind)

    Declaration
    export declare function isCommentTriviaKind(kind: SyntaxKind): kind is CommentTriviaKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is CommentTriviaKind

    isHtmlTriviaKind(kind)

    Declaration
    export declare function isHtmlTriviaKind(kind: SyntaxKind): kind is HtmlTriviaKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is HtmlTriviaKind

    isKeywordKind(kind)

    Declaration
    export declare function isKeywordKind(kind: SyntaxKind): kind is KeywordKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is KeywordKind

    isLexicalSymbolKind(kind)

    Declaration
    export declare function isLexicalSymbolKind(kind: SyntaxKind): kind is LexicalSymbolKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is LexicalSymbolKind

    isMetaElementKind(kind)

    Declaration
    export declare function isMetaElementKind(kind: SyntaxKind): kind is MetaElementKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is MetaElementKind

    isOptionalSymbolKind(kind)

    Declaration
    export declare function isOptionalSymbolKind(kind: SyntaxKind): kind is OptionalSymbolKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is OptionalSymbolKind

    isPrimarySymbolKind(kind)

    Declaration
    export declare function isPrimarySymbolKind(kind: SyntaxKind): kind is PrimarySymbolKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is PrimarySymbolKind

    isProductionBodyKind(kind)

    Declaration
    export declare function isProductionBodyKind(kind: SyntaxKind): kind is ProductionBodyKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is ProductionBodyKind

    isProseFragmentKind(kind)

    Declaration
    export declare function isProseFragmentKind(kind: SyntaxKind): kind is ProseFragmentKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is ProseFragmentKind

    isProseFragmentLiteralKind(kind)

    Declaration
    export declare function isProseFragmentLiteralKind(kind: SyntaxKind): kind is ProseFragmentLiteralKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is ProseFragmentLiteralKind

    isPunctuationKind(kind)

    Declaration
    export declare function isPunctuationKind(kind: SyntaxKind): kind is PunctuationKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is PunctuationKind

    isSourceElementKind(kind)

    Declaration
    export declare function isSourceElementKind(kind: SyntaxKind): kind is SourceElementKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is SourceElementKind

    isTextContentKind(kind)

    Declaration
    export declare function isTextContentKind(kind: SyntaxKind): kind is TextContentKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is TextContentKind

    isTokenKind(kind)

    Declaration
    export declare function isTokenKind(kind: SyntaxKind): kind is TokenKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is TokenKind

    isTriviaKind(kind)

    Declaration
    export declare function isTriviaKind(kind: SyntaxKind): kind is TriviaKind;
    Parameters
    kind
    SyntaxKind

    Returns
    kind is TriviaKind

    scanHtmlTrivia(text, pos, end)

    Declaration
    export declare function scanHtmlTrivia(text: string, pos: number, end: number): HtmlTrivia[] | undefined;
    Parameters
    text
    string

    pos
    number

    end
    number

    Returns
    HtmlTrivia[] | undefined

    skipTrivia(text, pos, end, htmlTrivia, commentTrivia)

    Declaration
    export declare function skipTrivia(text: string, pos: number, end: number, htmlTrivia?: HtmlTrivia[], commentTrivia?: CommentTrivia[]): number;
    Parameters
    text
    string

    pos
    number

    end
    number

    htmlTrivia
    HtmlTrivia[]

    commentTrivia
    CommentTrivia[]

    Returns
    number

    stringToToken(text)

    Declaration
    export declare function stringToToken(text: string): SyntaxKind | undefined;
    Parameters
    text
    string

    Returns
    SyntaxKind | undefined

    tokenToString(kind, quoted)

    Declaration
    export declare function tokenToString(kind: SyntaxKind | string, quoted?: boolean): string;
    Parameters
    kind
    SyntaxKind | string

    quoted
    boolean

    Returns
    string

    Variables

    Diagnostics

    Declaration
    Diagnostics: {
        _0_or_1_: Diagnostic;
        Constant_expected: Diagnostic;
        _0_expected: Diagnostic;
        Unexpected_token_0_: Diagnostic;
        Invalid_character: Diagnostic;
        Unterminated_string_literal: Diagnostic;
        Invalid_escape_sequence: Diagnostic;
        Digit_expected: Diagnostic;
        Production_expected: Diagnostic;
        Unterminated_identifier_literal: Diagnostic;
        Obsolete_0_: Diagnostic;
        HTML_trivia_not_allowed_here: Diagnostic;
        Cannot_find_name_0_: Diagnostic;
        Duplicate_identifier_0_: Diagnostic;
        Duplicate_terminal_0_: Diagnostic;
        Argument_0_cannot_be_specified_multiple_times: Diagnostic;
        Production_0_does_not_have_a_parameter_named_1_: Diagnostic;
        Production_0_is_missing_parameter_1_All_definitions_of_production_0_must_specify_the_same_formal_parameters: Diagnostic;
        There_is_no_argument_given_for_parameter_0_: Diagnostic;
        Parameter_0_is_unused: Diagnostic;
    }

    Type Aliases

    ArgumentOperatorKind

    Declaration
    export declare type ArgumentOperatorKind = SyntaxKind.QuestionToken | SyntaxKind.PlusToken | SyntaxKind.TildeToken;

    Assertion

    Declaration
    export declare type Assertion = EmptyAssertion | LookaheadAssertion | LexicalGoalAssertion | NoSymbolHereAssertion | ProseAssertion | InvalidAssertion;

    AssertionKind

    Declaration
    export declare type AssertionKind = SyntaxKind.EmptyAssertion | SyntaxKind.LookaheadAssertion | SyntaxKind.LexicalGoalAssertion | SyntaxKind.NoSymbolHereAssertion | SyntaxKind.ProseAssertion | SyntaxKind.InvalidAssertion;

    BooleanKind

    Declaration
    export declare type BooleanKind = SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword;

    CommentTrivia

    Declaration
    export declare type CommentTrivia = SingleLineCommentTrivia | MultiLineCommentTrivia;

    CommentTriviaKind

    Declaration
    export declare type CommentTriviaKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia;

    Declaration

    Declaration
    export declare type Declaration = SourceFile | Production | Parameter;

    HtmlTrivia

    Declaration
    export declare type HtmlTrivia = HtmlOpenTagTrivia | HtmlCloseTagTrivia;

    HtmlTriviaKind

    Declaration
    export declare type HtmlTriviaKind = SyntaxKind.HtmlOpenTagTrivia | SyntaxKind.HtmlCloseTagTrivia;

    KeywordKind

    Declaration
    export declare type KeywordKind = SyntaxKind.ButKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DefineKeyword | SyntaxKind.EmptyKeyword | SyntaxKind.FalseKeyword | SyntaxKind.GoalKeyword | SyntaxKind.HereKeyword | SyntaxKind.ImportKeyword | SyntaxKind.LexicalKeyword | SyntaxKind.LineKeyword | SyntaxKind.LookaheadKeyword | SyntaxKind.NoKeyword | SyntaxKind.NotKeyword | SyntaxKind.OfKeyword | SyntaxKind.OneKeyword | SyntaxKind.OrKeyword | SyntaxKind.ThroughKeyword | SyntaxKind.TrueKeyword;

    LexicalSymbol

    Declaration
    export declare type LexicalSymbol = PrimarySymbol | Assertion | PlaceholderSymbol | UnicodeCharacterRange | ButNotSymbol | Prose | OneOfSymbol | InvalidSymbol;

    LexicalSymbolKind

    Declaration
    export declare type LexicalSymbolKind = PrimarySymbolKind | AssertionKind | SyntaxKind.PlaceholderSymbol | SyntaxKind.UnicodeCharacterRange | SyntaxKind.ButNotSymbol | SyntaxKind.Prose | SyntaxKind.OneOfSymbol | SyntaxKind.InvalidSymbol;

    LookaheadOperatorKind

    Declaration
    export declare type LookaheadOperatorKind = SyntaxKind.EqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.NotEqualToToken | SyntaxKind.LessThanMinusToken | SyntaxKind.ElementOfToken | SyntaxKind.LessThanExclamationToken | SyntaxKind.NotAnElementOfToken;

    MetaElement

    Declaration
    export declare type MetaElement = Import | Define | Line;

    MetaElementKind

    Declaration
    export declare type MetaElementKind = SyntaxKind.Import | SyntaxKind.Define | SyntaxKind.Line;

    OptionalSymbol

    Declaration
    export declare type OptionalSymbol = Terminal | Nonterminal;

    OptionalSymbolKind

    Declaration
    export declare type OptionalSymbolKind = SyntaxKind.Terminal | SyntaxKind.Nonterminal;

    ParameterOperatorKind

    Declaration
    export declare type ParameterOperatorKind = SyntaxKind.PlusToken | SyntaxKind.TildeToken;

    PrimarySymbol

    Declaration
    export declare type PrimarySymbol = OptionalSymbol;

    PrimarySymbolKind

    Declaration
    export declare type PrimarySymbolKind = OptionalSymbolKind;

    ProductionBody

    Declaration
    export declare type ProductionBody = OneOfList | RightHandSide | RightHandSideList;

    ProductionBodyKind

    Declaration
    export declare type ProductionBodyKind = SyntaxKind.OneOfList | SyntaxKind.RightHandSide | SyntaxKind.RightHandSideList;

    ProductionSeperatorKind

    Declaration
    export declare type ProductionSeperatorKind = SyntaxKind.ColonToken | SyntaxKind.ColonColonToken | SyntaxKind.ColonColonColonToken;

    ProseFragment

    Declaration
    export declare type ProseFragment = ProseFragmentLiteral<ProseFragmentLiteralKind> | Terminal | Nonterminal;

    ProseFragmentKind

    Declaration
    export declare type ProseFragmentKind = ProseFragmentLiteralKind | SyntaxKind.Terminal | SyntaxKind.Nonterminal;

    ProseFragmentLiteralKind

    Declaration
    export declare type ProseFragmentLiteralKind = SyntaxKind.ProseFull | SyntaxKind.ProseHead | SyntaxKind.ProseMiddle | SyntaxKind.ProseTail;

    PunctuationKind

    Declaration
    export declare type PunctuationKind = SyntaxKind.AtToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenBracketToken | SyntaxKind.OpenBracketGreaterThanToken | SyntaxKind.CloseBracketToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.ColonToken | SyntaxKind.ColonColonToken | SyntaxKind.ColonColonColonToken | SyntaxKind.CommaToken | SyntaxKind.PlusToken | SyntaxKind.TildeToken | SyntaxKind.QuestionToken | SyntaxKind.EqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.LessThanExclamationToken | SyntaxKind.LessThanMinusToken | SyntaxKind.NotEqualToToken | SyntaxKind.ElementOfToken | SyntaxKind.NotAnElementOfToken;

    ReadFileCallback

    Asynchronously read a file from the host.

    Declaration
    export declare type ReadFileCallback = (this: void, file: string, cancelToken?: CancelToken) => PromiseLike<string | undefined> | string | undefined;

    SourceElement

    Declaration
    export declare type SourceElement = Production | MetaElement;

    SourceElementKind

    Declaration
    export declare type SourceElementKind = MetaElementKind | SyntaxKind.Production;

    TextContentKind

    Declaration
    export declare type TextContentKind = SyntaxKind.StringLiteral | SyntaxKind.NumberLiteral | SyntaxKind.TerminalLiteral | SyntaxKind.UnicodeCharacterLiteral | ProseFragmentLiteralKind | SyntaxKind.Identifier;

    TextContentNode

    Declaration
    export declare type TextContentNode = StringLiteral | NumberLiteral | Identifier | UnicodeCharacterLiteral | TerminalLiteral | ProseFragmentLiteral<ProseFragmentLiteralKind>;

    TokenKind

    Declaration
    export declare type TokenKind = SyntaxKind.EndOfFileToken | PunctuationKind | KeywordKind;

    Trivia

    Declaration
    export declare type Trivia = CommentTrivia | HtmlTrivia;

    TriviaKind

    Declaration
    export declare type TriviaKind = CommentTriviaKind | HtmlTriviaKind;

    WriteFileCallback

    Asynchronously write a file to the host.

    Declaration
    export declare type WriteFileCallback = (this: void, file: string, content: string, cancelToken?: CancelToken) => PromiseLike<void> | void;

    Namespaces

    Position

    Range

    TextChange

    • Improve this Doc
    Generated by DocFX