Created PetitParserExtension project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Created PetitParserExtension project

Guillaume Larcheveque
Hi everybody,

I am using PetitParser a lot and had implemented some little tools that help me for writing or generating grammars. I put two of the most useful in the project PetitParserExtension (http://smalltalkhub.com/#!/~Moose/PetitParserExtensions).

the first one is useful when you generate grammars with lots of rules:

A PPExtendedCompositeParser offers you a new way to create rules. Just define your rule as a method in the #rules protocol and it will be managed exactly like rules in PPCompositeParser.
You will not have the limitation of 256 rules due to the instance variables limit but you will need to refer to your rule with the method #rule: in any other rule using it.

You can mix PPCompositeParser and PPExtendedCompositeParser way to define rules.


the second one is cool for token identification because it creates a parser that will parse in a time depending on token length and not the number of different tokens.

A PPMultiStringParser is a tool able to create a really effective parser on a huge  collection of Strings. This parser will match any string in this collection, and the longest one if two are matchable (( PPMultiStringParser on: #('tin' 'tintin')) parse: 'tintin' will match 'tintin' and not just 'tin')


If someone else has implemented some tools around PetitParser, it will be great to put those all together so feel free to commit your tools in this project and to improve mines.

--
Guillaume Larcheveque