mastodon.online is one of the many independent Mastodon servers you can use to participate in the fediverse.
A newer server operated by the Mastodon gGmbH non-profit

Server stats:

10K
active users

#chumsky

0 posts0 participants0 posts today

To the #Rust #rustlang community: I once started to write a #compiler / #parser with #nom #crate. However I had some struggles with it of how to provide **multiple** errors with line+column indicators for a parsed context.
Now I read a tiny bit about #syn and #chumsky 👀
Are they the right crates for me? Are there others?
I do not parse rust-code, but a completely custom language (similar to pugjs)

(Boost for reach 🙏)

Sometimes, when programming in #Rust, I'm wondering whether there is a little Ferris in my computer whispering to all those 0's and 1's to behave correctly. :ferris:

Otherwise I can't describe the following experience:
1. Rewrite parts of #parsing a programming language from #nom to #chumsky (the parts that are most interleaved with each other => indirect recursion over multiple non-terminals!).
2. Run all affected tests
3. See all of them pass _on the first try!_

1/2

Continued thread

So what should this all tell you? It should tell you that:
- #Rust enables fearless prototyping, refactoring and maintenance of software
- you shouldn't be afraid of stepping into the unknown
- despite seeming very scary at first, #chumsky is more approachable than you might think - thank you to chumsky contributors for such an amazing crate!

10/11

Many people say that #Rust is very hard to #prototype with or to #refactor. This couldn't be further from the truth! It is the exact opposite!

Let me share with you one of the most profound experiences I had with #RustLang on a casual sunday - a thread 🧵

I'm currently rewriting my #transpiler from #nom to #chumsky and until now everything has turned out great so far, until I've hit the following road block:
Implementing parsers by using #parser functions that have indirect #recursion.

1/11

The #Rust #parser combinator experience:

1. Writing multiple parser combinator functions ✅
2. The most "higher up" parser fails ❌
3. Investigate reason 🔍
4. Find out it's a _whitespace_ char that has been parsed too eagerly 💡
5. Fix eagerly parsed whitespace 🔧
6. All tests pass ✅
7. Rinse and repeat ➰

In all seriousness: 95% of errors I have are due to me parsing whitespace too eagerly (this is good!).

I'm using #chumsky, btw (beautifully designed parser combinator crate!).

Continued thread

Sometimes, in order to stay flexible and fit, you need to do some (type) gymnastics 🤸

Slowly getting the hang of #chumsky #parser combinator #crate 🤓

One concept (among others!) I haven't learned yet, but _will_ run into, is #recursion in chumsky. I know, there are good docs on it - it's just something I haven't gotten to yet.

All in all, I'm very happy with chumsky so far. Kudos to its maintainers! 🙂 🎩

Currently in the process of rewriting my #transpiler from #nom v4.2 to #chumsky v1.0.0-alpha.6 🤓

It is a lot of fun so far, but I have to say these type signatures are _wild_!😄

I'm still struggling with it far more than I'd like, but I guess it is just a matter of time until intuition kicks in and it will become more and more natural.

Exciting project ahead!🙂

I'm even able to parse string literals _with escape sequences_ - something I haven't even achieved with nom!

Uh, ohhh... I think it's time for me to migrate away from #nom v4.2 😮

Yeah, I know, I've procrastinated on this a lot. This will probably be a lot of work and "slow me down" for a bit. 😪 On the upside, though: I can correct all my mistakes along the way (like having spans).

I'll probably migrate to #chumsky, but #winnow also looks really nice. 🙂

chumsky:
github.com/zesterer/chumsky

winnow:
github.com/winnow-rs/winnow

winnow - Making parsing a breeze (by epage and contributors):

github.com/winnow-rs/winnow

winnow is a parser combinator library written in Rust that started as a fork of #nom.

Not sure yet, if I should migrate from nom 4.* to #winnow or #chumsky. I really do like the good error recovery and parsing capabilities for PEGs of chumsky.🥰

Making parsing a breeze. Contribute to winnow-rs/winnow development by creating an account on GitHub.
GitHubGitHub - winnow-rs/winnow: Making parsing a breezeMaking parsing a breeze. Contribute to winnow-rs/winnow development by creating an account on GitHub.