[實作] J006:P2C - a Pascal to C translator
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)
https://github.com/jans0204/J006-P2C---a-Pascal-to-C-translator
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 124.218.31.163 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/PLT/M.1661346937.A.5C9.html
PLT 近期熱門文章
PTT數位生活區 即時熱門文章