title: Antlr - How to generate exact input file to the output? (source-to-source transformation)
body: <p>Let's say I have a source code file. I want to give this file to the ANTLR and generate the same code and save it to an output file.</p>
  
  <p><strong>Usage:</strong> </p>
  
  <ol>
  <li>To beautify the input file.</li>
  <li>To add some comments to the input file.</li>
  <li>To inject some code into the input file.</li>
  </ol>
  
  <p>Is it possible to do such a thing by exploiting ANTLR?</p>
  
  <p>Basically, I am trying to do a <strong>source-to-source transformation with ANTLR</strong>  from C/C++ to C/C++.</p>
  
  <p>I am interested to add, delete, replace, or modify some lines of the code and generate an output that complies with C/C++ language rules. </p>
  
  <hr>
  
  <p>P.S.: Please let me know if you know any other tool (other than CLANG) that does the same thing. Parsing C/C++ (or even Fortran) and providing some events to the user and let the user modify the source code.</p>