comp.lang.ada
 help / color / mirror / Atom feed
* Re: Fortran pasta anybody?
       [not found] ` <4ide24$12h@tomquartz.niestu.com>
@ 1996-03-19  0:00   ` Robert I. Eachus
  0 siblings, 0 replies; only message in thread
From: Robert I. Eachus @ 1996-03-19  0:00 UTC (permalink / raw)



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 loop> ::= while <expression> do <statement_or_block> 
  <statement_or_block> ::= begin <statement_list> end
  <statement_list> ::= <statement>
  <statement_list> ::= <statement> ; <statement_list>

Ada:
  <while loop> ::= while <expression> loop <statement_or_block> end loop;
  <statement>_or_block> ::= <statement_list>
  <statement_list>  ::= <statement>
  <statement_list> ::=  <statement> <statement_list>

  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...




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-03-19  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4i6tms$o5n@dfw.dfw.net>
     [not found] ` <4ide24$12h@tomquartz.niestu.com>
1996-03-19  0:00   ` Fortran pasta anybody? Robert I. Eachus

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