lkolbly / ripstop

Apache License 2.0
0 stars 0 forks source link

Improve parse error messages #21

Open lkolbly opened 2 years ago

lkolbly commented 2 years ago

Currently, parse errors give fairly cryptic messages. For example, this:

module blinky() -> (bit led) {
    led = led[t-1];
}

throws an error like:

thread 'main' panicked at 'Parse failed!: Error { variant: ParsingError { positives: [variable_type, indexed_variable], negatives: [] }, location: Pos(183), line_col: Pos((9, 5)), path: None, line: "    led = ~led[t-1];␊", continued_line: None }', src/parse.rs:29:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

which is difficult for the user to read. Ideally, we would say something like "at this location, expected a X or a Y."

lkolbly commented 1 year ago

Additionally, we should try using e.g. this crate: https://github.com/zesterer/ariadne to format error messages.