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,b7c81c4d901c9bd X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Fortran pasta anybody? Date: 1996/03/19 Message-ID: #1/1 X-Deja-AN: 143307084 references: <4i6tms$o5n@dfw.dfw.net> <4ide24$12h@tomquartz.niestu.com> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-03-19T00:00:00+00:00 List-Id: In article <4ide24$12h@tomquartz.niestu.com> chipr@niestu.com (Chip Richards) writes: > I need to translate Pascal to Ada--a modest amount (around 250k > SLOC) at first, but if that works well enough, we might be > interested in an additional 3.5 million lines. I've been meaning > to ask about this on the group for some time, having finally > decided through some not inconsiderable research on the net that > such a thing either does not exist, or is not readily available. There are companies that provide code translation services, and it is a very profitable business. But you are not going to find "off the shelf" tools due to the versioning problems. It may take a few hours for an expert to tweak a quality translation tool to accept a different dialect of Pascal and to produce code targeted to a 16-bit integer version of the Alsys compiler. But they can't do it over the phone. That's why they sell the services not the tools. Having said that, and if you are ready to perform do-it-yourself brain surgery, get a compiler text and read about SDTS (syntax directed translation schemes). Basically you need to create a pair of grammars, one for the Pascal, one for Ada. These need look nothing like "standard" grammars for those languages, and in fact you will have productions with tokens like "Text_IO.Put(". But the goal is to have two grammars with the same non-terminals in corresponding productions, and in the same order. For example, writing from memory here (recursive descent version): Pascal: ::= while do ::= begin end ::= ::= ; Ada: ::= while loop end loop; _or_block> ::= ::= ::= Only a couple hundred more to go. (Note that Ada features not used to match the Pascal will not appear in your Ada grammar, and the same Ada or Pascal features can show up as many different non-terminal productions. The trick is to get the grammars to match, not to be minimal.) Once you have the grammars, converting to a tool is easy. If your grammars are LL1 you can just quickly write code, otherwise use a tool--and this is one case where an Early's parser is a great tool--you then don't need to care if your grammar is ambiguous, all it will do is slow down translation. A typical Pascal to Ada tool which does about 98% of the work will be in the 5-6K SLOC range. Put in support for Ada generating Ada with clauses and translating Pascal "use" and you can double that easily. (I've done a couple such tools for different Pascal dialects and one really complex tool that produced PL/I from Ada source files.) Oh, if you aren't comfortable hacking grammars, forget I mentioned this. The number of people with an aptitude for SDTSes is amazingly small. Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is... -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...