bobzhang/peg/bytecode does not have a README file

    ClassConst

    pub(all) struct ClassConst {
    parts : Array[
    ClassPart
    ]
    inverted : Bool
    ignore_case : Bool
    } derive(Eq,
    Debug
    )

    A character class constant (classes[i] of the abstract machine).

    ClassConst::to_json

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

    FunctionConst

    pub(all) struct FunctionConst {
    predicate : Bool
    params : Array[String]
    body : String
    } derive(Eq,
    Debug
    )

    An action, predicate or initializer code block (functions[i]). Deduplicated on (predicate, params, body), exactly as PEG.js does.

    FunctionConst::to_json

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

    Opcodes

    pub(all) struct Opcodes {
    push_empty_string : Int
    push_undefined : Int
    push_null : Int
    push_failed : Int
    push_empty_array : Int
    push_curr_pos : Int
    pop : Int
    pop_curr_pos : Int
    pop_n : Int
    nip : Int
    append : Int
    wrap : Int
    text : Int
    pluck : Int
    if_ : Int
    if_error : Int
    if_not_error : Int
    while_not_error : Int
    match_any : Int
    match_string : Int
    match_string_ic : Int
    match_class : Int
    accept_n : Int
    accept_string : Int
    expect : Int
    load_saved_pos : Int
    update_saved_pos : Int
    call : Int
    rule : Int
    silent_fails_on : Int
    silent_fails_off : Int
    expect_ns_begin : Int
    expect_ns_end : Int
    } derive(Eq,
    Debug
    )

    Bytecode instruction opcodes (lib/compiler/opcodes.js).

    A Session may carry a different numbering; generated programs record the table they were produced with.

    Program

    pub(all) struct Program {
    opcodes : Opcodes
    rules : Array[RuleCode]
    literals : Array[String]
    classes : Array[ClassConst]
    expectations : Array[
    Expectation
    ]
    functions : Array[FunctionConst]
    initializer : String?
    allowed_start_rules : Array[String]
    cache : Bool
    trace : Bool
    features :
    Features

    } derive(
    Debug
    )

    Everything the parsing machine needs: per-rule bytecode plus the constant tables it indexes. Produced by the compiler, consumed by the VM and by the code generator.

    Program::rule_index

    fn Program::rule_index(self : Program, name : String) -> Int?

    RuleCode

    pub(all) struct RuleCode {
    name : String
    bytecode : Array[Int]
    } derive(Eq,
    Debug
    )

    The compiled form of one rule.

    default_opcodes

    let default_opcodes : Opcodes

    The standard PEG.js opcode numbering.

    expectation_const_json

    fn expectation_const_json(e :
    Expectation
    ) -> Json

    Serializes an expectation constant the way generateBytecode stores it ({type: "rule", value} for named rules, value for literal text).

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io