metaborg / rust-scopegraphs

Scope Graph Implementation in Rust
https://github.com/metaborg/rust-scopegraphs
MIT License
20 stars 0 forks source link

Error resilient codegen #6

Closed AZWN closed 7 months ago

AZWN commented 8 months ago

Makes the code generation more error-resilient.

Test cases like

#[test]
fn test_repeat() {
    use Alphabet::*;

    compile_regex!(type Machine<Alphabet> = A : B); // note the typo ':'

    assert!(Machine::new().accepts([A]));
    assert!(Machine::new().accepts([B]));
    assert!(!Machine::new().accepts([]));
    assert!(!Machine::new().accepts([B, A]));
    assert!(!Machine::new().accepts([A, B]));
    assert!(!Machine::new().accepts([A, A]));
}

Will now only generate 1 error (on the macro), instead of one on every reference to Machine.

jdonszelmann commented 7 months ago

Very cool