Making a C Refactoring Program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pingu219@gmail.com

    Making a C Refactoring Program

    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.
  • santosh

    #2
    Re: Making a C Refactoring Program

    pingu219@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 >

    Comment

    • pingu219@gmail.com

      #3
      Re: Making a C Refactoring Program

      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.

      Comment

      Working...