Dynamic Parsers

39 views
Skip to first unread message

Tanner Ezell

unread,
Oct 2, 2015, 2:39:24 AM10/2/15
to parboiled2.org User List
Hello,

I'm evaluating libraries to build parsers for our little toy language. One requirement we have is that parsers are only available if certain parsers (and variables) of a specific type are available. For example, a parser that works with Integers would not be available until an integer type variable is added to the context. Once it is added, it can then be parsed by any parsers that work from an Integer.

Is runtime generation of parsers possible with Parboiled2?

Mathias Doenitz

unread,
Oct 2, 2015, 2:57:39 AM10/2/15
to parboil...@googlegroups.com
Tanner,

> Is runtime generation of parsers possible with Parboiled2?

It’s “possible” but probably not what you’d want to do.

pb2 is a parser generator that works at compile-time.
That is: the Scala compiler translates your rule definitions into runnable byte code.

When your app is running this translation has already happened.
If you’d like to fully generate rules at runtime you’d have to have the compiler on the class path, run it from your app and then load the generated classes at runtime,
which is probably not what you’d want to do.

Have you looked at http://lihaoyi.github.io/fastparse/?
It appears to be a very good alternative to pb2.

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/0ce9b4fd-4233-42e2-af27-4c3a65a7c989%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages