From: Baptiste L. <gai...@fr...> - 2003-01-31 22:04:37
|
----- Original Message ----- From: "Andre Baresel" <and...@gm...> To: "Sven Reichard" <rei...@ma...>; "CppTool Mailing List" <Cpp...@li...> Sent: Friday, January 31, 2003 4:47 PM Subject: Re: [Cpptool-develop] apologies > Sven Reichard wrote: > > >Since the CodeGenerator code isn't used yet, I don't really understand it. > >I'll try to work on it. > > > I think I understood the main idea by anlysing the tests written by > Baptiste. > In the tests the code generator is used in the following way: > > - Parse a code to an AST (lazy parsing as used in the Refactoring code) > - Transform the AST to Code-Elements like if-statement/for-statement > etc. (for each programming > element there is a class > - Code-Elements are used to rewrite the code in a textual form > (formatting stuff). > > For me it seems to be a transformation between the AST-representation > and a new CodeGenerator > representation. This codegeneration representation can be used for > formatting. Yes, that's it. See the very basic example in CodeWriterTest::testRewriteStatement(). It will be use for formatting, but also for refactoring. On difficult issue when doing some refactoring like IntroduceExplainingVariable and ReduceTemporaryScope is that you need to introduce a new statement next to another existing one. Doing so may require adding a compound statement, which is very 'context dependent' (is it within a switch/case,a for, a if/then/else...) Baptiste. > [...] |