lumesh 0.18.2

a lighting shell ⚡ bash alternative
Documentation
use lumesh::tokenize;

fn main() {
    let inputs = vec![
        "#foo",
        "# foo",
        "a.b",
        "a..b",
        "foo.bar()",
        ".5",
        "./path",
        "-42",
        "x-1",
        "--flag",
        "a - b",
        "foo!",
        "!x",
        "a!=b",
        "arr[0]",
        "func(arg)",
        "(a + b)",
        "a@0",
        "@decorator",
        "mod::func",
        "foo_bar",
        "foo _ bar",
        "%{",
        "x?y",
        "??",
        "a+b",
        "+flag",
        "1.5",
        "1.",
        "a===b",
        "a==b",
        "a!==b",
        "a!~:b",
        "a?.b",
        "...",
        "..=",
        "a...b",
        "a..=b",
        "x->y",
        "x=>y",
        "x&&y",
        "x||y",
        "x|>",
        "x<<y",
        "x>>y",
        "x+=1",
        "x-=1",
        "x:=1",
        "x~:y",
        "x?=y",
        "x?+y",
        "x?~y",
        "x??y",
        "x?:y",
        "x?!y",
        "x?>y",
        "x^y",
        "x*y",
        "x/y",
        "x%y",
        "x|y",
        "x<y",
        "x>y",
        "x=y",
        "x:y",
        "x,y",
        "x;z",
        "x!y",
        "x.y",
        "x[y",
        "x{y",
        "let x = 1",
        "fn foo()",
        "true",
        "false",
        "none",
        "_",
        "foo _ bar",
        "a..b",
        "..10",
        "10..",
        "10..20",
        "H{}",
        "M{}",
        "S{}",
        "$var",
        "$",
        r"'hello world'",
        r"`template ${x}`",
        r"g'/pattern/'",
        r"t'2024-01-01'",
        "a+b-c*d/e",
        "x[0][1]",
        "f()(g)",
        "!true",
        "!!x",
        "x!!!",
        "a..=b..=c",
        "x...y",
        "a.b.c.d",
        "x.y[z].w",
        "f(x).y(z)",
        "-x-y",
        "x--y",
        "a - -b",
        "x!=y!=z",
        "a! b!",
        "x::y::z",
        "a::b c",
        "x@@y",
        "@@x",
        "a%b%c",
        "x%%y",
        "x^y^z",
        "x||y&&z",
        "x|>y|>z",
        "x<<y>>z",
        "> ls -la",
        "ls -la --color=auto",
        "echo hello; echo world",
        "a\nb",
        "a b\nc d",
        "fn foo() { let x = 1 }",
        "match x { 1 => 'a', _ => 'b' }",
        "for i in 1..10 { print(i) }",
        "if true { 1 } else { 2 }",
        "while x { break }",
        "loop { continue }",
        "export let x = 1",
        "alias foo = bar",
        "del x",
        "use module",
        "set x = 1",
    ];

    for input in inputs {
        println!("=== INPUT: {:?} ===", input);
        let (tokens, diags) = tokenize(input);
        for tok in &tokens {
            println!("  {:?}", tok);
        }
        for diag in &diags {
            println!("  DIAG: {:?}", diag);
        }
        if tokens.is_empty() {
            println!("  (no tokens)");
        }
        println!();
    }
}