FAQ
Thanks to all that responded. Cleaning up my parser was a success. I still
have a question:
-----Original Message-----
From: Ted Zlatanov
Sent: Tuesday, July 23, 2002 4:21 PM
To: Brian Michalk
Cc: Marco Baringer; recdescent@perl.org
Subject: Re: Parse::RecDescent and catenating (no skip match)
To answer your question as best I can, I think you want the

<skip: qr/,?/>

directive in general, applied to your top rule, instead of accessing
$skip directly. See the Parse::RecDescent documentation on the <skip>
directive. From the doc:
Why is the skip token attached to a rule? I have my grammar written such
that a lot of different rules can borrow from the same atomic subrules.
Take for instance, a color definition. It could be used as a field in a
person's favorite color, or in the DuPont catalog. If I used the skip
directive, I would have to put it in every concievable entry point in the
grammar, and I really don't know where someone is going to enter the
grammar. So I would be forced to do it this way:

my $contrived_grammar = q{
dupont_catalog: <skip: qr/,?/>
color
...

personal_favorites: <skip: qr/,?/>
color
...

color: <skip: qr/,?/>
RGB
some_other_way_of_defining_color
}

# I gotta set the skip, because the following rule has to work:
print "Yay!!! Its a color-- $somestring" if (defined
($contrived_parser_object->color($somestring)));

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 11 | next ›
Discussion Overview
grouprecdescent @
categoriesperl
postedJul 23, '02 at 1:54p
activeJul 25, '02 at 2:27p
posts11
users4
websitemetacpan.org...

People

Translate

site design / logo © 2018 Grokbase