Charles Comstock wrote:

> The advantage of the embedded system is you can call out to a grammar 
> inline from a builtin regex, something you can't really do in ruby at 
> the moment.  Basically with the perl6 grammars you would be able to say
> text =~ /__START__<ruby>__END__/ where ruby would be the grammar for 
> ruby with associated callbacks for each grammar node to say create an 
> AST.  The fact it can be embedded in a regex gives the nice touch that
> a) you can switch quickly back and forth between the grammar and lexer 
> level
> b) it just makes it alot easier to use a grammar from within the 
> language.
>
> It might help the discussion if a few more people take a look at how 
> the grammars are designed to work in perl6.  If the functionality they 
> are trying is possible without extending the language then go for it, 
> but I am inclined to believe it is not possible without a seperate 
> regex engine at the moment.  In addition the ability to inherit 
> grammars would probably be easier if it was embedded in the language, 
> but it is certainly possible to work around that constraint.
>
> The pertinent perl6 grammar references:
> http://dev.perl.org/perl6/exegesis/E05.html
> http://dev.perl.org/perl6/apocalypse/A05.html
>
I've taken a look and I agree it looks powerful. The embedding in the 
language is crucial to what they are trying to do: making 
grammars/parsing a first-class entity in the language that plays nicely 
with the other parts. The things that is a bit hard to understand is how 
powerful a parser this can be used to express. All context-free 
grammars? An even larger class? I guess the latter might be the case 
since they can have code intermingled.

The downside is the complexity of it, both in understanding and 
implementing. Do they plan to support this in Parrot so that other 
languages on top of Parrot can reuse the same implemenation? Seems like 
this is quite a bit away into the future. Thanks for bringing it up.

/Robert