diff --git a/example/snippets/regex_grep_example_1.cpp b/example/snippets/regex_grep_example_1.cpp index 846a0ee8..602c398a 100644 --- a/example/snippets/regex_grep_example_1.cpp +++ b/example/snippets/regex_grep_example_1.cpp @@ -31,7 +31,29 @@ typedef std::map > 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 { diff --git a/example/snippets/regex_grep_example_2.cpp b/example/snippets/regex_grep_example_2.cpp index b7b01f92..6a7d043a 100644 --- a/example/snippets/regex_grep_example_2.cpp +++ b/example/snippets/regex_grep_example_2.cpp @@ -32,7 +32,30 @@ typedef std::map > 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; std::string::const_iterator base; diff --git a/example/snippets/regex_grep_example_3.cpp b/example/snippets/regex_grep_example_3.cpp index e3ab8785..2712be0b 100644 --- a/example/snippets/regex_grep_example_3.cpp +++ b/example/snippets/regex_grep_example_3.cpp @@ -33,6 +33,29 @@ typedef std::map > 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 { boost::regex expression; @@ -45,7 +68,7 @@ public: void IndexClasses(const std::string& file); class_index() : index(), - expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)") + expression(re) {} }; diff --git a/example/snippets/regex_grep_example_4.cpp b/example/snippets/regex_grep_example_4.cpp index fd7ea6fd..f524aafd 100644 --- a/example/snippets/regex_grep_example_4.cpp +++ b/example/snippets/regex_grep_example_4.cpp @@ -33,6 +33,29 @@ typedef std::map > 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 { boost::regex expression; @@ -47,7 +70,7 @@ public: void IndexClasses(const std::string& file); class_index() : index(), - expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\\{|:[^;\\{()]*\\{)") + expression(re) {} }; diff --git a/example/snippets/regex_search_example.cpp b/example/snippets/regex_search_example.cpp index 0f48fe23..8d4f9874 100644 --- a/example/snippets/regex_search_example.cpp +++ b/example/snippets/regex_search_example.cpp @@ -31,7 +31,30 @@ typedef std::map > 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) { diff --git a/test/regress/parse.cpp b/test/regress/parse.cpp index 11c86ef3..91f5ede1 100644 --- a/test/regress/parse.cpp +++ b/test/regress/parse.cpp @@ -37,11 +37,16 @@ using namespace boost; flag_info flag_data[] = { { BOOST_RE_STR("REG_BASIC"), 9, REG_BASIC, 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_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_NOCOLLATE"), 13, REG_NOCOLLATE, 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_NOTEOL"), 10, REG_NOTEOL, 1 }, diff --git a/test/regress/tests.txt b/test/regress/tests.txt index 3d944dae..10c61b35 100644 --- a/test/regress/tests.txt +++ b/test/regress/tests.txt @@ -503,8 +503,10 @@ a(b+|((c)*))+d abcd 0 4 2 3 2 3 2 3 '([^\\']|\\.)*' '\\n' 0 4 1 3 ; 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 +[\x10-\xff] \39135\12409 -1 -1 +[\01-\05]{5} \36865\36865\36865\36865\36865 -1 -1 ; finally try some case insensitive matches: - match_default normal REG_EXTENDED REG_ICASE @@ -880,3 +882,4 @@ a+(?#b+)b+ xaaabbba 1 7 +