ikaruga has asked for the wisdom of the Perl Monks concerning the following question:
However, the following code does not work:use strict; use warnings; use Parse::RecDescent; my $grammar = q { start : character character character(s) {print "Found: ", $item[1], $item[2], join "", @{$item[3 +]}, "\n"; } character: /\w/ }; my $parser = Parse::RecDescent->new($grammar); defined $parser->start("ABCD") or die "didn't match";
And by "not work" it prints out "1111" instead of the sequence:use strict; use warnings; use Parse::RecDescent; my $grammar = q { start : character character character(s) {print "Found: ", $item[1], $item[2], join "", @{$item[3 +]}, "\n"; } character: /\w/ {print "Character: $item[1]\n"} }; my $parser = Parse::RecDescent->new($grammar); defined $parser->start("ABCD") or die "didn't match";
I sure that I am misunderstanding how RecDescent works. Can someone enlighten me? I'm using WinXP, the latest ActiveState perl, the latest RecDescent. BTW, this is a minor issue. But what's up with "chatterbox"? Why not use IRC like everyone else?Character: A Character: B Character: C Character: D Found: 1111
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RecDescent help
by ikegami (Patriarch) on Jan 20, 2010 at 20:18 UTC | |
by ikaruga (Novice) on Jan 20, 2010 at 21:28 UTC | |
by ikegami (Patriarch) on Jan 21, 2010 at 16:24 UTC | |
|
Re: RecDescent help
by CountZero (Bishop) on Jan 20, 2010 at 22:06 UTC | |
by ikaruga (Novice) on Jan 21, 2010 at 15:31 UTC | |
by CountZero (Bishop) on Jan 22, 2010 at 17:30 UTC | |
|
Re: RecDescent help
by duelafn (Parson) on Jan 22, 2010 at 15:16 UTC |