Thanks for sharing the library with the community. It looks like a lot
of work has been put into it, and the documentation is excellent.

My only quibble, is that I wouldn't call the approach unique. While I
am unaware of what is available in Java there are many similar
libraries in other languages. For example I used a similar technique
in C# in the Heron language
(http://code.google.com/p/heron-language/source/browse/trunk/HeronEngine/HeronGrammar.cs).
The only difference is that I used operator overloading for sequence
and priortized choice operators.

- Christopher Diggins

On Thu, Nov 12, 2009 at 11:10 AM, Mathias <math...@parboiled.org> wrote:
> Hello everyone,
>
> I thought the Java guys among you might be interested in a new, open
> source Java 1.5+ library supporting PEG parsing in a pretty unique way.
> http://www.parboiled.org was born out of frustration over existing
> parser generators with their external grammar files that lack IDE
> support and are often just a little bit too hard to integrate in real-
> world projects.
>
> parboiled let's you specify your PEG grammar rules right in Java source.
>
> Small example:
> Consider the following grammar (a classical calculator example):
>
> Expression ← Term ((‘+’ / ‘-’) Term)*
> Term ← Factor ((‘*’ / ‘/’) Factor)*
> Factor ← Number / ‘(’ Expression ‘)’
> Number ← [0-9]+
>
>
> A parboiled parser definition, complete and in ready-to-compile Java
> code would look like this:
>
>
> public class CalculatorParser extends BaseParser<Object,
> Actions<Object>> {
>
>     public Rule expression() {
>         return sequence(
>                 term(),
>                 zeroOrMore(
>                         sequence(
>                                 firstOf('+', '-'),
>                                 term()
>                         )
>                 )
>         );
>     }
>
>     public Rule term() {
>         return sequence(
>                 factor(),
>                 zeroOrMore(
>                         sequence(
>                                 firstOf('*', '/'),
>                                 factor()
>                         )
>                 )
>         );
>     }
>
>     public Rule factor() {
>         return firstOf(
>                 number(),
>                 sequence('(', expression(), ')')
>         );
>     }
>
>     public Rule number() {
>         return oneOrMore(charRange('0', '9'));
>     }
> }
>
> Your rule definitions can also include direct calls to action methods
> which will behave as expected, they are called at the right time
> during the parsing run.
> parboiled supports AST construction in a very flexible way and has a
> few other, quite neat features (like proper parse error recovery,
> white space gobbling and so on). It currently implements a recursive
> descent parser, but could be extended to support packrat parsing as
> well without too much trouble.
>
> The source and a rather full-blown documentation currently lives at
> github, which you are forwarded to from http://parboiled.org.
>
> Maybe you like the approach and are willing to provide feedback... I'd
> be happy to receive any.
>
> Cheers,
> Mathias
>
> ---
> math...@parboiled.org
> http://www.parboiled.org
>
>
> _______________________________________________
> PEG mailing list
> PEG@lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/peg
>

_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to