ROSE Compiler Framework/Big Picture

It is essential to understand what ROSE is so you can decide if it can help you solve your problems.

What is ROSE
ROSE is a library providing users access to compiler technology that was hitherto inaccessible to non-experts.

What is compiler technology? Compilers are sophisticated software that translate source code into machine binaries. Compiler developers have created powerful techniques to parse, analyze, transform and optimize the input source code.

Traditional compilers like GCC use these techniques, but they are essentially inaccessible to the user. However, even if the user had these capabilities in gcc, evaluating the results would be extremely difficult. The user inputs source code, the compiler outputs machine code. The user has access to his own code and perhaps the code generation at the assembly level, but comparing the two is extremely difficult as the code generation involved is not for clarity, it is for the needs of the compiler developer.

But what if a compiler returned a faithful source code representation of the post-transformation changes? Taking the original source code to transformed source code. A source-to-source compiler.

ROSE is a source-to-source compiler.

ROSE gives the user a library of compiler techniques. It also gives the user access to the building blocks of source analysis, allowing the user to create their own compilers, analyzers, translators, preprocessors, and so on.

If this is the sort of tool you are looking for, continue further into the wiki to learn more about ROSE.

How to use it
A typical use scenario of ROSE is that
 * Input: you have source code as input, such as myfile.c
 * Your ROSE-based translator/analyzer/compiler/tool: myTranslator.cpp
 * First of all, you call a frontend function provided by ROSE to generate an intermediate representation (IR or abstract syntax tree/AST to be accurate) of your input
 * Then, you call and compose other AST analysis/transformation/optimization functions provided by ROSE to analyze or transform the AST
 * Finally, you call the backend function provided by ROSE to unparse the analyzed and/or transformed AST to source code and optionally invoke a backend compiler (such as GCC) to generate the object codes.
 * Output: unparsed source code, named like rose_myfile.c, and optionally the object file generated from it, myfile.o

To be an efficient ROSE developer, you have to
 * get familiar with the AST of your input code since you have to write code to walk the tree, find the things you are interested in, and ultimately do analysis and transformation upon AST
 * get familiar with the functions provided by ROSE. The more functions you know, the faster you can get your work done since you can avoid re-inventing the wheel as much as possible.

With the big picture in mind, you can read though the documentations of ROSE to learn how to use it.