PetitParser Examples

This package contains examples to illustrate the use of PetitParser. A tutorial and full documentation is contained in the package description and API documentation.

To run the web examples execute the following commands from the command line and navigate to http://localhost:8080/:

pub global activate webdev
webdev serve

Dart

This example contains the grammar of the Dart programming language. This is based on an early Dart 1.0 grammar specification and unfortunately does not support all valid Dart programs yet.

JSON

This example contains a complete implementation of JSON. It is a simple grammar that can be used for benchmarking with the native implementation.

Lisp

This example contains a simple grammar and evaluator for LISP. The code is reasonably complete to run and evaluate complex programs. Binaries for a Read–Eval–Print Loop (REPL) are provided for the console and the web browser.

Prolog

This example contains a simple grammar and evaluator for Prolog programs. The code is reasonably complete to run and evaluate basic prolog programs. Binaries for a Read–Eval–Print Loop (REPL) are provided for the console and the web browser.

Smalltalk

This example contains a complete implementation of the Smalltalk grammar. This is a verbatim export of a grammar that was originally developed for the PetitParser infrastructure in Smalltalk and that was the base of the Helvetia Language Workbench.

Libraries

petitparser.example.dart
This package contains the grammar of the Dart programming language. [...]
petitparser.example.json
This package contains a complete implementation of JSON. [...]
petitparser.example.lisp
This package contains a simple grammar and evaluator for LISP. [...]
petitparser.example.prolog
This package contains a simple grammar and evaluator for Prolog based on this blog post: https://curiosity-driven.org/prolog-interpreter. [...]
petitparser.example.smalltalk
This package contains the complete grammar of Smalltalk. [...]