# Which rust parser library has best error reporting?

**URL:** <https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598>\
**Category:** uncategorized\
**Created:** [March 29, 2021, 4:35pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598 "2021-03-29T16:35:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon80458984](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon80458984](https://users.rust-lang.org/u/anon80458984)\
**Post date:** [March 29, 2021, 4:35pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598/1 "2021-03-29T16:35:15Z")

</div>

Suppose:

1. you have some file you want to parse
2. you do not have an official EBNF / CFG definition
3. you are hand rolling some adhoc parser to just parse the data into AST so you can move on

Which Rust parser is best for this task? The most important feature I'm looking for is something that

1. does NOT just die with "error, invaild syntax"

but instead,

1. shows the current partial parse, what the remaining input is, where it got stuck, and what it was expecting

(this is because I'm writing the grammar in an 'error driven manner', by writing a partial grammar, looking at the error, then adding more to the grammar).

Thanks!

---

<div class="post-metadata">

**Author:** ![erelde](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/erelde/32/18926_2.png) [@erelde](https://users.rust-lang.org/u/erelde)\
**Post date:** [March 29, 2021, 4:40pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598/2 "2021-03-29T16:40:25Z")

</div>

[https://github.com/pest-parser/pest](https://github.com/pest-parser/pest)

> **[GitHub - lalrpop/lalrpop: LR(1) parser generator for Rust](https://github.com/lalrpop/lalrpop)**
>
> LR(1) parser generator for Rust. Contribute to lalrpop/lalrpop development by creating an account on GitHub.

[https://github.com/Geal/nom](https://github.com/Geal/nom)

All have their error reporting mechanism.

---

<div class="post-metadata">

**Author:** ![matklad](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/matklad/32/41370_2.png) [@matklad](https://users.rust-lang.org/u/matklad)\
**Post date:** [March 29, 2021, 4:47pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598/3 "2021-03-29T16:47:03Z")

</div>

(not a direct answer to the question)

I believe there's a conspicuous hole in the parsing tooling in a shape of a nice UX for developing parsers. I've written a bit about that [in this post](https://matklad.github.io/2018/06/06/modern-parser-generator.html#ux). Here's a short [video demo](https://www.youtube.com/watch?v=gb1MJnTcvds) of what should be possible.

---

<div class="post-metadata">

**Author:** ![anon80458984](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon80458984](https://users.rust-lang.org/u/anon80458984)\
**Post date:** [March 29, 2021, 10:45pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598/4 "2021-03-29T22:45:39Z")

</div>

@matklad : Thanks for sharing. Agreed, we need better UX for writing parsers.

This is one of the few areas Rust's compile time frustrates me. With most code, linking time is not a big deal, because "if it compiles, it probably works". With parsers however, there's this need for a tight iteration loop of writing some rules, testing it, seeing where it fails -- and Rust's linking time really slows this process down.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [June 27, 2021, 10:45pm UTC](https://users.rust-lang.org/t/which-rust-parser-library-has-best-error-reporting/57598/5 "2021-06-27T22:45:49Z")

</div>

Closed on June 27, 2021, 10:45pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
