Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Dynamic expansion of tokens with Parse::RecDescent

by Solo (Deacon)
on Aug 18, 2004 at 21:04 UTC ( [id://384108]=note: print w/replies, xml ) Need Help??


in reply to Dynamic expansion of tokens with Parse::RecDescent

You might try the Extend method like so:

use Parse::RecDescent; my @colors = ('periwinkle','indigo'); my $grammar = q[ order: quantity color item quantity: /\d+/ color: item: 'pen' | 'pencil' ]; my $parser = new Parse::RecDescent ($grammar); $parser->Extend("color: '" . join(q['|'],@colors) . "'" );

Or cram it in the grammar...

my $grammar = q[ order: quantity color item quantity: /\d+/ color: '] . join(q['|'],@colors) . q[' item: 'pen' | 'pencil' ];

Update: revdiablo beat me to it... note to self: type less.

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://384108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found