TOC Toolkit API - v0.1.0
    Preparing search index...

    toc-toolkit/grammars/syntax

    Reads grammar text into a syntax tree with UTF-16 spans, lowers the tree into a checked grammar through the grammar kernel, and prints checked grammars in canonical notation. Productions, semantic checks and derivation stay in grammars.

    • Two-pass grammar reading. The first pass reads every left side and collects the variable declarations. The second pass reads the right sides, splitting alternatives at the bar, and returns the first located issue. (readGrammarSyntax)
    • Longest-variable matching. Finds the longest declared variable name at each offset of a right side with a trie over UTF-16 code units. Quoted terminals, explicit variable references and the epsilon spellings take precedence in a fixed order. (readGrammarSyntax)
    • Lowering. Turns a syntax tree and a grammar kind into a checked grammar, or into the semantic issues of the kernel check. (lowerGrammarSyntax, parseGrammar)
    • Packed left sides. Warns when a context-sensitive or unrestricted grammar writes a bare name such as CB on a left side and the text spells each of its code points as a symbol elsewhere. The fix writes the symbols apart, with a symbol that a left side declares as a variable or an uppercase letter as a variable and every other symbol quoted, as in C B and "a" B. A context-free grammar gets no warning. (packedLeftSideIssues)
    • Canonical printing. Groups productions by left side, removes duplicate alternatives and quotes names that need it. Printing, parsing and printing again gives the same text. (printGrammar, printVariable)
    • Text codec. Pairs the parser and the printer for a fixed kind and budget. (grammarTextCodec)
    • Syntax dump. Prints a syntax tree as stable text. (dumpGrammarSyntax)
    • Syntax tree. Rows with a left side and alternatives of terminal and variable symbols, each with a span. (GrammarSyntaxTree, SyntaxSymbol, TerminalSymbol, VariableSymbol, AlternativeKind)
    • Tokens. The arrows, the epsilon spellings and the token kinds of the notation. (GRAMMAR_ARROWS, EPSILON_WORDS, GrammarToken)
    • Issues. Syntax issues with spans and semantic issues from lowering. (GrammarSyntaxIssue, GrammarTextIssue, PackedLeftSideIssue, GrammarSyntaxIssueCode, grammarSyntaxIssueDecoder, grammarTextIssueDecoder)