http://qs1969.pair.com?node_id=208285

ixo111 has asked for the wisdom of the Perl Monks concerning the following question:

hi folks,

I'm trying to write a Parse::RecDescent chunk that will split up a line of input in to <tags> and non-tags such that

"<this>this is tagged</this> <bye>bye!</bye>";

becomes a list suchlike -

[ '<this>', 'this is tagged', '</this>', ' ', '<bye>', 'bye!', '</bye>' ]
the below works, but only if TOKEN is specified as 'TAG | LITERAL' .. i'm sure there are a billion things i don't understand about Parse::RecDescent
$Parser = Parse::RecDescent->new( q( TAG : <skip:''> /\\<.*?\\>/ LITERAL : <skip:''> /[^<]*/ TOKEN : TAG | LITERAL startrule: TOKEN(s) { @main::PARSED = @{$item[1]}; } ) );
can anyone shed any light on why TOKEN would not evaluate in an OR | context properly if the arguments are reversed? (any other comments on what i may be doing improperly are more than welcome)

thanks!

Edit kudra, 2002-10-27 Replaced code tags around entire message with markup