RE: Parse::RecDescent and catenating (no skip match)
[email protected] ("Brian Michalk") Thu, 25 Jul 2002 08:54:05 -0500
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Thanks to all that responded. Cleaning up my parser was a success. I still have a question: > -----Original Message----- > From: Ted Zlatanov [mailto:[email protected]] > Sent: Tuesday, July 23, 2002 4:21 PM > To: Brian Michalk > Cc: Marco Baringer; [email protected] > 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)));