rantlr-core 0.1.0

Rantlr core: .gr lexer, parser, linter, and in-process runtime
Documentation
// Rantlr (.gr) — keyword-driven, TypeScript/Rust-flavoured syntax
grammar Calculator;

// Built-in lexical type (no hand-rolled [0-9]+ needed)
token Num = Number;

// Whitespace is skipped after matching
token Ws = " " -> skip;
token Tab = "\t" -> skip;
token Nl = "\n" -> skip;

rule prog {
    expr
}

rule expr {
    term
    repeat {
        match "+" | "-"
        term
    }
}

rule term {
    factor
    repeat {
        match "*" | "/"
        factor
    }
}

rule factor {
    match Num | ("(" expr ")")
}

// Embedded tests — validated when the grammar is compiled
example "precedence" {
    input: `1+2*3`
    expect: expr
}

example "grouping" {
    input: `(1+2)*3`
    expect: expr
}