Re: newlines and no newlines
[email protected] (Damian Conway)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
This works fine as far as I can tell:
use Parse::RecDescent;
$::RD_AUTOACTION = q{ print "$item[0]\n" };
$grammar = q {
s : c
c : ct 'a' m
ct: 'c t'
m : 'b' t 'B'
t : 'int'
};
$parse = new Parse::RecDescent ($grammar);
$schema = q{
c t a
b int B
};
my $tree = $parse->s($schema);
use Data::Dumper 'Dumper';
print Dumper [ $tree ];
Of course, $tree doesn't actually have the parse tree in it, since the
autoaction means the last item of each rule is a print statement, which
returns 1. So the entire parse returns 1. :-(
Perhaps you wanted:
$::RD_AUTOACTION = q{ print "$item[0]\n"; [@item[1..$#item]] };
???
Damian