forked from boostorg/regex
Updated examples with better comment on expressions. Updated test program to test for apparent Rogur Wave bug (and it's workaround).
[SVN r11390]
This commit is contained in:
@ -31,7 +31,29 @@
|
|||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
||||||
|
|
||||||
boost::regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)");
|
const char* re =
|
||||||
|
// possibly leading whitespace:
|
||||||
|
"^[[:space:]]*"
|
||||||
|
// possible template declaration:
|
||||||
|
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||||
|
// class or struct:
|
||||||
|
"(class|struct)[[:space:]]*"
|
||||||
|
// leading declspec macros etc:
|
||||||
|
"("
|
||||||
|
"\\<\\w+\\>"
|
||||||
|
"("
|
||||||
|
"[[:blank:]]*\\([^)]*\\)"
|
||||||
|
")?"
|
||||||
|
"[[:space:]]*"
|
||||||
|
")*"
|
||||||
|
// the class name
|
||||||
|
"(\\<\\w*\\>)[[:space:]]*"
|
||||||
|
// template specialisation parameters
|
||||||
|
"(<[^;:{]+>)?[[:space:]]*"
|
||||||
|
// terminate in { or :
|
||||||
|
"(\\{|:[^;\\{()]*\\{)";
|
||||||
|
|
||||||
|
boost::regex expression(re);
|
||||||
|
|
||||||
class IndexClassesPred
|
class IndexClassesPred
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,30 @@
|
|||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
||||||
|
|
||||||
boost::regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)");
|
const char* re =
|
||||||
|
// possibly leading whitespace:
|
||||||
|
"^[[:space:]]*"
|
||||||
|
// possible template declaration:
|
||||||
|
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||||
|
// class or struct:
|
||||||
|
"(class|struct)[[:space:]]*"
|
||||||
|
// leading declspec macros etc:
|
||||||
|
"("
|
||||||
|
"\\<\\w+\\>"
|
||||||
|
"("
|
||||||
|
"[[:blank:]]*\\([^)]*\\)"
|
||||||
|
")?"
|
||||||
|
"[[:space:]]*"
|
||||||
|
")*"
|
||||||
|
// the class name
|
||||||
|
"(\\<\\w*\\>)[[:space:]]*"
|
||||||
|
// template specialisation parameters
|
||||||
|
"(<[^;:{]+>)?[[:space:]]*"
|
||||||
|
// terminate in { or :
|
||||||
|
"(\\{|:[^;\\{()]*\\{)";
|
||||||
|
|
||||||
|
|
||||||
|
boost::regex expression(re);
|
||||||
map_type class_index;
|
map_type class_index;
|
||||||
std::string::const_iterator base;
|
std::string::const_iterator base;
|
||||||
|
|
||||||
|
@ -33,6 +33,29 @@
|
|||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
||||||
|
|
||||||
|
const char* re =
|
||||||
|
// possibly leading whitespace:
|
||||||
|
"^[[:space:]]*"
|
||||||
|
// possible template declaration:
|
||||||
|
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||||
|
// class or struct:
|
||||||
|
"(class|struct)[[:space:]]*"
|
||||||
|
// leading declspec macros etc:
|
||||||
|
"("
|
||||||
|
"\\<\\w+\\>"
|
||||||
|
"("
|
||||||
|
"[[:blank:]]*\\([^)]*\\)"
|
||||||
|
")?"
|
||||||
|
"[[:space:]]*"
|
||||||
|
")*"
|
||||||
|
// the class name
|
||||||
|
"(\\<\\w*\\>)[[:space:]]*"
|
||||||
|
// template specialisation parameters
|
||||||
|
"(<[^;:{]+>)?[[:space:]]*"
|
||||||
|
// terminate in { or :
|
||||||
|
"(\\{|:[^;\\{()]*\\{)";
|
||||||
|
|
||||||
|
|
||||||
class class_index
|
class class_index
|
||||||
{
|
{
|
||||||
boost::regex expression;
|
boost::regex expression;
|
||||||
@ -45,7 +68,7 @@ public:
|
|||||||
void IndexClasses(const std::string& file);
|
void IndexClasses(const std::string& file);
|
||||||
class_index()
|
class_index()
|
||||||
: index(),
|
: index(),
|
||||||
expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)")
|
expression(re)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,6 +33,29 @@
|
|||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
||||||
|
|
||||||
|
const char* re =
|
||||||
|
// possibly leading whitespace:
|
||||||
|
"^[[:space:]]*"
|
||||||
|
// possible template declaration:
|
||||||
|
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||||
|
// class or struct:
|
||||||
|
"(class|struct)[[:space:]]*"
|
||||||
|
// leading declspec macros etc:
|
||||||
|
"("
|
||||||
|
"\\<\\w+\\>"
|
||||||
|
"("
|
||||||
|
"[[:blank:]]*\\([^)]*\\)"
|
||||||
|
")?"
|
||||||
|
"[[:space:]]*"
|
||||||
|
")*"
|
||||||
|
// the class name
|
||||||
|
"(\\<\\w*\\>)[[:space:]]*"
|
||||||
|
// template specialisation parameters
|
||||||
|
"(<[^;:{]+>)?[[:space:]]*"
|
||||||
|
// terminate in { or :
|
||||||
|
"(\\{|:[^;\\{()]*\\{)";
|
||||||
|
|
||||||
|
|
||||||
class class_index
|
class class_index
|
||||||
{
|
{
|
||||||
boost::regex expression;
|
boost::regex expression;
|
||||||
@ -47,7 +70,7 @@ public:
|
|||||||
void IndexClasses(const std::string& file);
|
void IndexClasses(const std::string& file);
|
||||||
class_index()
|
class_index()
|
||||||
: index(),
|
: index(),
|
||||||
expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)")
|
expression(re)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,30 @@
|
|||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
||||||
|
|
||||||
boost::regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)");
|
const char* re =
|
||||||
|
// possibly leading whitespace:
|
||||||
|
"^[[:space:]]*"
|
||||||
|
// possible template declaration:
|
||||||
|
"(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
||||||
|
// class or struct:
|
||||||
|
"(class|struct)[[:space:]]*"
|
||||||
|
// leading declspec macros etc:
|
||||||
|
"("
|
||||||
|
"\\<\\w+\\>"
|
||||||
|
"("
|
||||||
|
"[[:blank:]]*\\([^)]*\\)"
|
||||||
|
")?"
|
||||||
|
"[[:space:]]*"
|
||||||
|
")*"
|
||||||
|
// the class name
|
||||||
|
"(\\<\\w*\\>)[[:space:]]*"
|
||||||
|
// template specialisation parameters
|
||||||
|
"(<[^;:{]+>)?[[:space:]]*"
|
||||||
|
// terminate in { or :
|
||||||
|
"(\\{|:[^;\\{()]*\\{)";
|
||||||
|
|
||||||
|
|
||||||
|
boost::regex expression(re);
|
||||||
|
|
||||||
void IndexClasses(map_type& m, const std::string& file)
|
void IndexClasses(map_type& m, const std::string& file)
|
||||||
{
|
{
|
||||||
|
@ -37,11 +37,16 @@ using namespace boost;
|
|||||||
flag_info flag_data[] = {
|
flag_info flag_data[] = {
|
||||||
{ BOOST_RE_STR("REG_BASIC"), 9, REG_BASIC, 0 },
|
{ BOOST_RE_STR("REG_BASIC"), 9, REG_BASIC, 0 },
|
||||||
{ BOOST_RE_STR("REG_EXTENDED"), 12, REG_EXTENDED, 0 },
|
{ BOOST_RE_STR("REG_EXTENDED"), 12, REG_EXTENDED, 0 },
|
||||||
|
{ BOOST_RE_STR("REG_ESCAPE_IN_LISTS"), 19, REG_ESCAPE_IN_LISTS, 0 },
|
||||||
{ BOOST_RE_STR("REG_ICASE"), 9, REG_ICASE, 0 },
|
{ BOOST_RE_STR("REG_ICASE"), 9, REG_ICASE, 0 },
|
||||||
{ BOOST_RE_STR("REG_NOSUB"), 9, REG_NOSUB, 0 },
|
{ BOOST_RE_STR("REG_NOSUB"), 9, REG_NOSUB, 0 },
|
||||||
{ BOOST_RE_STR("REG_NEWLINE"), 11, REG_NEWLINE, 0 },
|
{ BOOST_RE_STR("REG_NEWLINE"), 11, REG_NEWLINE, 0 },
|
||||||
{ BOOST_RE_STR("REG_NEWLINE"), 11, REG_NEWLINE, 0 },
|
{ BOOST_RE_STR("REG_NOCOLLATE"), 13, REG_NOCOLLATE, 0 },
|
||||||
{ BOOST_RE_STR("REG_NOSPEC"), 10, REG_NOSPEC, 0 },
|
{ BOOST_RE_STR("REG_NOSPEC"), 10, REG_NOSPEC, 0 },
|
||||||
|
{ BOOST_RE_STR("REG_NEWLINE_ALT"), 15, REG_NEWLINE_ALT , 0 },
|
||||||
|
{ BOOST_RE_STR("REG_PERL"), 8, REG_PERL, 0 },
|
||||||
|
{ BOOST_RE_STR("REG_AWK"), 7, REG_AWK, 0 },
|
||||||
|
{ BOOST_RE_STR("REG_EGREP"), 9, REG_EGREP, 0 },
|
||||||
|
|
||||||
{ BOOST_RE_STR("REG_NOTBOL"), 10, REG_NOTBOL, 1 },
|
{ BOOST_RE_STR("REG_NOTBOL"), 10, REG_NOTBOL, 1 },
|
||||||
{ BOOST_RE_STR("REG_NOTEOL"), 10, REG_NOTEOL, 1 },
|
{ BOOST_RE_STR("REG_NOTEOL"), 10, REG_NOTEOL, 1 },
|
||||||
|
@ -503,8 +503,10 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3
|
|||||||
'([^\\']|\\.)*' '\\n' 0 4 1 3
|
'([^\\']|\\.)*' '\\n' 0 4 1 3
|
||||||
|
|
||||||
; now try and test some unicode specific characters:
|
; now try and test some unicode specific characters:
|
||||||
- match_default normal REG_EXTENDED REG_UNICODE_ONLY
|
- match_default normal REG_PERL REG_UNICODE_ONLY
|
||||||
[[:unicode:]]+ a\0300\0400z 1 3
|
[[:unicode:]]+ a\0300\0400z 1 3
|
||||||
|
[\x10-\xff] \39135\12409 -1 -1
|
||||||
|
[\01-\05]{5} \36865\36865\36865\36865\36865 -1 -1
|
||||||
|
|
||||||
; finally try some case insensitive matches:
|
; finally try some case insensitive matches:
|
||||||
- match_default normal REG_EXTENDED REG_ICASE
|
- match_default normal REG_EXTENDED REG_ICASE
|
||||||
@ -880,3 +882,4 @@ a+(?#b+)b+ xaaabbba 1 7
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user