Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2005-09-25 22:11:19

Eric Niebler wrote:
> Joel de Guzman wrote:
>>Tom Brinkman wrote:
>>>* What is your evaluation of the potential usefulness of the library?
>>>As others have indicated, there is some overlap with other boost libraries.
>>>However, the emphasis of xpressive is different and
>>>somewhat more flexible.
>>Flexible in what way please? ;-)
>>I should know, so I could steal that "flexibility" :P
> Certainly I would like to hear Tom's answer. But your question reminds
> me that that I've spent some time describing how xpressive is different
> than Boost.Regex, but none describing how it's different than Spirit. In
> no particular order:
> - Rather than relying exclusively on expression templates, which are
> fixed at compile time, xpressive lets you write patterns as strings as
> well, so you can specify than at runtime or read them from an
> initialization file.

Yeah. Here's a bit of a historical trivia. Spirit started out as
a parser compiler where rules are defined by strings like:
"r ::= ('a' | 'b')*;"; (notice the real EBNF syntax). Here's
a very early doc of the thing: .
I actually needed a parser to parse Spirit following the formal
grammar presented. This parser started out hand coded. Over time,
this hand-coded parser evolved to be a low level parser using
expression templates, which became what Spirit is now. Someday,
I'll resurrect the string based parser. I've had lots of requests
for such a beast.

> - xpressive has exhaustive backtracking semantics, which you can
> selectively turn off using the keep() directive. Spirit doesn't have an
> exhaustive backtracking option.

Right[*]. Actually, Spirit's main thrust now seems to be towards
non-backtracking, predictive parsing, due to the problems of
backtracking and semantic actions, not to mention the cubic
worst case performance. Maybe Spirit can banish backtracking
altogether and simply call on Xpressive as a Spirit plugin
whan that is really needed.

[*] Actually Right Recursion can be used in absence of exhaustive
backtracking (See:

> - xpressive::regex, unlike spirit::rule, has normal value semantics so
> you can copy them and put them in std containers.

Good point. I'm highly considering moving towards xpressive's

> - xpressive::regex keeps its referenced regexes alive via reference
> counting, so you can never have a dangling reference. spirit::rule
> doesn't, nor does spirit::grammar<> IIUC.


> Taken together, it means you can pretty quickly and easily put together
> a grammar in an ad hoc manner.

Very good points! That is why I vote for Xpressive :-)
I need a screw driver, pliers and a hammer, please!


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at