Re: Line continuation characters

[email protected] ((Randal L. Schwartz))
Newsgroups perl.recdescent
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "Marc" == Marc Mims <[email protected]> writes:

Marc> I need to parse a grammar that includes line continuation
Marc> characters.  For example:

Marc> // COMMAND ARG1-VALUE,ARG2-VALUE, +
Marc>    ARG3-VALUE,ARG4-VALUE, +
Marc>    EVEN-MORE-ARGS
Marc> // ANOTHERCOMMAND
Marc> * and a comment
Marc> * or two

Marc> How do I formulate a rule (or rules) to treat the first command
Marc> as if all 5 arguments were specified on a single line?  I need to
Marc> skip over the /\s*+\n\s*/ sequence.  It seems like skip or resync
Marc> should do this for me, but if so, I haven't discovered the
Marc> correct technique, yet.

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.

-- 
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!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.