Skip to content

Latest commit

 

History

History
88 lines (64 loc) · 3.34 KB

README.md

File metadata and controls

88 lines (64 loc) · 3.34 KB

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.

Learn more about PetitParser2. In the tutorial we cover all the topics related to PetitParser2. We discuss PetitParser2 best practices, testing, abstract syntax tree generation, optimizations or even context-sensitive parsing.

https://kursjan.github.io/petitparser2/

Need Help?

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