rkg has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write a rule to match a term. A term is one or more words, separated by underscores. Neither terms nor words can contain whitespace. These are valid terms: apple, apple_pear, apple_plum_grape. These are not valid terms: _, _apple, apple_, apple__pear. Can anyone give me guidance on writing the rule for term and word? Do I need a <skip> directive to indicate a term cannot contain whitespace? Here's what I have, which does not work. Many thanks!CSVLine: QuotedText(s Comma) { do something}
rkgmy $g = q( Word: /^[A-Z]+$/i {return $item[1]} TermSep: '_' Term: Word(s TermSep) { use Data::Dumper; Dumper($item[1]) } Line: Term {$item[1]} );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ParseRecDescent and csv-like data
by Elian (Parson) on Aug 21, 2003 at 13:45 UTC | |
|
Re: ParseRecDescent and csv-like data
by dreadpiratepeter (Priest) on Aug 21, 2003 at 13:47 UTC | |
|
Re: ParseRecDescent and csv-like data
by Abigail-II (Bishop) on Aug 21, 2003 at 14:51 UTC | |
|
Re: ParseRecDescent and csv-like data
by gjb (Vicar) on Aug 21, 2003 at 14:18 UTC | |
by rkg (Hermit) on Aug 21, 2003 at 16:05 UTC | |
|
Re: ParseRecDescent and csv-like data
by rkg (Hermit) on Aug 21, 2003 at 17:15 UTC |