By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,884 Members | 949 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,884 IT Pros & Developers. It's quick & easy.

Making a C Refactoring Program

P: n/a
Hi I'm currently in the midst of building a C high-level refactoring
program in Java but I was wondering if there are any good parsers (or
some other alternative) which are able to read in C files at a
function or global level and allow transformations to the code, in
other words it will allow me to swap a function out of one file and
into another using the api etc...

ATM I'm using ANTLR to generate a C Lexer/parser from a C grammar file
and then using that lexer/parser to read in all the code into an
internal tree structure but that seems abit excessive...

Cheers

P.S Also any references to similar software out there which maps out C
(or some other language) projects would be greatly appreciated.
Mar 26 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
pi******@gmail.com wrote:
Hi I'm currently in the midst of building a C high-level refactoring
program in Java but I was wondering if there are any good parsers (or
some other alternative) which are able to read in C files at a
function or global level and allow transformations to the code, in
other words it will allow me to swap a function out of one file and
into another using the api etc...

ATM I'm using ANTLR to generate a C Lexer/parser from a C grammar file
and then using that lexer/parser to read in all the code into an
internal tree structure but that seems abit excessive...

Cheers

P.S Also any references to similar software out there which maps out C
(or some other language) projects would be greatly appreciated.
Since you are doing this in Java may be you can adapt the following
software to your needs?

<http://www.eclipsecon.com/articles/Article-LTK/ltk.html>

Also:

<http://www.refactoring.com/tools.html>
<http://www.joanju.com/dist/docs/tree_manip.html>

Mar 26 '08 #2

P: n/a
Hi thanks for all the replies.

I know it's going to be hard performing lower-level code refactoring
with C and if I did attempt it, it would really only be with
preprocessed code. Alot of refactoring patterns don't seem to suit
structured programming languages very well, you're left with only a
basic subset of fairly basic refactorings that are still applicable.

I'm focusing more on the higher-level file-level refactorings like if
say a certain function gets used alot in a particular file then it may
be better to move that function to that file if it's currently in a
different one, the same with global declarations etc..

So I would really only need basic parsing capability or better still
an existing basic program that lays out out the dependencies. I looked
at CDepend but the original author mentioned that it hadn't been
updated in awhile so it would be better to use objdump though that's a
little too sparse..

BTW does anyone know whether there's any research or literature that
focuses purely on the higher-level refactorings rather than basic low-
level code refactorings? Or is that going to be refactoring in
entirely different context? I'm finding it hard to put down the right
term for it.

Cheers and again thanks for the help so far.
Mar 26 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.