|Building C/C++ compilers firstname.lastname@example.org (Sigurd Lerstad) (2004-12-16)|
|Re: Building C/C++ compilers email@example.com (Vidar Hokstad) (2004-12-17)|
|Re: Building C/C++ compilers firstname.lastname@example.org (Robert J. Simpson) (2004-12-17)|
|Re: Building C/C++ compilers email@example.com (David Lindauer) (2004-12-17)|
|From:||"Sigurd Lerstad" <firstname.lastname@example.org>|
|Date:||16 Dec 2004 00:50:21 -0500|
|Posted-Date:||16 Dec 2004 00:50:21 EST|
I'm trying to make a C/C++ compiler.
I'm using flex and bison, and I have the book "modern compiler
implementation in C".
Some have commented that this book uses a non-traditional
approach. Can someone be more specific why it's untraditional?
In the phase to produce Abstract Syntax Tree (AST) from the source. C/C++
has a difficult case that has an amiguity
g * h
this can mean declare a variable pointer to g named h, or the variable g
multiplied with h;
In the above mentioned book, Appel first builds a syntax tree and then does
semantic analysis, i.e. type checking etc.
but it seems to me that because of the above ambiguity, ast building and
semantic analysis must be performed at the same time ?
C++ makes it even more difficult, consider this example:
typedef int g;
Now, g is declared later in the source, which complicates things even more.
Does anyone have any pointers to me overcoming these two issues, also on the
light of using bison as the parser.
[Parsing C++ using a LALR parser is quite difficult. This has come up many
times before. -John]
Return to the
Search the comp.compilers archives again.