bobzhang/peg/ast does not have a README file

    ClassPart

    One part of a character class: a single code unit or an inclusive range.

    Location

    A span of the input, optionally tagged with the source file name.

    Pos

    using @bobzhang/peg/runtime { type Pos }

    A position in the input: a UTF-16 code-unit offset plus 1-based line and column (lines are only broken by \n, as in PEG.js).

    Comment

    pub(all) struct Comment {
    text : String
    multiline : Bool
    location :
    Location

    } derive(
    Debug
    )

    A comment collected with the extractComments parser option.
    impl ToJson for Comment

    Comment::to_json

    fn Comment::to_json(self : Comment) -> Json

    Grammar

    pub(all) struct Grammar {
    initializer : Initializer?
    rules : Array[Rule]
    comments : Array[(Int, Comment)]?
    location :
    Location

    literals : Array[String]?
    classes : Array[
    ClassConst
    ]?
    expectations : Array[
    Expectation
    ]?
    functions : Array[
    FunctionConst
    ]?
    code : String?
    } derive(
    Debug
    )

    The root of a parsed grammar. Code-generation passes fill in the constant tables and code.
    impl ToJson for Grammar

    Grammar::always_consumes_on_success

    fn Grammar::always_consumes_on_success(self : Grammar, node : Node) -> Bool

    Whether node always consumes input when it succeeds (Grammar.js).

    Grammar::find_rule

    fn Grammar::find_rule(self : Grammar, name : String) -> Rule?

    Grammar::index_of_rule

    fn Grammar::index_of_rule(self : Grammar, name : String) -> Int

    Index of the rule named name, or -1.

    Grammar::new

    fn Grammar::new(initializer : Initializer?, rules : Array[Rule], comments : Array[(Int, Comment)]?, location :
    Location
    ) -> Grammar

    Grammar::to_json

    fn Grammar::to_json(self : Grammar) -> Json

    Initializer

    pub(all) struct Initializer {
    code : String
    location :
    Location

    } derive(
    Debug
    )

    An { ... } initializer block at the top of a grammar.

    Initializer::to_json

    fn Initializer::to_json(self : Initializer) -> Json

    Kind

    pub(all) enum Kind {
    Named(name~ : String, Node)
    Choice(Array[Node])
    Action(Node, code~ : String)
    Sequence(Array[Node])
    Labeled(label~ : String?, pick~ : Bool, Node)
    Text(Node)
    SimpleAnd(Node)
    SimpleNot(Node)
    Optional(Node)
    ZeroOrMore(Node)
    OneOrMore(Node)
    Group(Node)
    SemanticAnd(code~ : String)
    SemanticNot(code~ : String)
    RuleRef(name~ : String)
    Literal(value~ : String, ignore_case~ : Bool)
    Class(parts~ : Array[
    ClassPart
    ], inverted~ : Bool, ignore_case~ : Bool)
    Any
    } derive(
    Debug
    )

    The kind-specific payload of an expression node.

    Node

    pub(all) struct Node {
    kind : Kind
    location :
    Location

    match_result : Int?
    } derive(
    Debug
    )

    An expression node. Passes may rewrite kind in place and annotate match_result (the match property of PEG.js nodes: -1 never matches, 0 may match, 1 always matches).
    impl ToJson for Node

    Node::children

    fn Node::children(self : Node) -> ArrayView[Node]

    Direct child expressions, in order.

    Node::expression

    fn Node::expression(self : Node) -> Node?

    The single child expression of wrapper nodes (expression in PEG.js).

    Node::new

    fn Node::new(kind : Kind, location :
    Location
    ) -> Node

    Node::to_json

    fn Node::to_json(self : Node) -> Json

    Node::type_name

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

    The PEG.js type string of this node.

    Rule

    pub(all) struct Rule {
    name : String
    expression : Node
    location :
    Location

    report_failures : Bool?
    match_result : Int?
    bytecode : Array[Int]?
    } derive(
    Debug
    )

    A grammar rule. Passes annotate report_failures, match_result and bytecode.
    impl ToJson for Rule

    Rule::new

    fn Rule::new(name : String, expression : Node, location :
    Location
    ) -> Rule

    Rule::to_json

    fn Rule::to_json(self : Rule) -> Json

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io