Replies: 2 comments 1 reply
-
I can have a go at writing up some docs for this later today. Are there any particular areas that you're interested in? |
Beta Was this translation helpful? Give feedback.
-
Hoping to re-ignite this discussion on how to get useful error messages from chumsky. I am going through the tutorial. I played a bit with the first step of parsing integers. Here's a very abbreviated version of it: use chumsky::prelude::*;
#[derive(Debug)]
enum Expr {
Num(f64),
}
fn parser() -> impl Parser<char, Expr, Error = Simple<char>> {
let atom = text::int(10)
.map(|s: String| Expr::Num(s.parse().unwrap()))
.padded();
atom.then_ignore(end())
}
fn main() {
let src = "a34";
let result = parser().parse(src);
match result {
Ok(ast) => println!("expression = {:?}", ast),
Err(parse_errs) => parse_errs
.into_iter()
.for_each(|e| println!("Parse error: {e}")),
}
} The error is |
Beta Was this translation helpful? Give feedback.
-
Curious how close this documentation is to being written?
I'm writing some parsers and am getting the
EmptyErr(())
and would like to start instrumenting my parsers. I've been dinking around this morning trying to follow the patterns in the json.rs example, but I'm clearly missing some of the fundamental concepts of error handling.If a small example is helpful:
Beta Was this translation helpful? Give feedback.
All reactions