comp.lang.ada
 help / color / mirror / Atom feed
From: jens.hansson@mailbox.swipnet.se (Jens Hansson)
Subject: Re: Building an Ada compiler
Date: 1996/07/04
Date: 1996-07-04T00:00:00+00:00	[thread overview]
Message-ID: <4rf99u$786@mn5.swip.net> (raw)
In-Reply-To: 4r0u04$21b0@sat.ipp-garching.mpg.de


In article <4r0u04$21b0@sat.ipp-garching.mpg.de>, berlich@pc66.mppmu.mpg.de 
says...
>
>Hi,
>if writing an Ada-Compiler is that much of a problem, then,
>how difficult is it to write an Ada95-Interpreter ?

I'd say it's even more difficult! Think about changing a declaration (i.e. a 
variable name or type) in a separate package header. Then all references in
all dependant modules of the program are invalid.

>I think of something one can plug into the code as a call to 
>the interpreter, where the interpeter knows anything about the 
>variables and objects defined at the calling-point of the 
>interpreter and is able to call all functions etc. that are accessible at
>the calling point. So one could do 'on the fly'-development of programs
>(e.g. provide a frame for the program which is linked with all necessary 
>libraries and then write the code that is needed while the program is 
>running.). O.k., maybe that is an illusion. But a nice one.
>Bye and have a nice day, Ruediger
>[berlich@pc66.mppmu.mpg.de]
>

The main difficulties of making an Ada compiler is the complexity of the 
language and efficient code generation. You cannot (legally :-)) simplify the 
language, but you can simplify the code generation by generating code for a
virtual machine (like Java) which has appropriate instructions and data types.
I believe C is inappropriate as an intermediate language because of Adas 
tasking -- You might be able to do it, but if your C compiler has stack 
checking it'll probably break.

I would recommend the following:

 * Get the Annotated RM, which contains RM plus lots of clarifications on how
   the language works.

 * Since you're not compiler writers, get a good book on compiler techniques
   like "Compilers -- Principles, Techniques and Tools" by Aho, Sethi and 
   Ullman.

 * Start out with a *tiny* subset of the language. Skip processes, exceptions, 
   user-defined types, procedure and operator overloading etc. I would start 
   with an Ada subset containing:

   - only integer variables
   - some program structure (like FOR loops) 
   - subroutines/functions with parameters and return values.

 * Then I could add other data types:

   - Floats, characters, booleans and enumerated types
   - Array types, strings and simple Record types
   - access types (skip the generics so far...). Memory management      
     (garbage collection) might produce a problem.
   - Tagged records, type extensions, ... (Ugh!).

   To make these data types more useful, you may want to implement:

   - Overloaded procedures and functions.
   - Overloaded operators.

When you've done this (assuming that you get everything to work in all 
combinations) I would say that you have 2/3 of the work remaining.

I'd recommend you to use compiler generator tools like YACC (or PCCTS or ..., 
check the comp.compilers group). These tools makes it a lot easier to change 
the grammar as the compiler develops. Some tools even come with a few sample 
grammars (I don't know if any of them comes with an Ada grammar though).

You're attempting to start a huge project. Good luck!

-- Jens





  parent reply	other threads:[~1996-07-04  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-28  0:00 Building an Ada compiler ErkoDJK
1996-06-28  0:00 ` Ray Blaak
1996-06-28  0:00   ` Robert Dewar
1996-07-01  0:00   ` Michael Feldman
1996-06-28  0:00 ` Robert Dewar
1996-06-28  0:00 ` Robert A Duff
1996-06-28  0:00   ` Robert Dewar
1996-06-28  0:00   ` Raul Barral Tamayo
1996-06-28  0:00     ` Robert Dewar
1996-06-30  0:00     ` Gary McKee
1996-06-28  0:00   ` Ruediger Berlich
1996-06-29  0:00     ` Robert A Duff
1996-07-04  0:00     ` Jens Hansson [this message]
1996-06-29  0:00 ` Mark Eichin
     [not found]   ` <4r4c6m$bec@eri1.erinet.com>
1996-06-30  0:00     ` James E. Hopper
1996-06-30  0:00       ` Tucker Taft
1996-06-30  0:00         ` Robert Dewar
1996-07-05  0:00           ` David Emery
1996-07-06  0:00             ` Robert Dewar
1996-07-07  0:00             ` Michael Feldman
1996-06-30  0:00         ` James E. Hopper
1996-07-01  0:00       ` Laurent Gasser
1996-07-02  0:00         ` Arthur Evans Jr
1996-06-29  0:00 ` Tucker Taft
1996-07-01  0:00 ` Ken Garlington
  -- strict thread matches above, loose matches on Subject: below --
1996-07-16  0:00 ErkoDJK
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox