Am 06.10.2011 um 12:05 schrieb drush66:
I have just watched video of Tudor's great hands on PettitParder tutorial on ESUG, and few questions poped up to me.
- in PPMSEGrammar, start is encoded ad ^elements end
is that a good habit to include end in start method? Somehow this is counter intuitive to me since it seems it would make such grammar non embeddable in another parser, or I am mistaken?
To use end in the start method is just saying that you want to consume all of the input with your rule. Let's say you have "mainrule end" in your start of the grammar then you can embed this in another grammar by referencing mainrule (and not start) in the new grammar. In the new grammar you would have start defined as "anothermainrule end". The start method is just to one that is used by default.
- can ==> be cascaded in a sense that if we have parser A, its subclass
parser B which calls supper and then adds ==>. Can we then have C which is subclass of B, and adds its ==> on top of the one added by B?
Yes. As input to the ==> block who will get the result of the ==> block of B
- What do you think, could PettitParser be reasonably used to de-marshal
some (binary) network protocol. By reasonably I mean that it would not be an order of magnitude slower than some code hacked from the scratch (but not terribly optimized).
I can only assume that the produced overhead is some magnitude slower than hand written stream parsers. But I'm sure there will be answers with more insight coming.
Norbert