[cfe-dev] Clarification for term "AST"

Sean Silva silvas at purdue.edu
Fri Feb 22 13:53:49 PST 2013

On Fri, Feb 22, 2013 at 3:09 PM, Markus Elfring <Markus.Elfring at web.de> wrote:
>> The problem as I see it is that building a "pure" AST of C++ (and C) is just impossible
> I have got a different opinion. - Corresponding solutions will need more efforts
> for further separation of concerns, won't they?

Yes. A complete separation of concerns is impossible though, and
Clang's implementation is basically at the edge of that limit.

>> because to know whether you have a variable declaration or a functional call
>> you require basic semantic analysis already.
> I guess that you refer to ambiguities in the programming language(s) like they
> were also described by software researchers "Edward D. Willink" and "Adrian D.
> Thurston".

I haven't looked in detail at their work, sorry. Maybe you could
summarize their findings?

>> This is a defect of the specification of the grammar itself, and it will not be solved now
>> (it would require completely reworking the grammar which is obviously impractical given
>> the number of programs written).
> I assume that there happened some discussions on this already.

Yes, but the existing grammar of the language is not open for debate.
There are billions of lines of code written against the existing
grammar. Grammar modifications at this point are only going to be

>> Therefore, you'll always have "kind-of" a semantic tree,
> I would like to suggest a different approach.

Please do! We are always interested in improving our codebase.
However, I think that as you gain a better understanding of the
complexities of the task that Clang performs you will come to
appreciate the current design as having quite a clear separation of

>> without a dedicated Abstract Syntax Tree level.
> I guess that it is another software design challenge to ensure clear interfaces
> between the involved abstraction levels.

Indeed. It has required a lot of effort to improve our interfaces to
the clarity that they are at now.

-- Sean Silva

More information about the cfe-dev mailing list