Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Dynamic Grammars in Java
branch: master

PetitParser for Java

Grammars for programming languages are traditionally specified statically. They are hard to compose and reuse due to ambiguities that inevitably arise. PetitParser combines ideas from scannnerless parsing, parser combinators, parsing expression grammars and packrat parsers to model grammars and parsers as objects that can be reconfigured dynamically.

This library is open source, stable and well tested. Development happens on GitHub. Feel free to report issues or create a pull-request there. General questions are best asked on StackOverflow.

Continuous build results are available from Jenkins. An introductory tutorial is part of the class documentation.

Basic Usage


From the command line check out the code and install your own copy:

$ git clone
$ cd java-petitparser
$ git checkout 2.0.0
$ mvn install

Then add the following snippet to your pom.xml file:



The package comes with a large collections of grammars and language experiments ready to explore:

  • petitparser-json contains a complete JSON grammar and parser.
  • petitparser-xml contains a complete XML grammar and parser.
  • petitparser-smalltalk contains a complete Smalltalk parser.



PetitParser was originally implemented in Smalltalk. Later on, as a mean to learn these languages, I reimplemented PetitParser in Java and Dart. The implementations are very similar in their API and the supported features. If possible, the implementations adopt best practises of the target language.



The MIT License, see LICENSE.

Something went wrong with that request. Please try again.