From: | "Tommy Thorn" <tommy.thorn@gmail.com> |
Newsgroups: | comp.compilers |
Date: | 19 Dec 2006 01:03:44 -0500 |
Organization: | Compilers Central |
References: | 06-09-02906-09-042 06-09-048 06-09-060 06-09-078 06-09-093 06-12-064 06-12-066 |
Keywords: | parse, C |
Posted-Date: | 19 Dec 2006 01:03:44 EST |
Robert A Duff wrote:
> Has anyone ever tried to solve these C / C++ parsing problems without
> "feedback"?
...
> The typical solution in Ada compilers is for the parser to build a
> tree that means "this could be any of ...", with X and Y as subtrees,
> and then semantic analysis has symbol tables, so it knows what X is,
> and changes that node into a "function call" or "array indexing" or
> whatever is appropriate. (Note: X could be an overloaded name.)
>
> My question is: can that technique work for the above C and C++
> ambiguities? Does it make the problem easier or harder? Is the
> answer different for C++ than for C?
It has certaintly been suggested, though I don't know if anyone
actually do that as it's probably simpler in practice to add a little
feedback to the lexer. Moreover, knowing the difference between types
and identifier enables much better error reporting in case of parse
errors.
The much more interesting part is what happens *after* parsing and
semantic analysis.
Tommy
Return to the
comp.compilers page.
Search the
comp.compilers archives again.