Re: Line continuation characters
[email protected] ((Randal L. Schwartz))
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Ted" == Ted Zlatanov <[email protected]> writes: Ted> [email protected] (Randal L. Schwartz) writes: >>>>>>> "Marc" == Marc Mims <[email protected]> writes: >> Marc> I need to parse a grammar that includes line continuation Marc> characters. For example: >> If the skip between tokens is any combination of spaces, tabs, or "+\n" combos, >> then say that: >> >> file: command(s) >> command: <skip: '(?:[ \t]+|\+\n)+'> commandline /\n/ >> commandline: "//" ... # real command >> commandline: "*" ... # comment >> >> You need to match a literal /\n/ at the end of your real >> command, since that's not matched by this skip. Ted> Because Marc's grammar seems to be otherwise line-oriented, I'd Ted> suggest preprocessing the grammar input to merge lines as needed, to Ted> simplify the grammar. The major disadvantage would be that line Ted> numbers would be off when reporting errors though. "line oriented grammar" => "requires preprocessing" doesn't seem to be very supportable logic. There's nothing inherent in P::RD that requires the grammar to be non-line-oriented. Now "metagrammar can appear within tokens" implies a need for a preprocessing layer. But from what I saw for examples, the metagrammar (line continuation) appears only outside of tokens, so that means it can be built into the skip matching logic. Don't overcomplicate the design... until you have to. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!