Boost logo

Boost Users :

Subject: Re: [Boost-users] [xpressive] assert while matching file contents.
From: Raindog (raindog_at_[hidden])
Date: 2008-09-24 18:37:40


Eric Niebler wrote:
> Raindog wrote:
>> Hello,
>>
>> I have the following regex:
>>
>> sregex sig_re = "@rem {" >>(sig_= -*_)>> "}, " >> (vbp_= -*_) >> _ln;
>>
>> which I am trying to use to match the last line of the following string.
>> The string is read in from a file.
>>
>> xcopy "foo" "foo3.bat" /Y
>> xcopy "foo" "foo3.bat" /Y
>> xcopy "foo" "foo3.bat" /Y
>> xcopy "foo" "foo3.bat" /Y
>> @rem c:\foo\somefile.txt files: 4
>> @rem {0xffffffff, SOMETYPEDEF, ""}, //c:\foo\somefile.txt
>>
>> When I call:
>>
>> sregex_iterator cur(file_contents.begin(), file_contents.end(),
>> sig_re);
>>
>> however, I get an assertion:
>>
>> Assertion failed: !s0.matched, file
>> c:\code\boost-trunk\boost\xpressive\detail\core\matcher\end_matcher.hpp,
>> line 37
>
>
>
> I cannot reproduce your error. The following works (doesn't assert)
> for me:
>
> mark_tag sig_(1), vbp_(2);
> sregex sig_re = "@rem {" >>(sig_= -*_)>> "}, " >> (vbp_= -*_) >> _ln;
>
> std::string file_contents =
> "xcopy \"foo\" \"foo3.bat\" /Y\n"
> "xcopy \"foo\" \"foo3.bat\" /Y\n"
> "xcopy \"foo\" \"foo3.bat\" /Y\n"
> "xcopy \"foo\" \"foo3.bat\" /Y\n"
> "@rem c:\\foo\\somefile.txt files: 4\n"
> "@rem {0xffffffff, SOMETYPEDEF, \"\"},
> //c:\\foo\\somefile.txt\n";
>
> sregex_iterator cur(file_contents.begin(), file_contents.end(),
> sig_re);
>
>
>
> Please post complete source that reproduces the problem. Thanks.
>
>
    mark_tag file_(0), vbp_(1), sig_(2);
    sregex files_re = "xcopy" >> -*_ >> "/Y" >> _n;
    sregex vbp_re = "@rem " >> -*_ >> " files: " >> repeat<1, 4>(_d) >> _ln;
    sregex sig_re = "@rem {" >> -*_>> "}, " >> *~_ln;

    //Combine above regexes to allow for only one search through the file.
    sregex whole_string_re =
        (file_=*files_re) >>
        (vbp_=vbp_re) >>
        (sig_=sig_re);

    sregex_iterator cur(file_contents.begin(), file_contents.end(),
whole_string_re);
    sregex_iterator end;

What I was trying to do was instead of searching for matches multiple
times, I decided to combine files_re, vbp_re and sig_re into 1 regex and
just do 1 search. That was when I had the assertion. If I change

    (file_=*files_re) >>

to

    *files_re >>

Then it works, but I don't have the capture group I wanted.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net