- Pascal to Component Pascal translator

From: CFB Software <"CFB>
Date: Wed, 19 Oct 2005 13:18:08 +0930

----boundary-LibPST-iamunique-38297258_-_-
Content-type: text/plain

> -----Original Message-----
> From: blackbox{([at]})nowhere.xy
> Behalf Of Rex Couture
> Sent: Wednesday, 19 October 2005 2:18 AM
>
> Sounds good. How does it differ from Tp2Cp?

Gérard Meunier (the author of Tp2Cp) asked exactly the same question on
the GPCP mailing list. My response was:

The end results are very similar for the Pascal programs that I have
tested with both translators. Yours (Tp2Cp) does more to handle
Turbo-related code. The following example (unashamedly contrived to show
my (P2O) best points!) illustrates the major differences:

Original Pascal Source:
===========
program test;

type
  enum = (first, middle, last);
  subrange = 0..10;
  rec = record
  i: integer;
  j: integer
end;

var
  j, k: integer;
  r: rec;

begin
  with r do begin
    i := j;
    j := k
  end;

if j = 0 then
  j := 1
else if j = 1 then
  j := 0;
end.


Tp2Cp Translation
========
MODULE test;

TYPE
  enum = (first, middle, last);
  subrange = 0..10;
  rec = RECORD
    i: INTEGER;
    j: INTEGER
  END;
 
VAR
  j, k: INTEGER;
  r: rec;

PROCEDURE Main*;
BEGIN
  WITH r DO
    i := j;
    j := k
  END;
  
  IF j = 0 THEN
    j := 1
  ELSE IF j = 1 THEN
    j := 0 END END;
END Main;
END test.

P2O Translation
=======
MODULE test;

TYPE
  enum = INTEGER;
CONST first = 0; middle = 1; last = 2;
  subrange = INTEGER;
  rec = RECORD
    i: INTEGER;
    j: INTEGER
  END;
 
VAR
  j, k: INTEGER;
  r: rec;

BEGIN
  (* WITH r DO *)
    
    r.i := r.j;
    
    r.j := k
  (* END WITH *);
  
  IF j = 0 THEN
    j := 1
  ELSIF j = 1 THEN
    j := 0
  END;
END test.

======
Note1: WITH handling is currently only working for the simplest cases.

Note2: The CONST statements generated from enumerated types need to be
relocated above the TYPE section before attempting to compile the
translated code.

Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-38297258_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCA+IC0tLS0tT3JpZ2luYWwgTWVz
c2FnZS0tLS0tXHBhcg0KPiBGcm9tOiBibGFja2JveEBvYmVyb24uY2ggW21haWx0bzpibGFja2Jv
eEBvYmVyb24uY2hdIE9uXHBhcg0KPiBCZWhhbGYgT2YgUmV4IENvdXR1cmVccGFyDQo+IFNlbnQ6
IFdlZG5lc2RheSwgMTkgT2N0b2JlciAyMDA1IDI6MTggQU1ccGFyDQo+IFxwYXINCj4gICAgICAg
ICBTb3VuZHMgZ29vZC4gIEhvdyBkb2VzIGl0IGRpZmZlciBmcm9tIFRwMkNwP1xwYXINClxwYXIN
CkdcJ2U5cmFyZCBNZXVuaWVyICh0aGUgYXV0aG9yIG9mIFRwMkNwKSBhc2tlZCBleGFjdGx5IHRo
ZSBzYW1lIHF1ZXN0aW9uIG9uXHBhcg0KdGhlIEdQQ1AgbWFpbGluZyBsaXN0LiBNeSByZXNwb25z
ZSB3YXM6XHBhcg0KXHBhcg0KVGhlIGVuZCByZXN1bHRzIGFyZSB2ZXJ5IHNpbWlsYXIgZm9yIHRo
ZSBQYXNjYWwgcHJvZ3JhbXMgdGhhdCBJIGhhdmVccGFyDQp0ZXN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AgICBqIDo9IDFccGFyDQogIEVMU0lGIGog
PSAxIFRIRU5ccGFyDQogICAgaiA6PSAwXHBhcg0KICBFTkQ7IFxwYXINCkVORCB0ZXN0LlxwYXIN
ClxwYXINCj09PT09PT09PT09PT1ccGFyDQpccGFyDQpOb3RlMTogV0lUSCBoYW5kbGluZyBpcyBj
dXJyZW50bHkgb25seSB3b3JraW5nIGZvciB0aGUgc2ltcGxlc3QgY2FzZXMuXHBhcg0KXHBhcg0K
Tm90ZTI6IFRoZSBDT05TVCBzdGF0ZW1lbnRzIGdlbmVyYXRlZCBmcm9tIGVudW1lcmF0ZWQgdHlw
ZXMgbmVlZCB0byBiZVxwYXINCnJlbG9jYXRlZCBhYm92ZSB0aGUgVFlQRSBzZWN0aW9uIGJlZm9y
ZSBhdHRlbXB0aW5nIHRvIGNvbXBpbGUgdGhlXHBhcg0KdHJhbnNsYXRlZCBjb2RlLlxwYXINClxw
YXINCkNocmlzIEJ1cnJvd3NccGFyDQpDRkIgU29mdHdhcmVccGFyDQpodHRwOi8vd3d3LmNmYnNv
ZnR3YXJlLmNvbS9ncGNwXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94XHBhcg0KLS0tIHNlbmQgc3Vi
amVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9iZXJvbi5jaH19AGFja2JveEBv
YmU

----boundary-LibPST-iamunique-38297258_-_---
Received on Wed Oct 19 2005 - 05:48:08 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:07 UTC