RE: skipping backslashes at the end of lines
[email protected] Tue, 1 Jun 2004 09:36:40 +0200
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Why doesn't <skip: '(?:\s|\\\\|\n)+'> remove backslashes?
I get a backslash consumed as "value" in the script below:
$top = {
'AIF' => [
'Videorecorder.aif',
'..\\aif',
'Videorecorderaif.rss',
'\\', # why is it here?
'c8'
]
};
I've read the continuation-character thread with Randall and
Domian in the archive (which is summarized in the P::RD::FAQ),
but still don't get it. Any hints please?
Regards
Alex
#!/usr/bin/perl
use strict;
use vars qw($parser $text %top);
use Data::Dumper;
use Parse::RecDescent;
$RD_WARN = 1;
$RD_HINT = 1;
$RD_TRACE = 120;
use constant GRAMMAR => q(
mmpfile: chunk(s) /^\Z/
chunk: assignment | <error>
assignment: keyword <skip: '(?:\s|\\\\|\n)+'> value(s) {
my $href = \%::top;
push @{$href->{uc $item{keyword}}}, @{$item[3]};
}
value: /"[^"]*"/ | ...!keyword /\S+/
keyword:
/AIF\b/i
);
$parser = Parse::RecDescent->new(GRAMMAR) or die 'Bad grammar';
$text .= $_ while (<DATA>);
defined $parser->mmpfile($text) or die 'Bad text';
print Data::Dumper->Dump([\%top], [qw(top)]);
__DATA__
AIF Videorecorder.aif ..\aif Videorecorderaif.rss \
c8