Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-09-13 09:56:32


Andy Little wrote:
> Hi Eric,
>
> Boost already has Regex. What is different about xpressive?
>
> regards
> Andy Little
>

Although xpressive's primitives are regex-ish in nature, xpressive is
far more than just a regular expression engine. (The docs don't make
this point strongly enough, my bad.) xpressive is a pattern matching
engine with the power of context-free grammars. By allowing you to embed
one pattern in another by reference, xpressive lets you find patterns in
data that are recursive in nature. Problems that are intractible with
"classic" regular expressions, such as matching balanced nested
parentheses or matching XML tags, are simple with xpressive. So
xpressive is more rightly thought of as a context-free grammar engine
with exhaustive backtracking. The goal is to provide one framework and
one set of pattern matching primitives that scales from simple
strstr-style grepping, through ordinary regexing, all the way to
full-blown parsing.

That's the primary difference. Other differences flow from that one,
like the ability to find patterns in non-char data, and better
integration with "real" C++. The latter point is a work in progress, but
the ultimate goal is to make it as simple to call C++ code from a regex
as it is to call a regex from C++. That includes things like
user-defined predicates (extending the set of regex primitives),
assignment to variables (string, list, map) from withing the regex, and
semantic actions.

It's true that there is functional overlap between Regex and xpressive,
but xpressive takes a much broader view of pattern matching. And just
because one piece of this puzzle has been proposed for standardization
doesn't mean that all innovation in this problem space must cease.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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