d95-bli at nada.kth.se
Fri Jul 9 02:00:01 PDT 2004
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. Unless you already are a gcc
hacker, you will need to spend the next year or so reading up on half
of the gcc source before you will be able to integrate a new front end
to gcc. I think the easiest way to use gcc as a back-end is to make
your compiler emit C code. This can still be quite efficient, since C
is a low level language. I know of at least one Common Lisp
implementation that does this (gcl).
More information about the lfs-chat