From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d819a12831be771 X-Google-Attributes: gid103376,public From: jens.hansson@mailbox.swipnet.se (Jens Hansson) Subject: Re: Building an Ada compiler Date: 1996/07/04 Message-ID: <4rf99u$786@mn5.swip.net>#1/1 X-Deja-AN: 163657090 references: <4r023h$jt2@newsbf02.news.aol.com> <4r0u04$21b0@sat.ipp-garching.mpg.de> content-type: Text/Plain; charset=US-ASCII organization: - mime-version: 1.0 newsgroups: comp.lang.ada nntp-posting-user: 2c6fdda8431637e6c07dd8313ec259b3 Date: 1996-07-04T00:00:00+00:00 List-Id: 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