[实作] J006:P2C - a Pascal to C translator

楼主: jans0204 (jans0204)   2022-08-24 21:15:32
J006:P2C - a Pascal to C translator
Home Page:
http://users.fred.net/tds/lab/p2c/historic/daves.index-2012Jul25-20-44-55.html
1. 下载原始档:(1993/12/8 13:36)
http://users.fred.net/tds/lab/p2c/p2c-1.21alpha2.tar.gz
2. 抽取 p2c-1.21alpha2.tar.gz\src\ 至工作目录 R:\p2c\src\ (RAMDRIVE)
3. 备份原档:
md R:\p2c\src\prog
cp trans.h R:\p2c\src\prog
cp Makefile R:\p2c\src\prog
4.1 PATCH - trans.h
LINE_1776
//extern FILE *inf, *outf, *codef, *hdrf, *logf;
extern FILE *inf, *outf, *codef, *hdrf, *logfile;
#define logf logfile
LINE_1865
//int unlink PP( (char *) );
int unlink PP( (const char *) );
4.2 PATCH - Makefile LINE_40
#CC = cc # you may wish to use gcc here instead
#OPT = # -O # uncomment this for optimization
CC = gcc
OPT = -Os
5. 产生 p2c.exe
进入 MSYS
$ cd /r/p2c/src
$ make p2c > make.log 2>&1
$ make clean.o
$ strip p2c.exe
$ make libp2c.a
6. 安装:
md R:\p2c\home
md R:\p2c\p2c
cd R:\p2c\src
cp p2c.exe ..
cp p2c.h ..\p2c
cp p2clib.o ..\p2c
cp system.imp ..\home
cp system.m2 ..\home
cp turbo.imp ..\home
cp loc.p2crc ..\home
cp sys.p2crc ..\home\p2crc
cp string.pas ..\home
7. 测试:p2c-1.21alpha2.tar.gz\examples\fact.p -> R:\p2c
R:\p2c>p2c.exe -o fact.c fact.p
fact, factorials
Translation completed.
R:\p2c>gcc -I. -Os -o fact.exe fact.c .\p2c\p2clib.o
R:\strip fact.exe
R:\p2c>fact.exe
The factorial of 1 is 1
The factorial of 2 is 2
The factorial of 3 is 6
The factorial of 4 is 24
The factorial of 5 is 120
The factorial of 6 is 720
The factorial of 7 is 5040
The factorial of 8 is 40320
The factorial of 9 is 362880
The factorial of 10 is 3628800
R:\p2c>
8. (END)

Links booklink

Contact Us: admin [ a t ] ucptt.com