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 -
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[ '<this>', 'this is tagged', '</this>', ' ', '<bye>', 'bye!', '</bye>' ]
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)$Parser = Parse::RecDescent->new( q( TAG : <skip:''> /\\<.*?\\>/ LITERAL : <skip:''> /[^<]*/ TOKEN : TAG | LITERAL startrule: TOKEN(s) { @main::PARSED = @{$item[1]}; } ) );
thanks!
Edit kudra, 2002-10-27 Replaced code tags around entire message with markup
Back to
Seekers of Perl Wisdom