Live data from Hacker News

Show HN: Pest – Fast parser generator written in Rust

github.com

21–28 of 28 posts

Re: Show HN: Pest – Fast parser generator written in Rust

#21
post #5

Shouldn't the title better by "Pest - Fast, modern parser _in_ Rust"? The current title made me think that this would be a Rust AST parser, similar to syntex.

The confusion here is because Pest is not, in fact, a parser. It's a parser generator: you can use it to generate parsers (maybe even a parser for Rust), but it is not in itself a parser.

A better title would be "Pest - Fast, modern parser generator for Rust".

One cool thing is that rather than the parser generation being a standalone tool, it's written using Rust's macro system. Normal parser generators use some sort of command line tool to generate say C code which can then be used like any other library. Here, there's no need for generated code, because the Rust macro system generates it on the fly.

Re: Show HN: Pest – Fast parser generator written in Rust

#22
I'm a bit confused by the benchmark. I looked through the benchmark code and, without really understanding what I'm looking at, the result of the nom parser looks much closer to the "pest (custom AST)" benchmark than the "pest" benchmark. The description above the image, however, primarily compares the "pest" result.

Am I misunderstanding something or is the comparison not fair?

Re: Show HN: Pest – Fast parser generator written in Rust

#23
post #17

This is a neat project! I might take a look at this if/when I get started on my dream language. :p One constructive criticism, which may be only an unpopular opinion, but I find creative operator overloading unnecessarily hard to read. And I don't think my opinion is entirely subjective since, by definition, you have to learn new semantics whereas a good function name would make the meaning obvious. Maybe this syntax…

I agree with your point. I tried my best not to sway too far off of some of syntax I've seen in other PEG projects, while also keeping it compatible with Rust's standard macros. While pest does have this constraint any longer with the new beta, changing the grammar too much would have been a nuisance for anyone who had grammars written in the older versions.

Re: Show HN: Pest – Fast parser generator written in Rust

#24
post #16

Earlier quoted context omitted.

Interesting. I'll try and find some time to read the source - am interested to see how this is implemented.

A good place to start would be in the manually written example. [1] My current plan is to try and limit the the use of memoization such that it still guarantees linear parsing, but it doesn't memoize unless necessary. [1]: https://github.com/pest-parser/pest/blob/master/pest/example...

I appreciate the link - I'm teaching myself about parsers right now and like the rest of HN I like Rust programs ;)

Re: Show HN: Pest – Fast parser generator written in Rust

#25
post #22

I'm a bit confused by the benchmark. I looked through the benchmark code and, without really understanding what I'm looking at, the result of the nom parser looks much closer to the "pest (custom AST)" benchmark than the "pest" benchmark. The description above the image, however, primarily compares the "pest" result. Am I misunderstanding something or is the comparison not fair?

I've added a clarification. The point of the benchmark is not to compete with other projects, it's merely there to put the parsing speed (and not necessarily the processing that comes after it) in a representative window of performance.

Re: Show HN: Pest – Fast parser generator written in Rust

#26
post #17

This is a neat project! I might take a look at this if/when I get started on my dream language. :p One constructive criticism, which may be only an unpopular opinion, but I find creative operator overloading unnecessarily hard to read. And I don't think my opinion is entirely subjective since, by definition, you have to learn new semantics whereas a good function name would make the meaning obvious. Maybe this syntax…

I agree with your point. I tried my best not to sway too far off of some of syntax I've seen in other PEG projects, while also keeping it compatible with Rust's standard macros. While pest does have this constraint any longer with the new beta, changing the grammar too much would have been a nuisance for anyone who had grammars written in the older versions.

Understood. Thanks for taking the time to explain!
Post reply on HN