a python suggestion!
hi guys,
I need to develop an application in python which take some .c,.h source file as an input and analyses the text in them and finally reports ,if there is any kind of coding violation is there! CAn any one sugget any site for such a parser kind of utility or any algorithm to carry out such job. |
By "coding violation" I assume you mean syntax error (or some other
problem that would cause compilation to fail). What you need is a full C parser, which is not a trivial task, so put it mildly. You could use flax+bison to build such a parser and call it from your Python code, but that is a pretty large task. But why not let the C compiler do it for you? You can run the C compiler from your Python code, pipe its output back to your code and look for error messages in it. This will save you a huge amount of time and nothing you do will be as accurate as this. If that is not acceptable, and if you don't mind finding only a subset of the problems, I think I remember seeing somewhere a Python interface to parsers built using flex+bison (or Lex+Yacc). Go Google for it. I will be surprised if anyone anywhere published a parser for C that you could use as is. It does not make sense to do this outside the scope of a full compiler or translator. Hope that helps. |
thanx mishunimi!
Actuually, i m not to that much level of comlexity! i need to check for certain kind of coding violations which actually are not syntatical errors!. Like any binary operatior should have one space around itself. like a + b but not a +b or a+b and there is a large set of such kind of violations that can occur ! so i was consdering if i make a generic kind of utility! and keep on adding the rules to check afterwards!, that wud be nice ! i hope u understand! |
Quote:
|
yup!
FUN FUN FUN! |
All times are GMT -5. The time now is 03:00 AM. |