Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-01-03 17:19:35


Bjørn Roald wrote:
> On Tuesday 03 January 2006 22:00, Eric Niebler wrote:
>
>>Bjørn Roald wrote:
>>>
>>>I tried to use the xpressive library from the Boost CVS and I ran into
>>>some problems. Do I understand the above to mean that the Vault version
>>>is a better choice?
>>
>>No, the Vault is pretty much the same as what is in CVS at the moment.
>>What is the problem you're seeing?
>
> Using static regexp to create simple grammars I encountered two problems.
>
> 1.
> The example code for nested grammar in the documentation produced only
> printout of part of the results compared to the documentation.

Do you mean the calculator example? For me, this program:

     std::string str("foo 9*(10+3) bar");
     smatch what;

     sregex group, factor, term, expression;

     group = '(' >> by_ref(expression) >> ')';
     factor = +_d | group;
     term = factor >> *(('*' >> factor) | ('/' >> factor));
     expression = term >> *(('+' >> term) | ('-' >> term));

     if(regex_search(str, what, expression))
     {
         std::cout << what[0] << std::endl;
     }

prints out this:

     9*(10+3)

which is correct, and agrees with the docs. If you mean the regex for
matching balanced nested parentheses, I just tried that too and got the
expected results.

> 2.
> Creating a more complex grammar with static regexp I encountered core dumps
> attempting to print nested matches. Call stack is listed below.

This sounds an awful lot like the bug I just fixed (and committed to CVS
at 2am this morning). Are you sure you have the latest? If you do,
please post code that reproduces the error and I'll fix it. Even if the
recent changes fixed your problem, if you send the code anyway, I'll add
it to xpressive's regression test. (Hint: you should do this.)

-- 
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