Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-09-01 11:47:41


On Sat, 2007-09-01 at 10:41 -0400, David Abrahams wrote:
> on Fri Aug 31 2007, Doug Gregor <dgregor-AT-osl.iu.edu> wrote:
>
> > - Video: http://llvm.org/devmtg/2007-05/09-Naroff-CFE.mov
>
> The goal of separating semantic analysis from parsing is a noble one,
> but it sounds like he may be underestimating the amount of semantic
> analysis that's required to parse C++. Inside templates we have the
> benefit of the typename and template keywords to tell us which are the
> types, but not inside regular code. AFAICT that means it has to do
> template instantiation just to tell whether foo<bar>::x is a type or
> not. Am I missing something?

No, you're technically correct. Some semantic analysis is certainly
required to parse C++, so you can't completely drop semantic analysis
and still parse. However, you can keep the two notions in separate
modules, and the parser will certainly need to call into the semantic
analysis module to figure out whether a particular name is a type, a
value, a template, etc... just like a C parser needs to consult a symbol
table to figure out whether a name is a typedef name or something else.

What this probably means is that the "minimal" semantic analysis for C++
is a whole lot more heavyweight than the minimal semantic analysis for
C. But you still get some benefit from separating out the semantics from
the parser, because there are many semantic bits that you *can* ignore
if you only want an (unchecked) parse tree.

        - Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk