bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regular Expression to math class references using grep


From: cosmopolitan
Subject: Regular Expression to math class references using grep
Date: Fri, 28 May 2010 07:47:17 -0700 (PDT)

I'm trying to math all class references in a C++ file using grep with regular
expression. I'm trying to know if a specific include is usuless or not, so I
have to know if there is a refence in cpp. 
I wrote this RE that searches for a reference from class ABCZ, but
unfortunately it isn't working as I espected:

 grep -E '^[^(\/\*)(\/\/)].*[^a-zA-Z]ABCZ[]*[\*\(\<:;,{& ]'

^[^(\/\*)(\/\/)]  don't math comments in the begging of the line ( // or /*
)
.* followed by any character
[^a-zA-Z] do not accept any caracter before the one I'm searching (like
defABCZ)
[]* any white space (I can have something like ABCZ     var;)
[\*\(\<:;,{& ] followed by ( * < : ; , & { (I cant get #define "ABCZ.h" or
ABCZdef for example)

Well, I can get patterns like this:

class Test: public ABCZ{
class Test: public ABCZ {
class Test :public ABCZ<T>
class NameSpace::Test :public ABCZ<T>
ABCZ var = ABCZ();
ABCZ* var = new ABCZ();
ABCZ* var = new ABCZ<T>();
teste = ABCZ(var);
teste = ABCZ(var, otherVar);
teste = ABCZ(var,otherVar);
teste =     ABCZ();
funct(*ABCZ av);
struct(ABCZ, BBBB, CCCC);
const ABCZ& getNot_before(void) const;

That's all right, they are all acceptable patterns. But these I'm missing,
and they are all acceptable too:

ABCZ        teste;
ABCZ        teste; //comment
ABCZ        teste; /* comment*/
ABCZ teste; /* comment*/
ABCZ teste;
ABCZ *teste;

And all these are not acceptable:
#include "ABCZ.h"
//ABCZ var = ABCZ();
ABCZdef a = ABCZdef();
DefABCZ a = DefABCZ();
ABCZdef a = ABCZdef();
/*ABCZ var = ABCZ();

I don't know if I'm missing any other patterns, if I am, please tell me =p
What am I doing wrong?
I'll be very grateful if someone answer me :)
Thanks in advance
-- 
View this message in context: 
http://old.nabble.com/Regular-Expression-to-math-class-references-using-grep-tp28707847p28707847.html
Sent from the Gnu - Grep mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]