PetitParser Compiler

Logo

Petit Compiler accepts PetitParser as input and produces a Smalltalk class with an equivalent top-down parser. Combinators of PetitParser are analyzed and the fastest parsing strategy is choosen for each of them. The compiled parser is significantly faster.

Performance

Smalltalk

We compare four different Smalltalk parsers. All of them create an identical AST:

Smalltalk-speedup

Speedup compared to PetitParser.

Smalltalk-tpc Average time per character for each of the parsers.

Other Benchmarks

In general, we measure performance speedup ranging form factor two to ten. In the figure bellow, there is a speedup for the following grammars:

Speedup

Installation

Gofer new smalltalkhubUser: 'JanKurs' project: 'PetitParser';
    configurationOf: #PetitCompiler; load.
(Smalltalk at: #ConfigurationOfPetitCompiler) perform: #'loadStable'.

Using PetitCompiler

| petitParser compiledParser |
petitParser := PPSmalltlakParser new.
"compilation might be costly do it only when you change your parser"
compiledParser := parser compile.
compiledParser parse: 'foo ^ 1'.

Visit Smalltalkhub for more information.

Limitations

Supported Smalltalks

PetitCompiler supports Pharo 5 and Smalltalk/X.

Do not hesitate to contact us, if you want to port into your own Smallatlk.

Publications

Author Page