#parser #logic #mindustry

mlog_parse

A parser for mindustry logic

3 unstable releases

Uses new Rust 2024

0.2.0 Jan 10, 2026
0.1.1 Jan 3, 2026
0.1.0 Jan 3, 2026

#2 in #mindustry

MIT license

89KB
1.5K SLoC

mlog_parse

A parser for mindustry logic.

Credits


lib.rs:

A parser for mindustry logic.

NOTE: All minor version updates are breaking changes for now (the API isn't stabilised)

Examples

const SRC: &str = r#"
    loop_start:
        op add i i 1
        write i cell1 0
    jump loop_start lessThan i 5
"#;

let lexer: Lexer<Statement> = Lexer::new(SRC);

let instructions: Vec<_> = lexer
    .map(|x| x.unwrap())
    .collect();

assert_eq!(
    instructions,
    vec![
        Statement::OpAdd{
            a: Argument::Variable("i"),
            b: Argument::Number(1.),
            c: "i"
        },
        Statement::Write {
            value: Argument::Variable("i"),
            cell:  Argument::Variable("cell1"),
            index: Argument::Number(0.)
        },
        Statement::Jump {
           index: 0,
           cond: ConditionOp::LessThan,
           lhs: Some(Argument::Variable("i")),
           rhs: Some(Argument::Number(5.)),
        }
    ]
);

Dependencies

~2.1–3.5MB
~67K SLoC