
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 scannerless parsing, parser combinators, parsing expression grammars and packrat parsers to model grammars and parsers as objects that can be reconfigured dynamically.
Although PetitParser was born as part of the Helvetia infrastructure, it can be used independently. An introduction to PetitParser can be found in the following blog posts: Writing Parsers with PetitParser and Composite Grammars with PetitParser. Also the Moose Book has a chapter on PetitParser.
Pharo Smalltalk is the main development environment of PetitParser. To load the core library evaluate the following code:
Gofer new
renggli: 'petit';
package: 'PetitParser';
load.To get the full toolset, including a dedicated editor and some experimental tools, use the following Metacello script:
Gofer new
renggli: 'petit';
package: 'ConfigurationOfPetitParser';
load.
(Smalltalk at: #ConfigurationOfPetitParser)
perform: #loadDefault.PetitParser has been reported to also work in Squeak.
To load the package PetitParser.star one can type:
gst-package http://smalltalk.gnu.org/project/petitparser/package.xml
To load the PetitParser.star into the image do:
PackageLoader fileInPackage: 'PetitParser'
There are some differences between the official PetitParser and this port. GNU Smalltalk does not support binary selectors that have more than two characters. This means that ==> and >=> had to be mapped to something else. I have picked => and >< for now.
More details can be found in the blog article of Holger Hans Peter Freyther.
This requires Cincom VisualWorks 7.7 or later:
PostgreSQLEXDIConnectiondb.iam.unibe.ch:5432_scgStorestoreguest (if you have one, put yours)storeguest (if you have one, put yours)BERNPetitParser.There is a port of PetitParser to VSE by Leandro Caniglia.
There is a version of PetitParser for Java.
There is also a version of PetitParser for Dart.
Please report bugs or ask questions in the Pharo or Moose mailing-lists.
PetitParser is licensed under the MIT license.