hello gentlemen,
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.
so I ask your assistance in helping me putting up a simple, yet
Aldo Calpini writes:
I've taken this bison example (an RPN calculator, stripped down version
from http://www.gnu.org/software/bison/manual/html_node/Rpcalc-Rules.html):
input:/* empty */
| input line
;
line: '\n'
| exp '\n'
;
exp: NUM
|
[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?
Luke Palmer wrote:
Also, if this is going to be an explanation rather than just a picture,
I suggest you go with Perl's usual versatile power, and store the
operators in a declarative data source.
grammar RPN {
my @operator = + - * / ;
rule input { line* }
Sean O'Rourke wrote:
* 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.
Small correction : pour, tant_que, si :)
[EMAIL PROTECTED] (Rafael Garcia-Suarez) writes:
Sean O'Rourke wrote:
* 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,
Rafael Garcia-Suarez writes:
Luke Palmer wrote:
Also, if this is going to be an explanation rather than just a picture,
I suggest you go with Perl's usual versatile power, and store the
operators in a declarative data source.
grammar RPN {
my @operator = + - * / ;
Luke Palmer wrote:
That left recursion won't do. I can't remember my transformation rules
well enough to know how to put that in a form suitable for a recursive
descent parser. To be honest, I've never seen an RPN calculator modeled
with a grammar.
Well, the main advantage of an RPM syntax
Aldo Calpini wrote:
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.
so I ask your assistance in helping me putting up a simple,