[squeak-dev] Xtreams up to date

mkobetic at gmail.com mkobetic at gmail.com
Fri Jan 21 23:26:23 UTC 2011


"Hannes Hirzel"<hannes.hirzel at gmail.com> wrote:
> Besides http://code.google.com/p/xtreams/wiki/Parsing are there more
> examples how to use Peg parsing?

Unfortunately that one is still waiting for documentation. Even the little bit that is on the wiki page uses an example that wasn't ported because it uses VW's XML Elements.

It's actually not that complicated to use. Basically you take a PEG grammar, you parse it as the wiki example shows (the first 2 lines). Then you need an 'actor' that will get callbacks from the parser when it parses some input. The Actor class provides simple pragma based dispatch mechanism for convenience, but ultimately the actor simply receives #process:object:start:stop: callbacks from successfully applied grammar rules. The TreeBuilder in the Tests package shows the simplest Actor that just collects all the callback arguments. The return value of the callback is important, the object: argument of the callback is a collection of what the lower level rules returned from their callbacks. Anyway that's real quick description of how the parsing mechanism works from user point of view. Real documentation needs a lot of simple examples to make that clearer, but hopefully this could get you going if you experiment with simpler grammars and the TreeBuilder a bit. I'll try to answer any more specific questions as I can.

HTH,

Martin



More information about the Squeak-dev mailing list