Re: PCC, TCC - new front end (Rob Warnock)
Sun, 24 May 2009 21:50:03 -0500

          From comp.compilers

Related articles
PCC, TCC - new front end (Marco) (2009-05-22)
Re: PCC, TCC - new front end (2009-05-24)
Companion language was PCC, TCC - new front end (Marco) (2009-05-25)
Re: PCC, TCC - new front end (Philip Herron) (2009-06-03)
| List of all articles for this month |

From: (Rob Warnock)
Newsgroups: comp.compilers
Date: Sun, 24 May 2009 21:50:03 -0500
Organization: Rob Warnock, Consulting Systems Architect
References: 09-05-106
Keywords: tools
Posted-Date: 25 May 2009 05:05:06 EDT
Originator: (Rob Warnock)

Marco <> wrote:
| I am looking to create what I would call a "companion language" to C.
| It would basically compile to .o files that would be linked with other
| standard C generated .o to create the executable. It would of course
| use the standard C library when needed.
| I have no desire or time to learn a complicated compiler such as gcc.
| Would generating C code be a better approach? Is there a fairly simple
| example project out there to start with? My concern is that this may limit
| what the "companion language" can be (besides the obvious linkage aspects).
| Ultimately I would like it to target 32 bit ARM, x86 and PowerPC
| embedded targets so cross-compiling is a must.

If you can tolerate Scheme as your "companion language", you might find
the following paper of interest:

        An Incremental Approach to Compiler Construction
        Abdulaziz Ghuloum (Indiana University)
        This paper from the [ICFP'06] Scheme workshop presents an extended
        tutorial showing how to implement a compiler from Scheme to x86
        assembly language. The compiler is written in Scheme...

        An important aspect of the presentation of the material is that
        the compiler is built incrementally, and the product of each step
        is a working compiler for a growing subset of the language.

Full paper (from the ICFP 2006 Scheme workshop):

        An Incremental Approach to Compiler Construction
        Abdulaziz Ghuloum
        We assume that the reader is familiar with the basic computer
        architecture: its components and execution model. Detailed
        knowledge of the Intel-x86 architecture is not required.
        Additionally, the compiler we develop is small enough to be easily
        portable to other architectures, and the majority of the compiler
        passes are platform independent.

So that should handle your cross-compiling to embedded targets requirement.


p.s. If you'd prefer to target C instead of assembler, you might prefer
this paper:

        The 90 Minute Scheme to C compiler (with video)
        Marc Feeley
        Montreal Scheme/Lisp User Group, 20/10/2004 Meeting

        Marc showed us how to write a simple Scheme to C compiler, in Scheme.
        In only 90 minutes! And although not supporting the whole Scheme
        standard, the compiler supports fully optimized proper tail calls,
        continuations, and (of course) full closures. The compiler is
        implemented using two important compilation techniques for functional
        languages: closure conversion and CPS-conversion.

        [Contains links to slides in PDF, compiler source code,
        and AVI video of presentation.]

Rob Warnock <>
627 26th Avenue <URL:>
San Mateo, CA 94403 (650)572-2607

Post a followup to this message

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