JC> Just to add to this: most common C++ compilers also have front ends that
JC> handle C, but in every case of which I'm aware, the same code generator
JC> is used for both. Some versions of GCC also handle Objective-C input,
JC> again using the same back-end for all three languages.
If I recall correctly, one of the c++ compilers I've had the misfortune
to use just uses a preproccessor to convert c++ to c to compile it.
My guess is that is just does the syntax/symantec error checking unique
to c++ and then uses the c compiler to check the rest (very slow).
JC> Likewise, at least at one time, MS' C, Pascal and FORTRAN compilers all
JC> used the same back-ends. At roughly the same time, MS shipped the
JC> compilers for both DOS and Xenix. In this case, you could have the same
JC> front-end if you were compiling C for either system, but a one code
JC> generator for DOS, and a different one for Xenix. (Actually, even the
JC> code generator wasn't a lot different, though the standard library was.)
The scanner/parser/intermidiate code generator can be used for any
machine: no machine dependant code. Then there was YACC (yet another
compiler compiler). It (given a syntax) would auto-generate a compiler
to produce a compiler. The scanner portion uses regular expressions to
define variable, keyword, constants, ect.
EG:
letter [a-zA-Z]
char [a-zA-Z_0-9]
variable (letter)(char)*
a letter is a - z lower or capitalized.
a character is a letter or an under score or a number
a variable must start with a letter and can be followed by
0 or more instances of a character. example:
b
b_
b1_a
baaaa2222_222934AAA
are all legal variables.
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)
|