Stuff/Software

Matthew Burgess matthew at linuxfromscratch.org
Fri Jul 9 13:35:14 PDT 2004


On 09 Jul 2004 10:59:22 +0200
d95-bli at nada.kth.se (Björn Lindberg) wrote:

> Matthew Burgess <matthew at linuxfromscratch.org> writes:
> 
> > > > Well, anything's possible, but I've no idea where you'd start. 
> > > > If my assumption about 1) is correct, then your best bet is
> > > > probably to study the source code of some existing open-source
> > > > shells (bash, ash, ksh, zsh, etc.).  For 2) You'll definitely
> > > > need some textbooks on language design, compiler design/writing
> > > > and an in depth knowledge of assembly language, which is, at the
> > > > end of the day, what you're programming language compiler will
> > > > have to produce as an end result.
> > > 
> > > Not necessarily. It could produce byte-codes for a virtual
> > > machine, eg the Java VM, or source code for another language, like
> > > C or Common Lisp. Not to mention that if he is content with an
> > > interpreter for his language, he doesn't need to write a compiler
> > > at all. I agree that it is quite an ambitious project in either
> > > case though.
> > 
> > All of your points are valid of course.  I had actually thought of
> > mentioning byte-code, etc. but for the sake of brevity & clarity
> > omitted them.  Just as a further point, the first C++ compilers
> > (e.g. Cfront) actually did exactly what you described above, i.e.
> > converted C++ code into C.
> > 
> > If I understand correctly, GCC takes the approach of converting all
> > of its supported languages (I believe) to an intermediate language
> > (RTL) which is then converted to assembly (or byte-code for Java I
> > would have thought).  This may actually be the easiest (still not by
> > any means easy though!) way forward - just write a front-end (or is
> > it a middle-end?) to convert your new language into RTL and let GCC
> > do the rest :)
> 
> From what I have read, I have the impression that the gcc internals
> are quite complex and poorly documented.

You understand correctly.  See http://gcc.gnu.org/PR14172 for evidence
:)  I even went on to #gcc to see if someone could help me, alas it
would appear the compiler may well have thrown away the information
needed to fix that bug entirely!

Cheers,

Matt.



More information about the lfs-chat mailing list