[Petal] [HELP] Anybody has experience with parsing?
Jean-Michel Hiver
jhiver at mkdoc.com
Wed Jun 11 11:46:12 BST 2003
> I've got it working with Parse::RecDescent. I suppose now is as good a time as
> any to expose my unpleasant alternative to Petal. I was working on it before
> I found Petal, I'm not putting it forward as a competitor or anything. It's
> not very polished at all but it does seem to be considerably faster due to
> compiling variable accesses down to Perl rather than parsing them at run
> time. In fact that's about the only thing it has on Petal.
Your implementation is mostly interesting! I understand the interest of
hinting the code generator on the type of expression that's being
parsed, but on the other hand I really like Petal's ability to 'do the
right thing' given an expression.
I suppose ideally Petal should be able to do both... Also, maybe
something 'like/this' could be turned into something like:
do {
my $context = do {
$context = $Context;
($context =~ /=/) ? $context->this() : $context->{this};
};
($context =~ /=/) ? $context->like() : $context->{like};
};
It could be then be brutally dumped in the code that's generated...
Also, I don't think that the 'some_modifier:' syntax should be included
in the Parse::RecDescent grammar because it seriously limits
extensibility. But I would like to see modifiers produce code as well.
For example, 'false: like/this' could become something like:
not do {
my $context = do {
$context = $Context;
($context =~ /=/) ? $context->this() : $context->{this};
};
($context =~ /=/) ? $context->like() : $context->{like};
};
I want to find a way to preserve Petal's feature set, increase its speed
and making the parsing more robust than a bunch of nasty regexes :)
Cheers,
--
Building a better web - http://www.mkdoc.com/
---------------------------------------------
Jean-Michel Hiver
jhiver at mkdoc.com - +44 (0)114 255 8097
Homepage: http://www.webmatrix.net/
More information about the Petal
mailing list