E
expert.cpp
Hi, I'm trying to use this regex code:
const boost::regex::flag_type f = boost::regex_constants::normal |
boost::regbase::icase;
const boost::regex fooo(
".*"
"unit"
"[ \t]+"
"[A-Z]|[a-z](?:[A-Z]|[a-z]|[0-9]|_)*"
"[ \t\n]+?"
"\{"
"[ \t\n]+"
"(.*)"
"\}"
"([^}]*)"
, f);
const std::string sTemp(szFileBuf); // ÉÓÈÏÄÎÙÊ ÔÅËÓÔ × szFileBuf
boost::match_results<std::string::const_iterator> what;
bool bRet = boost::regex_match(sTemp, what, fooo);
to get the body of block "unit" (just a list of function definitions)
and the last part: a call to one of those functions, In this case it
is MainFunction(), from this file
// comments
unit XXX
{
//
#include "header.h"
// arbitrary number of C/C++ functions
a_type Function1([optional args])
{
// C/C++ code
}
a_type FunctionN([optional args])
{
// C/C++ code
}
type MainFunction([optional args])
{
// C/C++ code
}
}
MainFunction();
It works with first 4 parts of regular expression. But it crashes when
I add other parts.
Can somebody help me correct this regex?
I'm doint that on Vista 64-bit, with Visual Studio 2005, boost::regex
linked statically if that matters.
Thanks,
Sava
const boost::regex::flag_type f = boost::regex_constants::normal |
boost::regbase::icase;
const boost::regex fooo(
".*"
"unit"
"[ \t]+"
"[A-Z]|[a-z](?:[A-Z]|[a-z]|[0-9]|_)*"
"[ \t\n]+?"
"\{"
"[ \t\n]+"
"(.*)"
"\}"
"([^}]*)"
, f);
const std::string sTemp(szFileBuf); // ÉÓÈÏÄÎÙÊ ÔÅËÓÔ × szFileBuf
boost::match_results<std::string::const_iterator> what;
bool bRet = boost::regex_match(sTemp, what, fooo);
to get the body of block "unit" (just a list of function definitions)
and the last part: a call to one of those functions, In this case it
is MainFunction(), from this file
// comments
unit XXX
{
//
#include "header.h"
// arbitrary number of C/C++ functions
a_type Function1([optional args])
{
// C/C++ code
}
a_type FunctionN([optional args])
{
// C/C++ code
}
type MainFunction([optional args])
{
// C/C++ code
}
}
MainFunction();
It works with first 4 parts of regular expression. But it crashes when
I add other parts.
Can somebody help me correct this regex?
I'm doint that on Vista 64-bit, with Visual Studio 2005, boost::regex
linked statically if that matters.
Thanks,
Sava