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.