Version 5 of Pascal>TCL

Updated 2006-05-23 14:16:35

SDR 21 May 2006

Interested to find out if there any convertors from Pascal code to Tcl code available.

I have some Pascal code that needs to be converted to Tcl and maybe I should learn Pascal code, but I'm too lazy (and not smart enough) for that.

Larry Smith You may find run to be some help. In the example you will find a demo of a pascal-like translator for Tcl that, with some work, might be just what you want.

I would assume any automatic conversion of code would be riddled with problems, but if the code is converted to Tcl I can then find the bugs easier.

Any suggestions?

AM (22 may 2006) I do not know enough of Pascal to help out, but I have experience with similar translations from Fortran. My strategy would be:

  • Replace all the keywords by their Tcl equivalents (use [string map] for that)
  • Convert the assignments (a=b and the like) to set-statements, using [regsub]
  • Find other general edits that take very little Tcl code to implement
  • Edit the resulting code manually

If there is no automatic conversion tool, and that is very likely the case, then the above steps at least get rid of the more tedious bits of conversion.

aa I think Pascal is among the easiest languages to read. If it's not been made unreasonably complex by the programmer, you basically need only to know that begin and end surround blocks of code. My suggestion is to do it the "right" way: look at what the Pascal code is intended to do and write new Tcl code to do the same thing. Tcl has rather different strengths from Pascal, so a direct translation is probably not going to be the best route.

Lars H: I agree with aa, but thought I should mention that one of my long time programming projects involves a translator from Pascal (actually Web, which is a pascal-with-preprocessor) to C, which I of course want to code in Tcl. The current (June 2005 -- May 2006) state is that it can tokenise everything and parse definition parts, but not statement parts (except to see where they begin and end). If you seriously don't want to do it the right way (as aa explained) then you might want to write me a line.


[ Category Language ]