----boundary-LibPST-iamunique-2102803426_-_-
Content-type: text/plain
> -----Original Message-----
> From: blackbox{([at]})nowhere.xy> Behalf Of Campbell, Robert D (SELEX) (UK Edinburgh)
> Sent: Wednesday, 19 October 2005 5:50 PM
> To: BlackBox Mailing List
> Subject: [BlackBox] - Pascal to Component Pascal translator -
> NumericalRecipes
>
>
>
> Chris
>
> I am not familiar with the various Pascal
> dialecs (I last used VAX Pascal decades ago!).
>
> For mathematical and engineering work the
> book 'Numerical Recipes' is a very valuable
> cookbook (and theory) resource, and is available
> in several languages (FORTRAN, c, Pascal at least).
>
I agree with Bernhard in his reply - if a Modula-2 version is already
available, it should be easier to use that as a starting point for
conversion to CP. However, collections of algorithms are probably better
candidates for translation than, say, special-purpose applications,
particularly if they are not dependent on any particular operating
system / platform or framework.
> Strangely enough, when I need to translate something
> to CP, I find the FORTRAN the easiest source (but the
> GOTOs are often VERY difficult to handle).
>
Similar to your VAX Pascal experience - the last programming job that I
had that involved FORTRAN was when it was still at version IV back in
1978. Yes - GOTOs are a nightmare in Pascal as well - they have to be
translated by hand. Unless they were used very sparingly in a Pascal
program (e.g. to simulate a HALT), such programs are better left to
wither away and die anyway.
> Can we now expect the translator tools to be powerful
> enough and mature enough to handle such translations
> reliably, and with minimal or modest 'user interaction'?
> That would indeed be useful.
>
I've continued on from Wirth's example (he was the original author of
M2O, the Modula-2 to Oberon translator) and taken the conservative
approach to translation. i.e. only translate the obvious. Anything that
is disputable should be left to manual intervention - there is nothing
worse than 'smart' decision-making software.
So far I have experimented with two different approaches to translation.
The current translator, and Wirth's M2O that it is based on, are
effectively language compilers. They scan and parse the input in the
same way as a traditional compiler. The difference is that instead of
the output being executable code, the output is source code for a
different language.
Another promising approach to translation is made possible by
environments like the old UCSD P-System and the Java Virtual Machine
(JVM). The most recent is Microsoft's .NET - in particular its use of
the Common Language Interface (CLI). All of the languages available on
.NET (including C#, C++, Fortran, Component Pascal, Modula-2, Oberon,
Visual Basic etc.) generate a common intermediate language (IL), similar
in many respects to assembly language. When you 'compile' a .NET program
it simply converts it into IL. It is not until the program is run that
the IL is compiled into native code.
Where this is useful for programming language translators is that, as
well as containing all the information about assignments, jumps, loops
etc. that is normally in an assembly language of a similar level, the IL
also contains 'meta-information' about the data types and structures. In
fact, there is sufficient information contained to be able to
'disassemble' the IL and reconstruct most of the original source code of
the program.
The neat outcome of all of this is that if you have written one of these
disassemblers, for Component Pascal, say, then you can use the same
disassembler for IL code that originated from a different programming
language and hence you have a language translator!
I have a prototype of such a .NET Component Pascal translator - I didn't
need to start from scatch, I just had to modify an existing Object
Pascal dissasembler which is publicly available. It does quite well
converting C# or Delphi for .NET programs, but unfortunately for you
perhaps, had no luck so far with FORTRAN.
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp
--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
----boundary-LibPST-iamunique-2102803426_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwID4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS1c
cGFyDQo+IEZyb206IGJsYWNrYm94QG9iZXJvbi5jaCBbbWFpbHRvOmJsYWNrYm94QG9iZXJvbi5j
aF0gT24gXHBhcg0KPiBCZWhhbGYgT2YgQ2FtcGJlbGwsIFJvYmVydCBEI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