Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-25 10:27:22


----- Original Message -----
From: "Greg Colvin" <gcolvin_at_[hidden]>
> > I always intended to subsume the lexer. I, for one, am not a
> > fan of posix style regular expressions. Reading one gives me
> > a headache. Here's a sample from boost::regex:
> >
> > "<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"
> >
> > Arghh, give me an aspirin!
>
> Me too. But what does the above look like in Spirit?

FWIW, Python's regex syntax (which it stole from Perl) allows an optional
"verbose" mode, where whitespace and comments are ignored unless
specifically escaped. This can be used very effectively in complex
expressions to make them readable. It also includes some special "raw
string" quoting tokens which prevent the need to escape backslashes and even
(using triple quotes) quotation marks:

r"""<\s* # opening delimiter
    A\s+[^>]* # any amount of garbage before href
    href\s*=\s*
    "([^"]*)\
"""

I thought this might provide inspiration for more rational syntaxes.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk