Talk 1: Parsers, Perl 6 Rules, and the Parrot Grammar Engine
So, I think I accidentally went to the wrong talk? I saw that this talk was about Perl 6, the Parser, and Grammars or something. Figured it was about the language Perl 6 is using, and would be interesting to see what the Perl 6 team has (not) accomplished this year.
Turns out, this talk is about how to write grammars in Parrot. He's describing the actual grammar system, the syntax of it, and etc etc. It's interesting so far, but not what I was expecting. Uh, whoops.
The gist - Perl 6 will provide the ability (well, I guess Parrot really) to create very, very extensive grammars with ease. You can then use these in your program very, very quickly. Write a configuration file parser? Ten lines of grammar, three lines of 'use my grammar to parse this input'. Then you just run down the parsed input and hurrah!
As an aside, Perl 6 has one less level of precedence than Perl 5. (I yelled out 'yay', remembering the times I printed out the list or 'perldoc perlop' to remember what went when. People laughed.)
Oh, very cool - it provides a very easy way to indicate precedence. You basically just state 'this is tighter than that' (or looser, or equivalent). You can even define circumfix/ternary/etc. (Although that'd be expected, as you need them in Perl...)
Another aspect, when you're writing your grammar, you can stick in error messages. Something like this...
rule if_statement {
if [ <expression> | <die: "Expression expected"> ]
[ then | <die: "If requires 'then'"> ]
[ <statement> | <die: "Statement expected, not found"> ]
}
(Wanted to do code input, but can't seem to. Alas.)
All told, this is interesting. It will be neat to be able to do this, have it put in the language without having to actually write your own complicated system. Yes, I realize there are things like bison/yacc/lex (I forget which does what I'm thinking of), and Parse::RecDescent and whatnot, but those still require more work than this system appears to.
So says the not-so-much-an-expert on parsing.
Still looking forward to Perl 6.