in reply to multiple occurences when using Parse::RecDescent
If I understand the problem correctly, a grammar along the following lines should do what you want:
It tells the parser that there should be one or more statements, separated by endlines.my $grammar = q { startrule: statement (endline statement)(s?) statement: print open text end print: "print" open: "'" text: /([^']*)/ end: "'" endline: /(\n|\r)+/ };
Hope this helps, -gjb-
Update: graff is correct, the above grammar unfortunately doesn't work on closer inspection, his is the solution I came up with after fixing mine with the exception of /^\Z/ as a terminator.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multiple occurences when using Parse::RecDescent
by graff (Chancellor) on Mar 30, 2005 at 09:45 UTC |