[EMAIL PROTECTED] (Aldo Calpini) writes:
> I'm preparing a talk about Perl6 for the Italian Perl Workshop, and I
> would like to have a slide comparing a BNF (yacc/bison) grammar to a
> Perl6 one, to show how powerful in parsing/lexing Perl6 regexen are.
> ...
> am I missing something obvious here? will the above code work in Perl6?
> do you have perhaps a better example, or just an idea about what to show?

A few points:

* Remember that with Yacc, you also need a lexer, while P6 combines
  lexing and parsing.  Though it would complicate the example, it
  would make P6 look better to include a lex definition for NUM and
  the regex rule in P6.

* I'd do infix, because it's not too much more complex, because it's
  more natural and familiar, and because it will show the differences
  in how you write recursive descent versus LALR grammars.

* To really show where P6 rocks, you need to show dynamic features.  A
  simple example might be using a language with keywords kept in
  variables, allowing you change between e.g. "for, while, if", "pour,
  tandis-que, si", etc. (hey, you could use LWP::Simple to babelfish
  your language on the fly!).  A more complicated example might parse
  a construct that would add rules to the grammar, something that
  would be really hard with Yacc.

/s

Reply via email to