Re: Writing a compiler

Louis Krupp <lkrupp@pssw.nospam.com.invalid>
Sat, 01 Nov 2008 12:06:54 -0600

          From comp.compilers

Related articles
[5 earlier articles]
Re: Writing a compiler m.collado@lml.ls.fi.upm.es (Manuel Collado) (2008-10-24)
Re: Writing a compiler Ibeam2000@gmail.com (Nick) (2008-10-26)
Re: Writing a compiler rajaram.officemails@gmail.com (RR) (2008-10-26)
Re: Writing a compiler andresjriofrio@gmail.com (andresj) (2008-10-29)
Re: Writing a compiler kamalpr@hp.com (kamal) (2008-10-29)
Re: Writing a compiler tony@my.net (Tony) (2008-10-31)
Re: Writing a compiler lkrupp@pssw.nospam.com.invalid (Louis Krupp) (2008-11-01)
Re: Writing a compiler marcov@stack.nl (Marco van de Voort) (2008-11-02)
Re: Writing a compiler chris.dollin@hp.com (Chris Dollin) (2008-11-03)
Re: Writing a compiler lkrupp@pssw.com (Louis Krupp) (2008-11-03)
Re: Writing a compiler alexc@TheWorld.com (Alex Colvin) (2008-11-03)
Re: compiling C++ to C, was writing a compiler marcov@stack.nl (Marco van de Voort) (2008-11-04)
Re: compiling C++ to C, was writing a compiler alexc@TheWorld.com (Alex Colvin) (2008-11-04)
[7 later articles]
| List of all articles for this month |

From: Louis Krupp <lkrupp@pssw.nospam.com.invalid>
Newsgroups: comp.compilers
Date: Sat, 01 Nov 2008 12:06:54 -0600
Organization: Compilers Central
References: 08-10-037 08-10-046 08-10-047 08-11-003
Keywords: code
Posted-Date: 01 Nov 2008 20:41:56 EDT

Tony wrote:
> "Nick" <Ibeam2000@gmail.com> wrote in message
>>> Just use XSLT to generate the assembler code.
>> If I can make a suggestion, use C or C++ as target language. Here
>> you don't have to reinvent subroutine calling and the like, and you
>> maintain compatibility with other things on the OS. Not to mention
>> ease of moving around different OSes. And troubleshooting. Much
>> easier.
>
> I want to do exactly that to experiment with language features, but I
> don't really know where to begin. Probably studying how CFront
> generated C code? From what I've read, it seems that CFront couldn't
> implement the whole language. How could it when introducing something
> like '::' as the scoping operator when C doesn't have such a beast?
>
> Tony
> [cfront was a prototype, and it's a miracle it worked as well as it did.
> If you want to see generated code, either get the Comeau compiler, or look
> at the assembler output from something like GCC. -John]


Look up "name mangling." It's as ugly as it sounds, but as far as I
know, it's how all C++ compilers manage scoping and overloading.


I see no reason why cfront couldn't implement all of C++;
theoretically, there's no difference between generating C or assembler
code. My guess is that all newer C++ compilers are "native" (i.e.,
they generate assembler), and cfront compilers may have predated later
versions of C++. So while there could be up-to-date cfront compilers,
in the real world, there may very well be none.


(One of the problems with cfront -- actually, the only problem I can
really articulate -- is that it depends on C. I've seen cfront generate
good C code which failed when fed to a buggy C compiler.)


Louis


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.