Sign in

    moonrockz/diagrams/ebnf does not have a README file

    Grammar

    pub struct Grammar {
    id : String
    items : ReadOnlyArray[Item]
    nodes : ReadOnlyArray[Node]
    title : String?
    accessibility_title : String?
    accessibility_description : String?
    } derive(Eq,
    Debug
    )

    One immutable grammar diagram. It describes a grammar; it does not parse input.

    Grammar::equal

    fn Grammar::equal(Grammar, Grammar) -> Bool

    Grammar::new

    fn Grammar::new(id : String, items : ArrayView[Item], nodes : ArrayView[Node], title? : String, accessibility_title? : String, accessibility_description? : String) -> Grammar

    Grammar::not_equal

    fn Grammar::not_equal(x : Grammar, y : Grammar) -> Bool

    Grammar::rules

    fn Grammar::rules(self : Grammar) -> Array[Rule]

    The rules of the grammar in source order.

    Grammar::to_repr

    Index

    pub struct Index {
    grammar : Grammar
    order : ReadOnlyArray[String]
    // private fields
    }

    A validated grammar with constant-time lookups. Each expression node has exactly one owner. References are symbolic and never expand definitions.

    Index::build

    fn Index::build(grammar : Grammar, limits? : Limits) -> IndexResult

    Validate identities, ownership, references, counts and limits without recursion. Unresolved and ambiguous names are warnings.

    Index::depth

    fn Index::depth(self : Index, id : String) -> Int?

    Index::node

    fn Index::node(self : Index, id : String) -> Node?

    Index::owner

    fn Index::owner(self : Index, id : String) -> String?

    The identity of the rule that owns an expression node.

    Index::parent

    fn Index::parent(self : Index, id : String) -> String?

    The parent node of an expression node. The body root has no parent.

    Index::resolution

    fn Index::resolution(self : Index, id : String) -> Resolution?

    The resolution of a reference node, or None for another node kind.

    Index::rule

    fn Index::rule(self : Index, id : String) -> Rule?

    IndexResult

    pub struct IndexResult {
    index : Index?
    diagnostics : ReadOnlyArray[
    Diagnostic
    ]
    }

    Item

    pub(all) enum Item {
    Rule(Rule)
    Note(String, String)
    } derive(Eq,
    Debug
    )

    One ordered grammar statement: a rule or a free-standing note.

    Item::equal

    fn Item::equal(Item, Item) -> Bool

    Item::not_equal

    fn Item::not_equal(x : Item, y : Item) -> Bool

    Item::to_repr

    Kind

    pub(all) enum Kind {
    Terminal(String, Quote)
    Reference(String, String?)
    Special(String)
    Empty
    Sequence(ReadOnlyArray[String])
    Choice(ReadOnlyArray[String])
    Optional(String)
    ZeroOrMore(String)
    OneOrMore(String)
    Count(String, String)
    Exclusion(String, String)
    } derive(Eq,
    Debug
    )

    The meaning of one grammar expression node. Composite kinds name their children by node identity, so a grammar is a flat, bounded arena.

    Kind::equal

    fn Kind::equal(Kind, Kind) -> Bool

    Kind::not_equal

    fn Kind::not_equal(x : Kind, y : Kind) -> Bool

    Kind::to_repr

    Limits

    pub struct Limits {
    nodes : Int
    depth : Int
    work : Int
    } derive(Eq,
    Debug
    )

    Explicit bounds for grammar validation and indexing.

    Limits::equal

    fn Limits::equal(Limits, Limits) -> Bool

    Limits::new

    fn Limits::new(nodes? : Int, depth? : Int, work? : Int) -> Limits

    Limits::not_equal

    fn Limits::not_equal(x : Limits, y : Limits) -> Bool

    Limits::to_repr

    Node

    pub struct Node {
    id : String
    kind : Kind
    notes_above : ReadOnlyArray[String]
    notes_below : ReadOnlyArray[String]
    source :
    Span
    ?
    } derive(Eq,
    Debug
    )

    Node::children

    fn Node::children(self : Node) -> ReadOnlyArray[String]

    The children of node in drawing order. An exclusion lists its left term first and its excluded term second.

    Node::equal

    fn Node::equal(Node, Node) -> Bool

    Node::is_leaf

    fn Node::is_leaf(self : Node) -> Bool

    Terminals, references, special sequences and empty terms are leaves.

    Node::label

    fn Node::label(self : Node) -> String

    Node::new

    fn Node::new(id : String, kind : Kind, notes_above? : ArrayView[String], notes_below? : ArrayView[String], source? :
    Span
    ) -> Node

    Node::not_equal

    fn Node::not_equal(x : Node, y : Node) -> Bool

    Node::to_repr

    Quote

    pub(all) enum Quote {
    Double
    Single
    } derive(Eq,
    Debug
    )

    The quote character of a terminal string.

    Quote::equal

    fn Quote::equal(Quote, Quote) -> Bool

    Quote::not_equal

    fn Quote::not_equal(x : Quote, y : Quote) -> Bool

    Quote::to_repr

    Resolution

    pub(all) enum Resolution {
    Resolved(String)
    Unresolved
    Ambiguous(ReadOnlyArray[String])
    } derive(Eq,
    Debug
    )

    How a reference resolved. Unresolved and ambiguous names stay renderable.

    Resolution::equal

    fn Resolution::equal(Resolution, Resolution) -> Bool

    Resolution::not_equal

    fn Resolution::not_equal(x : Resolution, y : Resolution) -> Bool

    Rule

    pub struct Rule {
    id : String
    name : String
    body : String?
    note_above : String?
    note_below : String?
    source :
    Span
    ?
    } derive(Eq,
    Debug
    )

    One named rule. A rule without a body is an empty definition.

    Rule::equal

    fn Rule::equal(Rule, Rule) -> Bool

    Rule::new

    fn Rule::new(id : String, name : String, body? : String, note_above? : String, note_below? : String, source? :
    Span
    ) -> Rule

    Rule::not_equal

    fn Rule::not_equal(x : Rule, y : Rule) -> Bool

    Rule::to_repr

    diagnostic_codes

    let diagnostic_codes : ReadOnlyArray[String]

    The stable diagnostic codes of grammar validation.

    validate

    fn validate(grammar : Grammar, limits? : Limits) -> ReadOnlyArray[
    Diagnostic
    ]

    Validate a constructed grammar. Errors prevent rendering; warnings for unresolved or ambiguous names do not.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io