Re: Re: Ranking of OO refactorings

Richard <[email protected]> Mon, 15 Jul 2013 08:53:56 -0600
Newsgroups gmane.comp.programming.refactoring
Organization multi-cellular, biological
Message-ID <[email protected]>
In article <CAEyOLyBvX-LNWyrFoZfqq4niadCzMkT8m3rAcrpNJpanf30X1A@mail.gmail.com>,
    J Arrizza <[email protected]> writes:

> One of the problems facing the C and C++ parsers in refactoring tools (and
> in pretty printers too) is the preprocessor. In short, you can, within
> limits, change the grammar of C++ using the preprocessor.

Yes, but I have a few points.

First, while this abuse of the preprocessor is possible, it isn't common.
So, if we ignore such abuse, then we aren't really suffering too much
if we can't apply a refactoring tool in the face of such abuse.

Second, while the interaction of the preprocessor and the parser
can't be captures in a single grammar, the existing implementations
are proof that such things can be parsed and understood by programs.
They do it by having a series of parsing steps that handle everything
from the original source file to handling includes and macro
expansion, etc.  Having just recently implemented the first few phases
of the preprocessor myself as an exercise, I can see how libClang
preserves all the necessary information while also deducing semantics.

Third, LLVM/libClang handles all this junk for you and give you an
annotated syntax tree that preserves (and understands) macro usage.

> Second, there are many, many compilers that introduce slight variants of
> the standard grammar: new keywords, slight changes to where some things are
> allowed, etc.

Obviously with a clang approach you need to have some sort of
mechanism for handling the extensions introduced by other compilers.
Ironically, one way you can do this is by abusing the preprocessor to
"make them all go away".
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/