Different questions about PB2

41 views
Skip to first unread message

Paul Schneider

unread,
Sep 24, 2015, 5:08:25 AM9/24/15
to parboiled2.org User List
Hi Mathias and Alexander!

Parboiled2 is awesome, and I want to make it even more popular by writing a series of articles about it. Could you answer some questions to make my understanding better in details?

1. In his presentation Alexander was talking about nested parsers (where handler can be a parser too). But can it be useful in real life? I can not imagine any real life example.
2. As far as I know it's possible to access Value Stack directly. It's considered to be a bad idea in general, but may there be a specific case when it's the best (or the only) option, to justify the very existence of such a feature?


Mathias Doenitz

unread,
Sep 25, 2015, 10:17:15 AM9/25/15
to parboil...@googlegroups.com
Hey Paul,

sorry for answering so late, I was busy with preparing for (and recovering from) scala.world… :)

> 1. In his presentation Alexander was talking about nested parsers (where handler can be a parser too). But can it be useful in real life? I can not imagine any real life example.

Yes, nested parsers can be very useful!
Nesting is a basic form of composition and composability is a key ingredient for effective APIs.
It simply gives you the required tools for structuring your parser rules in the way that is best for your application while keeping everything DRY and reusable.

> 2. As far as I know it's possible to access Value Stack directly. It's considered to be a bad idea in general, but may there be a specific case when it's the best (or the only) option, to justify the very existence of such a feature?

pb2 tries to combine cleanliness with performance.
In some cases, if you know what you are doing, accessing the value stack directly might give you a performance benefit in especially “hot” rules.

Cheers,
Mathias

---
mat...@parboiled.org
http://www.parboiled.org
> --
> You received this message because you are subscribed to the Google Groups "parboiled2.org User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to parboiled-use...@googlegroups.com.
> Visit this group at http://groups.google.com/group/parboiled-user.
> To view this discussion on the web visit https://groups.google.com/d/msgid/parboiled-user/2ab8614b-1e8a-4416-b113-3cff7876270c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Paul Schneider

unread,
Oct 7, 2015, 7:53:10 PM10/7/15
to parboiled2.org User List
Thank you for the reply. I wasn't hurrying, so time is not an issue :)
Reply all
Reply to author
Forward
0 new messages