LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2005, 06:11 AM   #1
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Rep: Reputation: 16
Smile 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.
 
Old 06-12-2005, 06:06 PM   #2
mishunimi
LQ Newbie
 
Registered: Feb 2004
Location: Israel
Distribution: Kubuntu
Posts: 7

Rep: Reputation: 0
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.
 
Old 06-14-2005, 09:38 AM   #3
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
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!
 
Old 06-14-2005, 09:40 AM   #4
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Quote:
Originally posted by kapsikum
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!
Sounds like you would be using a lot of regular expressions. Fun fun fun!
 
Old 07-01-2005, 04:27 AM   #5
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
yup!

FUN FUN FUN!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
installing python library's (Python Numeric) Four Linux - Newbie 1 10-16-2005 02:31 PM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 04:07 PM
Try Python, O'reilly Learning Python haknot Programming 5 02-15-2002 08:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration