Update of /cvsroot/boost/boost/libs/xpressive/tools
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26975
Modified Files:
perl2xpr.cpp
Log Message:
add -i option for perl's /i modifier
Index: perl2xpr.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/tools/perl2xpr.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- perl2xpr.cpp 30 Apr 2007 19:20:56 -0000 1.2
+++ perl2xpr.cpp 1 May 2007 00:29:50 -0000 1.3
@@ -18,6 +18,7 @@
int main(int argc, char *argv[])
{
int i = 1;
+ bool nocase = false;
char const *dot = " ~_n ";
char const *bos = " bos ";
char const *eos = " eos ";
@@ -26,6 +27,9 @@
{
switch(argv[i][1])
{
+ case 'i': // perl /i modifier
+ nocase = true;
+ break;
case 's': // perl /s modifier
dot = " _ ";
break;
@@ -41,7 +45,7 @@
if(i == argc)
{
- std::cerr << "Usage:\n perl2xpr [-s] [-m] 're'\n";
+ std::cerr << "Usage:\n perl2xpr [-i] [-s] [-m] 're'\n";
return -1;
}
@@ -68,14 +72,14 @@
| _ [top(strings) += " as_xpr('" + _ + "') "]
;
- group = as_xpr("?:") [top(strings) += " ( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?i:") [top(strings) += " icase( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?>") [top(strings) += " keep( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?=") [top(strings) += " before( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?!") [top(strings) += " ~before( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?<=") [top(strings) += " after( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | as_xpr("?<!") [top(strings) += " ~after( "] >> by_ref(regex)
>> as_xpr(')') [top(strings) += " ) "]
- | nil [top(strings) += " ( s" + as<std::string>(++mark_nbr) + "=
"] >> by_ref(regex) >> as_xpr(')') [top(strings) += " ) "]
+ group = as_xpr("?:") [top(strings) += " ( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?i:") [top(strings) += " icase( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?>") [top(strings) += " keep( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?=") [top(strings) += " before( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?!") [top(strings) += " ~before( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?<=") [top(strings) += " after( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | as_xpr("?<!") [top(strings) += " ~after( "] >> ref(regex) >>
as_xpr(')') [top(strings) += " ) "]
+ | nil [top(strings) += " ( s" + as<std::string>(++mark_nbr) + "=
"] >> ref(regex) >> as_xpr(')') [top(strings) += " ) "]
;
setelem = as_xpr('\\') >> _ [top(strings) += " as_xpr('" + _ + "') "]
@@ -142,6 +146,10 @@
std::cerr << "ERROR: unrecognized regular expression" << std::endl;
return -1;
}
+ else if(nocase)
+ {
+ std::cout << "icase( " << strings.get().top() << " )" << std::endl;
+ }
else
{
std::cout << strings.get().top() << std::endl;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs