A high-performance top-down parser
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.utilities loading the sources for smalltalk verifications Aug 24, 2016
BaselineOfPetitParser2.package [baseline] remove rewrite tool from the default baseline Jun 21, 2018
BaselineOfPetitParser2Core.package [baseline] use kursjan instead of feenkcom repository Jun 21, 2018
BaselineOfPetitParser2Experimental.package [baseline] add RewriteEngine do experimental baseline Jul 10, 2018
BaselineOfPetitParser2Gui.package [baseline] The GToolkit project is likely necessary only for Pharo 5.0? Aug 23, 2018
BaselineOfPetitParser2Languages.package [baseline] use kursjan instead of feenkcom repository Jun 21, 2018
BaselineOfPetitParser2RewriteEngine.package [baseline] use kursjan instead of feenkcom repository Jun 21, 2018
PetitParser2-Benchmarks-GUI.package #asParser2 changed to asPParser Sep 17, 2016
PetitParser2-Benchmarks.package optimizations in caches/profiling of caches Nov 13, 2016
PetitParser2-CSV.package refactorings Nov 12, 2016
PetitParser2-Experiments.package [code cleaning] move `parseInterpreted:` to experimental package Aug 31, 2018
PetitParser2-GUI-Tests.package Rewrite goes to experimental. Apr 22, 2018
PetitParser2-GUI.package Fixed title, updated comment. Sep 15, 2018
PetitParser2-Html-Tests.package code cleanup and dependency fixes Sep 3, 2017
PetitParser2-Html.package optimizations in caches/profiling of caches Nov 13, 2016
PetitParser2-JSON.package refactorings Nov 12, 2016
PetitParser2-MSE.package refactorings Nov 12, 2016
PetitParser2-ManifestMf.package refactorings Nov 12, 2016
PetitParser2-RewriteEngine-Tests.package improved handling of test blocks (still not perfect, but better :) Jan 8, 2018
PetitParser2-RewriteEngine.package improved handling of test blocks (still not perfect, but better :) Jan 8, 2018
PetitParser2-Smalltalk-Tests.package noop? Apr 22, 2018
PetitParser2-Smalltalk.package Fixed dependencies Apr 22, 2018
PetitParser2-Tests.package Add #foldRight: and tests Aug 11, 2018
PetitParser2-Tutorial.package added missing json files Mar 29, 2017
PetitParser2-Validation-Tests.package Experiments moved to experiments package Apr 20, 2018
PetitParser2-Validation.package added comments to validator Apr 14, 2018
PetitParser2.package [code cleaning] move `parseInterpreted:` to experimental package Aug 31, 2018
benchmarks benchmarks script (I am afraid it works only on my local machine) Oct 30, 2016
.core.ston [baseline] use feenkcom fork in order to make PR green Jun 21, 2018
.experimental.ston [baseline] use feenkcom fork in order to make PR green Jun 21, 2018
.filetree gitfiletree repository properties Apr 3, 2016
.gitignore benchmarks script (I am afraid it works only on my local machine) Oct 30, 2016
.gui.ston [baseline] use feenkcom fork in order to make PR green Jun 21, 2018
.languages.ston [baseline] use feenkcom fork in order to make PR green Jun 21, 2018
.rewrite.ston [baseline] use feenkcom fork in order to make PR green Jun 21, 2018
.smalltalk.ston [travis] fix PetitParser2 configuration Jun 21, 2018
.travis.yml simplify the travis file Jun 23, 2018
LICENSE Initial commit Apr 3, 2016
README.md [readme] add link to how-to debugging information Aug 23, 2018

README.md

PetitParser2 Build Status

PetitParser2 is a new version of PetitParser that allows one to define flexible and high-performance parsers.

Key Features

  • Modular, composable and easy to extend
  • Natural, easy-to-follow definitions
  • High performance
  • Supports context-sensitive parsing
  • Supports tolerant parsing
  • Rich IDE support

Why to switch from PetitParser to PetitParser2?

Better performance

The performance of PetitParser2 is 2-5 times faster compared to PetitParser when used in optimized mode. The optimizations are based on the technologies of PetitCompiler. To optimize, simply call optimize before parse:.

Try it out! Compare the optimized version of PP2SmalltalkParser, non-optimized version, SmaCC and RBParser. Evaluate the following code:

PP2Benchmark exampleSmalltalk

Much faster context-sensitive parsing

PetitParser2 applies many optimizations to reduce the overhead of context-sensitive combinators, when used in optimized mode.

Support for real streams

PetitParser2 supports real streams - no need to have the whole input in memory (see PP2BufferStream). The following demo utilizes a parser created on top of a character stream coming from your keystrokes. The parser waits for input from the keyboard and proceeds with parsing as characters come in:

PP2ReadKeysExample example

Support for bounded seas

With PetitParser2 you can define only part of the grammar and skip an uninteresting input. Bounded seas are extensible so you can always add more rules to your grammar to extract more data.

Installing PetitParser2

Use the configuration manager in your Pharo image and install the stable version.

Installing standard version for the latest Pharo:

Metacello new
    baseline: 'PetitParser2';
    repository: 'github://kursjan/petitparser2';
    load.

To install graphical tools (with GToolkit and Roassal2 dependencies):

Metacello new
    baseline: 'PetitParser2Gui';
    repository: 'github://kursjan/petitparser2';
    load.

To install experimental tools, e.g., RewriteEngine, use:

Metacello new
    baseline: 'PetitParser2Experimental';
    repository: 'github://kursjan/petitparser2';
    load.

To install a core with minimal external dependencies, use:

Metacello new
    baseline: 'PetitParser2Core';
    repository: 'github://kursjan/petitparser2';
    load.

Debugging Parsers

Here you can find an illustrative explanation how to debug when parsers do not work as expected.

PetitParser2 Book

Learn more about PetitParser. In the book we cover all the topics related to PetitParser. We discuss basics of parsing such as testing or AST generation as well as advanced topics including context-sensitive parsing or optimizations.

https://kursjan.github.io/petitparser2/pillar-book/build/book.html

Need Help?

Feel free to open an issue or post a StackOverflow question with the petitparser2 tag.