gcode-toolkit

    Typed G-code parsing, validation, rewriting, and offline toolpath review for MoonBit

    gcode
    cnc
    toolpath
    parser
    geometry
    Download zip
    Author
    Version
    0.3.1
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    59

    No dependencies

    #MoonBit G-code Toolkit

    cjcjwe/gcode-toolkit is a typed, offline G-code parsing, validation, rewriting, and toolpath review library for MoonBit. It accepts caller-provided text and produces lexical documents, modal state traces, controller-profile diagnostics, motion data, deterministic rewrites, and batch evidence reports.

    #Scope

    Version 0.3.0 provides two compatible parsing layers. parse_gcode produces typed motions for the supported G0-G3 subset. parse_gcode_document preserves physical blocks, words, comments, source locations, sequence numbers, and RepRap-style checksums without pretending that every word is a motion.

    The modal interpreter tracks G17/G18/G19, G20/G21, G90/G91, G92, M82/M83, feed, spindle, coolant, tool, and normalized machine position. Validation profiles define explicit generic CNC, common GRBL, and common Marlin subsets with command, workspace, sequence, checksum, feed, spindle, tool, arc, and extrusion checks. Program indexing supports command queries, word ranges, sequence gaps, tool sections, and line-aligned structural differences.

    The rewrite pipeline performs canonical lexical rendering, sequence removal or renumbering, checksum removal/recalculation/addition, comment and blank-line policies, feed/spindle scaling, tool mapping, and per-line change evidence. Bounded batch review combines parsing, indexing, validation, rewriting, outcome classification, and a stable manifest.

    #Use

    moon add cjcjwe/gcode-toolkit

    import {
    "cjcjwe/gcode-toolkit" @gcode,
    }

    let program = @gcode.parse_gcode("G1 X10 Y5 F1200\nG0 Z2").unwrap()
    let statistics = @gcode.analyze(program)
    println(@gcode.render_summary(program))
    println(statistics.cutting_distance())

    The package is pure MoonBit and does not read files, access a network, connect to CNC hardware, or send machine commands. The named GRBL and Marlin profiles are documented common subsets, not complete controller emulations. Canned cycles, cutter compensation, controller macros, hardware scheduling, and universal dialect compatibility remain future work.

    #Examples

    moon run cmd/main moon run examples/document moon run examples/validation moon run examples/rewrite moon run examples/batch

    #Verification

    moon fmt --check moon info moon check --deny-warn moon build moon test moon run cmd/main moon run examples/document moon run examples/validation moon run examples/rewrite moon run examples/batch powershell -ExecutionPolicy Bypass -File scripts/source-audit.ps1

    The project is released under Apache-2.0.

    ArcGeometry

    pub struct ArcGeometry {
    center_x_value : Double
    center_y_value : Double
    radius_value : Double
    chord_value : Double
    clockwise_value : Bool
    } derive(Eq,
    Debug
    )

    ArcGeometry::center_x

    fn ArcGeometry::center_x(self : ArcGeometry) -> Double

    ArcGeometry::center_y

    fn ArcGeometry::center_y(self : ArcGeometry) -> Double

    ArcGeometry::chord

    fn ArcGeometry::chord(self : ArcGeometry) -> Double

    ArcGeometry::clockwise

    fn ArcGeometry::clockwise(self : ArcGeometry) -> Bool

    ArcGeometry::radius

    fn ArcGeometry::radius(self : ArcGeometry) -> Double

    BlankLineRewriteMode

    pub(all) enum BlankLineRewriteMode {
    PreserveBlankLines
    DropBlankLines
    } derive(Eq,
    Debug
    )

    BlockDifference

    pub struct BlockDifference {
    kind_value : BlockDifferenceKind
    line_value : Int
    left_value : String?
    right_value : String?
    } derive(Eq,
    Debug
    )

    BlockDifference::kind

    BlockDifference::left

    fn BlockDifference::left(self : BlockDifference) -> String?

    BlockDifference::line

    fn BlockDifference::line(self : BlockDifference) -> Int

    BlockDifference::right

    fn BlockDifference::right(self : BlockDifference) -> String?

    BlockDifferenceKind

    pub(all) enum BlockDifferenceKind {
    AddedBlock
    RemovedBlock
    ChangedBlock
    } derive(Eq,
    Debug
    )

    BlockScan

    type BlockScan derive(Eq,
    Debug
    )

    BlockWord

    pub struct BlockWord {
    letter_value : Int
    value_value : Double
    raw_value : String
    column_value : Int
    } derive(Eq,
    Debug
    )

    A lexical word preserved from a G-code block.

    BlockWord::column

    fn BlockWord::column(self : BlockWord) -> Int

    BlockWord::letter

    fn BlockWord::letter(self : BlockWord) -> Int

    BlockWord::letter_text

    fn BlockWord::letter_text(self : BlockWord) -> String

    BlockWord::raw

    fn BlockWord::raw(self : BlockWord) -> String

    BlockWord::value

    fn BlockWord::value(self : BlockWord) -> Double

    Bounds

    pub struct Bounds {
    min_value : Position
    max_value : Position
    } derive(Eq,
    Debug
    )

    Bounds::max

    fn Bounds::max(self : Bounds) -> Position

    Bounds::min

    fn Bounds::min(self : Bounds) -> Position

    ChecksumRewriteMode

    pub(all) enum ChecksumRewriteMode {
    RemoveChecksums
    PreserveChecksumValues
    RecomputeExistingChecksums
    AddChecksums
    } derive(Eq,
    Debug
    )

    CommandOccurrence

    pub struct CommandOccurrence {
    letter_value : Int
    code_value : Double
    line_value : Int
    column_value : Int
    } derive(Eq,
    Debug
    )

    CommandOccurrence::code

    fn CommandOccurrence::code(self : CommandOccurrence) -> Double

    CommandOccurrence::column

    fn CommandOccurrence::column(self : CommandOccurrence) -> Int

    CommandOccurrence::letter

    fn CommandOccurrence::letter(self : CommandOccurrence) -> Int

    CommandOccurrence::line

    fn CommandOccurrence::line(self : CommandOccurrence) -> Int

    CommentRewriteMode

    pub(all) enum CommentRewriteMode {
    PreserveComments
    DropComments
    } derive(Eq,
    Debug
    )

    ControllerFamily

    pub(all) enum ControllerFamily {
    GenericCnc
    GrblCompatible
    MarlinCompatible
    } derive(Eq,
    Debug
    )

    CoolantMode

    pub(all) enum CoolantMode {
    CoolantOff
    MistCoolant
    FloodCoolant
    } derive(Eq,
    Debug
    )

    CoordinateMode

    pub(all) enum CoordinateMode {
    AbsoluteCoordinates
    RelativeCoordinates
    } derive(Eq,
    Debug
    )

    CoordinateTransform

    pub struct CoordinateTransform {
    offset_x_value : Double
    offset_y_value : Double
    offset_z_value : Double
    scale_value : Double
    } derive(Eq,
    Debug
    )

    CoordinateTransform::new

    fn CoordinateTransform::new(offset_x : Double, offset_y : Double, offset_z : Double, scale : Double) -> Result[CoordinateTransform, GCodeError]

    Diagnostic

    pub struct Diagnostic {
    severity_value : DiagnosticSeverity
    code_value : String
    message_value : String
    line_value : Int
    } derive(Eq,
    Debug
    )

    Diagnostic::code

    fn Diagnostic::code(self : Diagnostic) -> String

    Diagnostic::line

    fn Diagnostic::line(self : Diagnostic) -> Int

    Diagnostic::message

    fn Diagnostic::message(self : Diagnostic) -> String

    Diagnostic::severity

    fn Diagnostic::severity(self : Diagnostic) -> DiagnosticSeverity

    DiagnosticSeverity

    pub(all) enum DiagnosticSeverity {
    Error
    Warning
    } derive(Eq,
    Debug
    )

    DocumentDifference

    pub struct DocumentDifference {
    differences_value : Array[BlockDifference]
    equal_blocks_value : Int
    left_lines_value : Int
    right_lines_value : Int
    } derive(Eq,
    Debug
    )

    DocumentDifference::differences

    DocumentDifference::equal_blocks

    fn DocumentDifference::equal_blocks(self : DocumentDifference) -> Int

    DocumentDifference::is_equal

    fn DocumentDifference::is_equal(self : DocumentDifference) -> Bool

    DocumentRewritePlan

    pub struct DocumentRewritePlan {
    comment_mode_value : CommentRewriteMode
    blank_mode_value : BlankLineRewriteMode
    sequence_mode_value : SequenceRewriteMode
    checksum_mode_value : ChecksumRewriteMode
    feed_multiplier_value : Double
    spindle_multiplier_value : Double
    tool_mappings_value : Array[ToolMapping]
    include_final_newline_value : Bool
    } derive(Eq,
    Debug
    )

    DocumentRewritePlan::canonical

    DocumentRewritePlan::with_blank_lines

    DocumentRewritePlan::with_checksums

    DocumentRewritePlan::with_comments

    DocumentRewritePlan::with_feed_multiplier

    fn DocumentRewritePlan::with_feed_multiplier(self : DocumentRewritePlan, multiplier : Double) -> Result[DocumentRewritePlan, GCodeError]

    DocumentRewritePlan::with_final_newline

    fn DocumentRewritePlan::with_final_newline(self : DocumentRewritePlan, enabled : Bool) -> DocumentRewritePlan

    DocumentRewritePlan::with_sequences

    DocumentRewritePlan::with_spindle_multiplier

    fn DocumentRewritePlan::with_spindle_multiplier(self : DocumentRewritePlan, multiplier : Double) -> Result[DocumentRewritePlan, GCodeError]

    DocumentRewritePlan::with_tool_mapping

    fn DocumentRewritePlan::with_tool_mapping(self : DocumentRewritePlan, from : Int, to : Int) -> Result[DocumentRewritePlan, GCodeError]

    DocumentRewriteResult

    pub struct DocumentRewriteResult {
    text_value : String
    records_value : Array[RewriteLineRecord]
    changed_lines_value : Int
    omitted_lines_value : Int
    diagnostics_value : Array[Diagnostic]
    } derive(Eq,
    Debug
    )

    DocumentRewriteResult::changed_lines

    fn DocumentRewriteResult::changed_lines(self : DocumentRewriteResult) -> Int

    DocumentRewriteResult::diagnostics

    DocumentRewriteResult::omitted_lines

    fn DocumentRewriteResult::omitted_lines(self : DocumentRewriteResult) -> Int

    DocumentRewriteResult::records

    DocumentRewriteResult::text

    fn DocumentRewriteResult::text(self : DocumentRewriteResult) -> String

    DocumentValidation

    pub struct DocumentValidation {
    profile_value : ValidationProfile
    diagnostics_value : Array[Diagnostic]
    summary_value : ValidationSummary
    state_trace_value : StateTraceReport
    } derive(Eq,
    Debug
    )

    DocumentValidation::accepted

    fn DocumentValidation::accepted(self : DocumentValidation) -> Bool

    DocumentValidation::diagnostics

    DocumentValidation::profile

    DocumentValidation::state_trace

    DocumentValidation::summary

    ExtrusionMode

    pub(all) enum ExtrusionMode {
    AbsoluteExtrusion
    RelativeExtrusion
    } derive(Eq,
    Debug
    )

    GCodeAudit

    pub struct GCodeAudit {
    program_value : GCodeProgram
    statistics_value : MotionStatistics
    diagnostics_value : Array[Diagnostic]
    canonical_text_value : String
    } derive(Eq,
    Debug
    )

    GCodeAudit::accepted

    fn GCodeAudit::accepted(self : GCodeAudit) -> Bool

    GCodeAudit::canonical_text

    fn GCodeAudit::canonical_text(self : GCodeAudit) -> String

    GCodeAudit::diagnostics

    fn GCodeAudit::diagnostics(self : GCodeAudit) -> Array[Diagnostic]

    GCodeAudit::program

    fn GCodeAudit::program(self : GCodeAudit) -> GCodeProgram

    GCodeAudit::statistics

    fn GCodeAudit::statistics(self : GCodeAudit) -> MotionStatistics

    GCodeBatchItem

    pub struct GCodeBatchItem {
    label_value : String
    program_value : GCodeProgram?
    error_value : GCodeError?
    } derive(Eq,
    Debug
    )

    Parse several independent programs while preserving each input label.

    GCodeBatchItem::accepted

    fn GCodeBatchItem::accepted(self : GCodeBatchItem) -> Bool

    GCodeBatchItem::error

    GCodeBatchItem::label

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

    GCodeBatchItem::program

    GCodeBlock

    pub struct GCodeBlock {
    source_value : String
    body_value : String
    source_line_value : Int
    sequence_value : Int?
    words_value : Array[BlockWord]
    comments_value : Array[String]
    checksum_value : Int?
    computed_checksum_value : Int?
    } derive(Eq,
    Debug
    )

    One source block with comments and lexical metadata preserved.

    GCodeBlock::body

    fn GCodeBlock::body(self : GCodeBlock) -> String

    GCodeBlock::checksum

    fn GCodeBlock::checksum(self : GCodeBlock) -> Int?

    GCodeBlock::checksum_valid

    fn GCodeBlock::checksum_valid(self : GCodeBlock) -> Bool

    GCodeBlock::comments

    fn GCodeBlock::comments(self : GCodeBlock) -> Array[String]

    GCodeBlock::computed_checksum

    fn GCodeBlock::computed_checksum(self : GCodeBlock) -> Int?

    GCodeBlock::duplicate_letters

    fn GCodeBlock::duplicate_letters(self : GCodeBlock) -> Array[Int]

    GCodeBlock::first_value

    fn GCodeBlock::first_value(self : GCodeBlock, letter : Int) -> Double?

    GCodeBlock::has_letter

    fn GCodeBlock::has_letter(self : GCodeBlock, letter : Int) -> Bool

    GCodeBlock::is_comment_only

    fn GCodeBlock::is_comment_only(self : GCodeBlock) -> Bool

    GCodeBlock::sequence

    fn GCodeBlock::sequence(self : GCodeBlock) -> Int?

    GCodeBlock::source

    fn GCodeBlock::source(self : GCodeBlock) -> String

    GCodeBlock::source_line

    fn GCodeBlock::source_line(self : GCodeBlock) -> Int

    GCodeBlock::values_for

    fn GCodeBlock::values_for(self : GCodeBlock, letter : Int) -> Array[Double]

    GCodeBlock::word_count

    fn GCodeBlock::word_count(self : GCodeBlock) -> Int

    GCodeBlock::words

    fn GCodeBlock::words(self : GCodeBlock) -> Array[BlockWord]

    GCodeDocument

    pub struct GCodeDocument {
    blocks_value : Array[GCodeBlock]
    physical_lines_value : Int
    } derive(Eq,
    Debug
    )

    A complete lexical document. Empty physical lines are intentionally kept.

    GCodeDocument::block_count

    fn GCodeDocument::block_count(self : GCodeDocument) -> Int

    GCodeDocument::blocks

    GCodeDocument::checksum_count

    fn GCodeDocument::checksum_count(self : GCodeDocument) -> Int

    GCodeDocument::comment_count

    fn GCodeDocument::comment_count(self : GCodeDocument) -> Int

    GCodeDocument::executable_block_count

    fn GCodeDocument::executable_block_count(self : GCodeDocument) -> Int

    GCodeDocument::invalid_checksum_lines

    fn GCodeDocument::invalid_checksum_lines(self : GCodeDocument) -> Array[Int]

    GCodeDocument::physical_lines

    fn GCodeDocument::physical_lines(self : GCodeDocument) -> Int

    GCodeError

    pub struct GCodeError {
    code_value : GCodeErrorCode
    message_value : String
    location_value : SourceLocation
    } derive(Eq,
    Debug
    )

    GCodeError::code

    GCodeError::format

    fn GCodeError::format(self : GCodeError) -> String

    GCodeError::location

    fn GCodeError::location(self : GCodeError) -> SourceLocation

    GCodeError::message

    fn GCodeError::message(self : GCodeError) -> String

    GCodeErrorCode

    pub(all) enum GCodeErrorCode {
    EmptyLine
    InvalidWord
    InvalidNumber
    UnknownCommand
    InvalidArc
    } derive(Eq,
    Debug
    )

    GCodeProgram

    pub struct GCodeProgram {
    motions_value : Array[Motion]
    ignored_lines_value : Int
    } derive(Eq,
    Debug
    )

    GCodeProgram::ignored_lines

    fn GCodeProgram::ignored_lines(self : GCodeProgram) -> Int

    GCodeProgram::motion_count

    fn GCodeProgram::motion_count(self : GCodeProgram) -> Int

    GCodeProgram::motions

    fn GCodeProgram::motions(self : GCodeProgram) -> Array[Motion]

    LayerSummary

    pub struct LayerSummary {
    z_value : Double
    motion_count_value : Int
    cutting_distance_value : Double
    } derive(Eq,
    Debug
    )

    LayerSummary::cutting_distance

    fn LayerSummary::cutting_distance(self : LayerSummary) -> Double

    LayerSummary::motion_count

    fn LayerSummary::motion_count(self : LayerSummary) -> Int

    LayerSummary::z

    fn LayerSummary::z(self : LayerSummary) -> Double

    LengthUnit

    pub(all) enum LengthUnit {
    Millimeter
    Inch
    } derive(Eq,
    Debug
    )

    LetterUsage

    pub struct LetterUsage {
    letter_value : Int
    count_value : Int
    first_line_value : Int
    last_line_value : Int
    minimum_value : Double
    maximum_value : Double
    } derive(Eq,
    Debug
    )

    LetterUsage::count

    fn LetterUsage::count(self : LetterUsage) -> Int

    LetterUsage::first_line

    fn LetterUsage::first_line(self : LetterUsage) -> Int

    LetterUsage::last_line

    fn LetterUsage::last_line(self : LetterUsage) -> Int

    LetterUsage::letter

    fn LetterUsage::letter(self : LetterUsage) -> Int

    LetterUsage::maximum

    fn LetterUsage::maximum(self : LetterUsage) -> Double

    LetterUsage::minimum

    fn LetterUsage::minimum(self : LetterUsage) -> Double

    MachineState

    pub struct MachineState {
    unit_value : LengthUnit
    coordinate_mode_value : CoordinateMode
    extrusion_mode_value : ExtrusionMode
    plane_value : WorkingPlane
    motion_value : MotionKind?
    position_value : Position
    work_offset_value : Position
    feed_value : Double?
    spindle_mode_value : SpindleMode
    spindle_speed_value : Double?
    coolant_value : CoolantMode
    tool_value : Int?
    } derive(Eq,
    Debug
    )

    Deterministic machine-neutral modal state. Positions are normalized to mm.

    MachineState::coolant

    fn MachineState::coolant(self : MachineState) -> CoolantMode

    MachineState::coordinate_mode

    fn MachineState::coordinate_mode(self : MachineState) -> CoordinateMode

    MachineState::display_position

    fn MachineState::display_position(self : MachineState) -> Position

    MachineState::extrusion_mode

    fn MachineState::extrusion_mode(self : MachineState) -> ExtrusionMode

    MachineState::feed

    fn MachineState::feed(self : MachineState) -> Double?

    MachineState::initial

    fn MachineState::initial() -> MachineState

    MachineState::motion

    fn MachineState::motion(self : MachineState) -> MotionKind?

    MachineState::plane

    MachineState::position

    fn MachineState::position(self : MachineState) -> Position

    MachineState::spindle_mode

    fn MachineState::spindle_mode(self : MachineState) -> SpindleMode

    MachineState::spindle_speed

    fn MachineState::spindle_speed(self : MachineState) -> Double?

    MachineState::tool

    fn MachineState::tool(self : MachineState) -> Int?

    MachineState::unit

    MachineState::unit_scale

    fn MachineState::unit_scale(self : MachineState) -> Double

    MachineState::work_offset

    fn MachineState::work_offset(self : MachineState) -> Position

    Motion

    pub struct Motion {
    kind_value : MotionKind
    start_value : Position
    end_value : Position
    i_value : Double
    j_value : Double
    feed_value : Double?
    source_line_value : Int
    } derive(Eq,
    Debug
    )

    Motion::end

    fn Motion::end(self : Motion) -> Position

    Motion::feed

    fn Motion::feed(self : Motion) -> Double?

    Motion::i

    fn Motion::i(self : Motion) -> Double

    Motion::j

    fn Motion::j(self : Motion) -> Double

    Motion::kind

    fn Motion::kind(self : Motion) -> MotionKind

    Motion::source_line

    fn Motion::source_line(self : Motion) -> Int

    Motion::start

    fn Motion::start(self : Motion) -> Position

    MotionKind

    pub(all) enum MotionKind {
    Rapid
    Linear
    ClockwiseArc
    CounterclockwiseArc
    } derive(Eq,
    Debug
    )

    MotionStatistics

    pub struct MotionStatistics {
    rapid_count_value : Int
    linear_count_value : Int
    arc_count_value : Int
    total_distance_value : Double
    cutting_distance_value : Double
    min_feed_value : Double
    max_feed_value : Double
    } derive(Eq,
    Debug
    )

    MotionStatistics::arc_count

    fn MotionStatistics::arc_count(self : MotionStatistics) -> Int

    MotionStatistics::cutting_distance

    fn MotionStatistics::cutting_distance(self : MotionStatistics) -> Double

    MotionStatistics::linear_count

    fn MotionStatistics::linear_count(self : MotionStatistics) -> Int

    MotionStatistics::max_feed

    fn MotionStatistics::max_feed(self : MotionStatistics) -> Double

    MotionStatistics::min_feed

    fn MotionStatistics::min_feed(self : MotionStatistics) -> Double

    MotionStatistics::rapid_count

    fn MotionStatistics::rapid_count(self : MotionStatistics) -> Int

    MotionStatistics::total_distance

    fn MotionStatistics::total_distance(self : MotionStatistics) -> Double

    ParseLimits

    pub struct ParseLimits {
    max_lines_value : Int
    max_motions_value : Int
    max_words_per_line_value : Int
    } derive(Eq,
    Debug
    )

    ParseLimits::standard

    fn ParseLimits::standard() -> ParseLimits

    ParseLimits::with_max_lines

    fn ParseLimits::with_max_lines(self : ParseLimits, value : Int) -> ParseLimits

    ParseLimits::with_max_motions

    fn ParseLimits::with_max_motions(self : ParseLimits, value : Int) -> ParseLimits

    ParseLimits::with_max_words_per_line

    fn ParseLimits::with_max_words_per_line(self : ParseLimits, value : Int) -> ParseLimits

    Position

    pub struct Position {
    x_value : Double
    y_value : Double
    z_value : Double
    e_value : Double
    } derive(Eq,
    Debug
    )

    Position::e

    fn Position::e(self : Position) -> Double

    Position::new

    fn Position::new(x : Double, y : Double, z : Double, e : Double) -> Position

    Position::x

    fn Position::x(self : Position) -> Double

    Position::y

    fn Position::y(self : Position) -> Double

    Position::z

    fn Position::z(self : Position) -> Double

    ProgramIndex

    pub struct ProgramIndex {
    commands_value : Array[CommandOccurrence]
    usage_value : Array[LetterUsage]
    executable_lines_value : Array[Int]
    comment_lines_value : Array[Int]
    sequence_gaps_value : Array[SequenceGap]
    } derive(Eq,
    Debug
    )

    ProgramIndex::command_count

    fn ProgramIndex::command_count(self : ProgramIndex) -> Int

    ProgramIndex::commands

    ProgramIndex::comment_lines

    fn ProgramIndex::comment_lines(self : ProgramIndex) -> Array[Int]

    ProgramIndex::executable_lines

    fn ProgramIndex::executable_lines(self : ProgramIndex) -> Array[Int]

    ProgramIndex::find_command

    fn ProgramIndex::find_command(self : ProgramIndex, letter : Int, code : Double) -> Array[CommandOccurrence]

    ProgramIndex::sequence_gaps

    fn ProgramIndex::sequence_gaps(self : ProgramIndex) -> Array[SequenceGap]

    ProgramIndex::usage

    ProgramIndex::usage_for

    fn ProgramIndex::usage_for(self : ProgramIndex, letter : Int) -> LetterUsage?

    ReviewBatch

    pub struct ReviewBatch {
    outcomes_value : Array[ReviewOutcome]
    summary_value : ReviewBatchSummary
    } derive(Eq,
    Debug
    )

    ReviewBatch::accepted

    fn ReviewBatch::accepted(self : ReviewBatch) -> Bool

    ReviewBatch::accepted_labels

    fn ReviewBatch::accepted_labels(self : ReviewBatch) -> Array[String]

    ReviewBatch::find

    fn ReviewBatch::find(self : ReviewBatch, label : String) -> ReviewOutcome?

    ReviewBatch::manifest

    ReviewBatch::outcomes

    fn ReviewBatch::outcomes(self : ReviewBatch) -> Array[ReviewOutcome]

    ReviewBatch::parse_error_labels

    fn ReviewBatch::parse_error_labels(self : ReviewBatch) -> Array[String]

    ReviewBatch::rejected_labels

    fn ReviewBatch::rejected_labels(self : ReviewBatch) -> Array[String]

    ReviewBatch::summary

    ReviewBatchSummary

    pub struct ReviewBatchSummary {
    item_count_value : Int
    parsed_count_value : Int
    accepted_count_value : Int
    rejected_count_value : Int
    parse_error_count_value : Int
    diagnostic_error_count_value : Int
    warning_count_value : Int
    changed_line_count_value : Int
    command_count_value : Int
    } derive(Eq,
    Debug
    )

    ReviewBatchSummary::accepted_count

    fn ReviewBatchSummary::accepted_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::changed_line_count

    fn ReviewBatchSummary::changed_line_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::command_count

    fn ReviewBatchSummary::command_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::diagnostic_error_count

    fn ReviewBatchSummary::diagnostic_error_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::item_count

    fn ReviewBatchSummary::item_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::parse_error_count

    fn ReviewBatchSummary::parse_error_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::parsed_count

    fn ReviewBatchSummary::parsed_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::rejected_count

    fn ReviewBatchSummary::rejected_count(self : ReviewBatchSummary) -> Int

    ReviewBatchSummary::warning_count

    fn ReviewBatchSummary::warning_count(self : ReviewBatchSummary) -> Int

    ReviewManifestItem

    pub struct ReviewManifestItem {
    label_value : String
    parsed_value : Bool
    accepted_value : Bool
    physical_lines_value : Int
    executable_blocks_value : Int
    checked_words_value : Int
    error_count_value : Int
    warning_count_value : Int
    changed_lines_value : Int
    } derive(Eq,
    Debug
    )

    ReviewManifestItem::accepted

    fn ReviewManifestItem::accepted(self : ReviewManifestItem) -> Bool

    ReviewManifestItem::changed_lines

    fn ReviewManifestItem::changed_lines(self : ReviewManifestItem) -> Int

    ReviewManifestItem::checked_words

    fn ReviewManifestItem::checked_words(self : ReviewManifestItem) -> Int

    ReviewManifestItem::error_count

    fn ReviewManifestItem::error_count(self : ReviewManifestItem) -> Int

    ReviewManifestItem::executable_blocks

    fn ReviewManifestItem::executable_blocks(self : ReviewManifestItem) -> Int

    ReviewManifestItem::label

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

    ReviewManifestItem::parsed

    fn ReviewManifestItem::parsed(self : ReviewManifestItem) -> Bool

    ReviewManifestItem::physical_lines

    fn ReviewManifestItem::physical_lines(self : ReviewManifestItem) -> Int

    ReviewManifestItem::warning_count

    fn ReviewManifestItem::warning_count(self : ReviewManifestItem) -> Int

    ReviewOutcome

    pub struct ReviewOutcome {
    label_value : String
    document_value : GCodeDocument?
    index_value : ProgramIndex?
    validation_value : DocumentValidation?
    rewrite_value : DocumentRewriteResult?
    parse_error_value : GCodeError?
    } derive(Eq,
    Debug
    )

    ReviewOutcome::accepted

    fn ReviewOutcome::accepted(self : ReviewOutcome) -> Bool

    ReviewOutcome::changed_lines

    fn ReviewOutcome::changed_lines(self : ReviewOutcome) -> Int

    ReviewOutcome::document

    fn ReviewOutcome::document(self : ReviewOutcome) -> GCodeDocument?

    ReviewOutcome::error_count

    fn ReviewOutcome::error_count(self : ReviewOutcome) -> Int

    ReviewOutcome::index

    ReviewOutcome::label

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

    ReviewOutcome::parse_error

    fn ReviewOutcome::parse_error(self : ReviewOutcome) -> GCodeError?

    ReviewOutcome::parsed

    fn ReviewOutcome::parsed(self : ReviewOutcome) -> Bool

    ReviewOutcome::rewrite

    ReviewOutcome::validation

    ReviewOutcome::warning_count

    fn ReviewOutcome::warning_count(self : ReviewOutcome) -> Int

    ReviewRequest

    pub struct ReviewRequest {
    label_value : String
    source_value : String
    profile_value : ValidationProfile
    rewrite_plan_value : DocumentRewritePlan
    } derive(Eq,
    Debug
    )

    ReviewRequest::label

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

    ReviewRequest::new

    fn ReviewRequest::new(label : String, source : String) -> ReviewRequest

    ReviewRequest::profile

    ReviewRequest::rewrite_plan

    fn ReviewRequest::rewrite_plan(self : ReviewRequest) -> DocumentRewritePlan

    ReviewRequest::source

    fn ReviewRequest::source(self : ReviewRequest) -> String

    ReviewRequest::with_profile

    fn ReviewRequest::with_profile(self : ReviewRequest, profile : ValidationProfile) -> ReviewRequest

    ReviewRequest::with_rewrite_plan

    fn ReviewRequest::with_rewrite_plan(self : ReviewRequest, plan : DocumentRewritePlan) -> ReviewRequest

    RewriteLineRecord

    pub struct RewriteLineRecord {
    source_line_value : Int
    output_line_value : Int?
    original_value : String
    rewritten_value : String?
    changes_value : Array[String]
    } derive(Eq,
    Debug
    )

    RewriteLineRecord::changed

    fn RewriteLineRecord::changed(self : RewriteLineRecord) -> Bool

    RewriteLineRecord::changes

    fn RewriteLineRecord::changes(self : RewriteLineRecord) -> Array[String]

    RewriteLineRecord::original

    fn RewriteLineRecord::original(self : RewriteLineRecord) -> String

    RewriteLineRecord::output_line

    fn RewriteLineRecord::output_line(self : RewriteLineRecord) -> Int?

    RewriteLineRecord::rewritten

    fn RewriteLineRecord::rewritten(self : RewriteLineRecord) -> String?

    RewriteLineRecord::source_line

    fn RewriteLineRecord::source_line(self : RewriteLineRecord) -> Int

    SafetyPolicy

    pub struct SafetyPolicy {
    max_x_value : Double
    max_y_value : Double
    max_z_value : Double
    reject_negative_feed : Bool
    } derive(Eq,
    Debug
    )

    SafetyPolicy::standard

    fn SafetyPolicy::standard() -> SafetyPolicy

    SafetyPolicy::with_workspace

    fn SafetyPolicy::with_workspace(self : SafetyPolicy, x : Double, y : Double, z : Double) -> SafetyPolicy

    SequenceGap

    pub struct SequenceGap {
    previous_value : Int
    current_value : Int
    line_value : Int
    missing_value : Int
    } derive(Eq,
    Debug
    )

    SequenceGap::current

    fn SequenceGap::current(self : SequenceGap) -> Int

    SequenceGap::line

    fn SequenceGap::line(self : SequenceGap) -> Int

    SequenceGap::missing

    fn SequenceGap::missing(self : SequenceGap) -> Int

    SequenceGap::previous

    fn SequenceGap::previous(self : SequenceGap) -> Int

    SequenceRewriteMode

    pub(all) enum SequenceRewriteMode {
    KeepSequences
    RemoveSequences
    RenumberSequences(Int, Int)
    } derive(Eq,
    Debug
    )

    SourceLocation

    pub struct SourceLocation {
    line_value : Int
    column_value : Int
    } derive(Eq,
    Debug
    )

    SourceLocation::column

    fn SourceLocation::column(self : SourceLocation) -> Int

    SourceLocation::line

    fn SourceLocation::line(self : SourceLocation) -> Int

    SourceLocation::new

    fn SourceLocation::new(line : Int, column : Int) -> SourceLocation

    SpindleMode

    pub(all) enum SpindleMode {
    SpindleOff
    SpindleClockwise
    SpindleCounterclockwise
    } derive(Eq,
    Debug
    )

    StateSnapshot

    pub struct StateSnapshot {
    line_value : Int
    before_value : MachineState
    after_value : MachineState
    labels_value : Array[String]
    } derive(Eq,
    Debug
    )

    StateSnapshot::after

    StateSnapshot::before

    StateSnapshot::changed

    fn StateSnapshot::changed(self : StateSnapshot) -> Bool

    StateSnapshot::labels

    fn StateSnapshot::labels(self : StateSnapshot) -> Array[String]

    StateSnapshot::line

    fn StateSnapshot::line(self : StateSnapshot) -> Int

    StateTraceReport

    pub struct StateTraceReport {
    snapshots_value : Array[StateSnapshot]
    diagnostics_value : Array[Diagnostic]
    final_state_value : MachineState
    } derive(Eq,
    Debug
    )

    StateTraceReport::changed_blocks

    fn StateTraceReport::changed_blocks(self : StateTraceReport) -> Int

    StateTraceReport::diagnostics

    StateTraceReport::final_state

    StateTraceReport::snapshots

    ToolMapping

    pub struct ToolMapping {
    from_value : Int
    to_value : Int
    } derive(Eq,
    Debug
    )

    ToolMapping::from

    fn ToolMapping::from(self : ToolMapping) -> Int

    ToolMapping::to

    fn ToolMapping::to(self : ToolMapping) -> Int

    ToolSection

    pub struct ToolSection {
    ordinal_value : Int
    tool_value : Int?
    start_line_value : Int
    end_line_value : Int
    blocks_value : Array[GCodeBlock]
    } derive(Eq,
    Debug
    )

    ToolSection::blocks

    fn ToolSection::blocks(self : ToolSection) -> Array[GCodeBlock]

    ToolSection::document

    fn ToolSection::document(self : ToolSection) -> GCodeDocument

    ToolSection::end_line

    fn ToolSection::end_line(self : ToolSection) -> Int

    ToolSection::ordinal

    fn ToolSection::ordinal(self : ToolSection) -> Int

    ToolSection::start_line

    fn ToolSection::start_line(self : ToolSection) -> Int

    ToolSection::tool

    fn ToolSection::tool(self : ToolSection) -> Int?

    ToolpathMetrics

    pub struct ToolpathMetrics {
    segment_count_value : Int
    rapid_distance_value : Double
    cutting_distance_value : Double
    estimated_seconds_value : Double
    feedless_cutting_count_value : Int
    endpoint_revisit_count_value : Int
    } derive(Eq,
    Debug
    )

    ToolpathMetrics::cutting_distance

    fn ToolpathMetrics::cutting_distance(self : ToolpathMetrics) -> Double

    ToolpathMetrics::endpoint_revisit_count

    fn ToolpathMetrics::endpoint_revisit_count(self : ToolpathMetrics) -> Int

    ToolpathMetrics::estimated_seconds

    fn ToolpathMetrics::estimated_seconds(self : ToolpathMetrics) -> Double

    ToolpathMetrics::feedless_cutting_count

    fn ToolpathMetrics::feedless_cutting_count(self : ToolpathMetrics) -> Int

    ToolpathMetrics::rapid_distance

    fn ToolpathMetrics::rapid_distance(self : ToolpathMetrics) -> Double

    ToolpathMetrics::segment_count

    fn ToolpathMetrics::segment_count(self : ToolpathMetrics) -> Int

    ToolpathTrace

    pub struct ToolpathTrace {
    points_value : Array[TracePoint]
    total_distance_value : Double
    } derive(Eq,
    Debug
    )

    ToolpathTrace::at

    fn ToolpathTrace::at(self : ToolpathTrace, index : Int) -> TracePoint?

    ToolpathTrace::length

    fn ToolpathTrace::length(self : ToolpathTrace) -> Int

    ToolpathTrace::points

    ToolpathTrace::total_distance

    fn ToolpathTrace::total_distance(self : ToolpathTrace) -> Double

    TracePoint

    pub struct TracePoint {
    index_value : Int
    line_value : Int
    position_value : Position
    cumulative_distance_value : Double
    feed_value : Double?
    kind_value : MotionKind
    } derive(Eq,
    Debug
    )

    TracePoint::cumulative_distance

    fn TracePoint::cumulative_distance(self : TracePoint) -> Double

    TracePoint::feed

    fn TracePoint::feed(self : TracePoint) -> Double?

    TracePoint::index

    fn TracePoint::index(self : TracePoint) -> Int

    TracePoint::kind

    fn TracePoint::kind(self : TracePoint) -> MotionKind

    TracePoint::line

    fn TracePoint::line(self : TracePoint) -> Int

    TracePoint::position

    fn TracePoint::position(self : TracePoint) -> Position

    ValidationProfile

    pub struct ValidationProfile {
    name_value : String
    family_value : ControllerFamily
    allowed_g_codes_value : Array[Double]
    allowed_m_codes_value : Array[Int]
    allowed_letters_value : Array[Int]
    max_x_value : Double
    max_y_value : Double
    max_z_value : Double
    max_feed_value : Double
    max_spindle_value : Double
    max_tool_value : Int
    require_sequence_value : Bool
    require_checksum_value : Bool
    require_monotonic_sequence_value : Bool
    allow_extrusion_value : Bool
    allow_arcs_value : Bool
    } derive(Eq,
    Debug
    )

    ValidationProfile::family

    ValidationProfile::generic_cnc

    ValidationProfile::grbl

    ValidationProfile::marlin

    ValidationProfile::name

    fn ValidationProfile::name(self : ValidationProfile) -> String

    ValidationProfile::with_arcs_allowed

    fn ValidationProfile::with_arcs_allowed(self : ValidationProfile, allowed : Bool) -> ValidationProfile

    ValidationProfile::with_checksum_required

    fn ValidationProfile::with_checksum_required(self : ValidationProfile, required : Bool) -> ValidationProfile

    ValidationProfile::with_max_feed

    fn ValidationProfile::with_max_feed(self : ValidationProfile, max_feed : Double) -> ValidationProfile

    ValidationProfile::with_max_spindle

    fn ValidationProfile::with_max_spindle(self : ValidationProfile, max_spindle : Double) -> ValidationProfile

    ValidationProfile::with_sequence_policy

    fn ValidationProfile::with_sequence_policy(self : ValidationProfile, required : Bool, monotonic : Bool) -> ValidationProfile

    ValidationProfile::with_workspace

    fn ValidationProfile::with_workspace(self : ValidationProfile, max_x : Double, max_y : Double, max_z : Double) -> ValidationProfile

    ValidationSummary

    pub struct ValidationSummary {
    physical_lines_value : Int
    executable_blocks_value : Int
    checked_words_value : Int
    error_count_value : Int
    warning_count_value : Int
    first_sequence_value : Int?
    last_sequence_value : Int?
    } derive(Eq,
    Debug
    )

    ValidationSummary::checked_words

    fn ValidationSummary::checked_words(self : ValidationSummary) -> Int

    ValidationSummary::error_count

    fn ValidationSummary::error_count(self : ValidationSummary) -> Int

    ValidationSummary::executable_blocks

    fn ValidationSummary::executable_blocks(self : ValidationSummary) -> Int

    ValidationSummary::first_sequence

    fn ValidationSummary::first_sequence(self : ValidationSummary) -> Int?

    ValidationSummary::last_sequence

    fn ValidationSummary::last_sequence(self : ValidationSummary) -> Int?

    ValidationSummary::physical_lines

    fn ValidationSummary::physical_lines(self : ValidationSummary) -> Int

    ValidationSummary::warning_count

    fn ValidationSummary::warning_count(self : ValidationSummary) -> Int

    WorkingPlane

    pub(all) enum WorkingPlane {
    XYPlane
    XZPlane
    YZPlane
    } derive(Eq,
    Debug
    )

    analyze

    fn analyze(program : GCodeProgram) -> MotionStatistics

    Summarize motion classes, distances, and observed feed-rate range.

    arc_chord_sum

    fn arc_chord_sum(program : GCodeProgram) -> Double

    arc_geometry

    fn arc_geometry(motion : Motion) -> Result[ArcGeometry, GCodeError]

    Derive stable geometric facts for an I/J offset arc.

    arc_path_length

    fn arc_path_length(motion : Motion) -> Result[Double, GCodeError]

    Calculate the swept XY arc length, including simultaneous Z travel.

    audit_gcode

    fn audit_gcode(text : String, policy? : SafetyPolicy) -> Result[GCodeAudit, GCodeError]

    Run parsing, geometry analysis, safety checks, and canonical serialization together.

    bounds

    fn bounds(program : GCodeProgram) -> Bounds

    canonical_equal

    fn canonical_equal(left : GCodeProgram, right : GCodeProgram) -> Bool

    compare_documents

    fn compare_documents(left : GCodeDocument, right : GCodeDocument, ignore_comments? : Bool) -> DocumentDifference

    diagnose

    fn diagnose(program : GCodeProgram, policy? : SafetyPolicy) -> Array[Diagnostic]

    Check workspace bounds and unsafe feed values without connecting to a machine.

    index_document

    fn index_document(document : GCodeDocument, expected_sequence_step? : Int) -> ProgramIndex

    interpret_modal_state

    fn interpret_modal_state(document : GCodeDocument, initial? : MachineState) -> StateTraceReport

    Interpret common machine-neutral modal state without controlling hardware.

    measure

    fn measure(program : GCodeProgram) -> ToolpathMetrics

    Estimate duration from feed rates; units are minutes per distance unit.

    parse_gcode

    fn parse_gcode(text : String, max_lines? : Int) -> Result[GCodeProgram, GCodeError]

    parse_gcode_batch

    fn parse_gcode_batch(inputs : Array[(String, String)], max_items? : Int) -> Array[GCodeBatchItem]

    parse_gcode_document

    fn parse_gcode_document(text : String, max_lines? : Int) -> Result[GCodeDocument, GCodeError]

    Parse source blocks without interpreting machine motion.

    parse_gcode_with_limits

    fn parse_gcode_with_limits(text : String, limits : ParseLimits) -> Result[GCodeProgram, GCodeError]

    program_equal

    fn program_equal(left : GCodeProgram, right : GCodeProgram) -> Bool

    render_audit_json

    fn render_audit_json(audit : GCodeAudit) -> String

    render_audit_text

    fn render_audit_text(audit : GCodeAudit) -> String

    render_block_structure

    fn render_block_structure(document : GCodeDocument) -> String

    render_diagnostics

    fn render_diagnostics(diagnostics : Array[Diagnostic]) -> String

    render_document_difference

    fn render_document_difference(difference : DocumentDifference) -> String

    render_metrics

    fn render_metrics(metrics : ToolpathMetrics) -> String

    render_program_index

    fn render_program_index(index : ProgramIndex) -> String

    render_review_batch

    fn render_review_batch(batch : ReviewBatch) -> String

    render_review_manifest

    fn render_review_manifest(batch : ReviewBatch) -> String

    render_review_outcome

    fn render_review_outcome(outcome : ReviewOutcome) -> String

    render_rewrite_report

    fn render_rewrite_report(result : DocumentRewriteResult) -> String

    render_state_trace

    fn render_state_trace(report : StateTraceReport) -> String

    render_summary

    fn render_summary(program : GCodeProgram) -> String

    render_trace_text

    fn render_trace_text(trace_value : ToolpathTrace) -> String

    render_validation

    fn render_validation(validation : DocumentValidation) -> String

    review_batch

    fn review_batch(requests : Array[ReviewRequest], max_items? : Int, max_lines_per_item? : Int) -> Result[ReviewBatch, GCodeError]

    review_source

    fn review_source(request : ReviewRequest, max_lines? : Int) -> ReviewOutcome

    rewrite_document

    fn rewrite_document(document : GCodeDocument, plan? : DocumentRewritePlan) -> Result[DocumentRewriteResult, GCodeError]

    select_motions

    fn select_motions(program : GCodeProgram, predicate : (Motion) -> Bool) -> GCodeProgram

    serialize_gcode

    fn serialize_gcode(program : GCodeProgram) -> String

    Deterministically render the supported motion subset for review and fixtures.

    split_by_tool

    fn split_by_tool(document : GCodeDocument) -> Array[ToolSection]

    summarize_layers

    fn summarize_layers(program : GCodeProgram, tolerance? : Double) -> Array[LayerSummary]

    Group motions by endpoint Z while retaining first-seen order.

    total_distance

    fn total_distance(program : GCodeProgram) -> Double

    trace

    fn trace(program : GCodeProgram) -> ToolpathTrace

    Build an immutable trace suitable for previews and downstream reports.

    trace_at_distance

    fn trace_at_distance(trace_value : ToolpathTrace, distance : Double) -> TracePoint?

    transform_program

    fn transform_program(program : GCodeProgram, transform : CoordinateTransform) -> GCodeProgram

    validate_document

    fn validate_document(document : GCodeDocument, profile? : ValidationProfile) -> DocumentValidation