Conversation

thinking of using nom to write a parser for some input file. i already have a hand-written parser which works great, but it's hard to iterate on while i'm figuring out the format. also, i hope that using a purpose built parsing library can provide better general error handling, without requiring a lot more code to deal with special cases in the hand-written parser.

is nom good?

3
0
0

@ma3ke try logos if you just need a lexer

1
0
0
@ma3ke I have not tried the new version yet, so I can only talk about like 2 years ago. Had to write a parser for a homegrown binary format and it was quite nice at least compared to the old parser. It can be a bit confusing at least the way the errors used to work. So at least for binary formats I think it'd good, I have not really used it to non binary format yet tbh.
0
0
1

@ma3ke also if its well formatted binary file I like binrw.. what are you parsing ? đź‘€

1
0
0

@pinkforest it’s a plain text input file for a computational biochemistry application. I’ll post about it more this week as I’m working on it :)

0
0
0

@ma3ke have heard positive things about it. for the zip crate hand-written allows for SIMD and other logic which is hard to achieve in a more general framework (i want to address this for text parsing but binary parsing is different). if it's not the whole purpose of the codebase a generated parser seems far more appropriate. wonder if @jsbarretto has thoughts on nom or binary parsing frameworks

1
0
0

@hipsterelectron @ma3ke Nom is good! Winnow also, and faster in most benchmarks. My own chumsky can certainly be made to do binary parsing, but it's not the primary focus. That said, neither of the first 2 are massively adept at error handling, but it depends on what you're after!

Parser libs work best when the grammar/format you're parsing is tree-like & mostly context-free/locally contextual. Most, image/audio file formats are *not* like that, so a parser lib wouldn't be a great option there.

1
0
0

@jsbarretto @hipsterelectron

Thanks for the suggestions. Excited to check them out.

I’m currently writing a parser for a plain text input file format for bentopy, a piece of scientific software. Still figuring out the config language to be parsed, so I value composability of different lexer and parser elements. And performance is not _as_ relevant because the input files are relatively straightforward.

For binary formats, I have always done hand-written parsers (e.g., molly) because the reason I’m writing the reader is to squeeze some last droplet of performance out through some weird trick doctors hate.

1
0
0

@ma3ke @hipsterelectron That sounds like a suitable application for my library if you wanted to kick the tires! All fine if not, of course. See what you think: https://github.com/zesterer/chumsky

2
0
0

@jsbarretto @ma3ke (i think it's a good library and i have immense difficulty with almost every parsing library)

1
0
0

@jsbarretto @ma3ke part of the issue is i believe that parsing theory is extremely nascent and the models we have available are responsible for many of the flaws rather than the implementation. i have one such theory with a basic impl but i have a grander theory for the implementation which would have been my phd thesis

1
0
0

@hipsterelectron @ma3ke I still struggle with a lot of parser theory, I'll be honest. The gap between academia and practice is often wide at the best of times, but parsing takes it to a new level.

1
0
0

@jsbarretto @ma3ke it took me a very long time to work out an implementation (two years) and it was very difficult (i love graph algorithms but they are still very hard for me). one reason i'm hopeful about the new implementation technique is because it actually somewhat sidesteps the monolithic graph solve in favor of defining an operational semantics for matchers and match actions, which i think is an important foundation. but i think it will still require The Big Solve Algorithm, and i think that will be obnoxiously hard. but i can make incremental progress!

1
0
0

@hipsterelectron @ma3ke What would you say is the big headline idea it introduces? (Apologies @ma3ke if you're not interested in this, happy to remove you from the mentions if so!)

1
0
0

@jsbarretto @hipsterelectron

Omg very here for parser talk!! ( It’s one of my fave ways to nerdsnipe d@nny )

0
0
0

@jsbarretto @hipsterelectron

This looks so good. Good chance I’ll try it tomorrow or later this week. Will keep you in the loop on my progress :)

0
0
0