Where could I find more examples of using PetitParser?

1k Views Asked by At

I'm looking for additional examples of using PetitParser beyond PPArithmeticParser and PPLambdaParser that are provided in the tests package and a couple of blog posts by Lukas? If anyone's willing to share theirs, it would be much appreciated.

Updated: https://github.com/NicolasPetton/jtalk/blob/master/st/parser.st
Updated: https://github.com/dmatveev/waste/blob/master/wastex.st

Keep 'em coming!

2

There are 2 best solutions below

0
On BEST ANSWER

Have a look at the official PetitParser code repository, there are many grammars ready to download:

  • PetitCSV
  • PetitJson (well tested, builds Smalltalk objects)
  • PetitMSE
  • PetitManifestMf
  • PetitRegex
  • PetitSQL
  • PetitSmalltalk (well tested, can be used as a replacement for the refactoring engine parser)
  • PetitXml (well tested)

Additionally you find various PetitParser grammars on SqueakSource. Just search for 'PetitParser' as a keyword and you find more or less complete grammars for Java, JavaScript, Ada, SQL, and some others.

1
On

There are a lot of small nice examples on PetitParsers Google+ site.

  • Quickly extract all JavaDoc comments from a file
  • Parse 'self', but not variables like 'selfish' or 'selfism'
  • A PetitParser grammar that only accepts an even number of a's and b's
  • Parse a non context-free language
  • Parse floating point numbers
  • Parse nestable Haskell comments
  • ...