├── 0 ├── pl0.c ├── pl0.h └── TEST2.PL0 ├── 1 ├── pl0.c ├── pl0.h └── ex1.pl0 ├── 2 ├── pl0.c ├── pl0.h ├── for.pl0 └── ifelse.pl0 ├── 3 ├── pl0.c ├── pl0.h ├── for.pl0 └── ifelse.pl0 ├── .gitignore ├── 实验1.docx ├── 实验2.docx ├── 实验3.docx ├── 编译原理实验安排.doc └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.tmp 2 | *.exe 3 | -------------------------------------------------------------------------------- /0/pl0.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/0/pl0.c -------------------------------------------------------------------------------- /0/pl0.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/0/pl0.h -------------------------------------------------------------------------------- /1/pl0.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/1/pl0.c -------------------------------------------------------------------------------- /1/pl0.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/1/pl0.h -------------------------------------------------------------------------------- /2/pl0.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/2/pl0.c -------------------------------------------------------------------------------- /2/pl0.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/2/pl0.h -------------------------------------------------------------------------------- /3/pl0.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/3/pl0.c -------------------------------------------------------------------------------- /3/pl0.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/3/pl0.h -------------------------------------------------------------------------------- /实验1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/实验1.docx -------------------------------------------------------------------------------- /实验2.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/实验2.docx -------------------------------------------------------------------------------- /实验3.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/实验3.docx -------------------------------------------------------------------------------- /编译原理实验安排.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyyanbj/experiment-for-pl0-compiler-expansion/HEAD/编译原理实验安排.doc -------------------------------------------------------------------------------- /3/for.pl0: -------------------------------------------------------------------------------- 1 | var i,a; 2 | begin 3 | read(a); 4 | for i:=1 to 10 do 5 | begin 6 | write(i); 7 | write(i*3); 8 | end; 9 | end. 10 | 11 | -------------------------------------------------------------------------------- /2/for.pl0: -------------------------------------------------------------------------------- 1 | var i,a; 2 | begin 3 | read(a); 4 | for i=1 to 10 5 | begin 6 | write(i); 7 | write(i*a); 8 | end; 9 | 10 | end. 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # experiment-for-pl0-compiler-expansion 2 | 3 | 只做了前三个实验,后面的实验不要求就没做 - - 4 | 5 | ## 实验0 6 | 7 | 原始紫书pl0代码 8 | 9 | ## 实验1 10 | 11 | 阅读理解 12 | 13 | ## 实验2 14 | 15 | 增加else语句 16 | 17 | ## 实验3 18 | 19 | 增加for语句 -------------------------------------------------------------------------------- /0/TEST2.PL0: -------------------------------------------------------------------------------- 1 | const a=10; 2 | var b,c; 3 | procedure p; 4 | var k; 5 | begin 6 | c:=b+a; 7 | end; 8 | begin 9 | read(b); 10 | while b#0 do 11 | begin 12 | call p; 13 | write(2*c); 14 | read(b) 15 | end 16 | end. 17 | 18 | -------------------------------------------------------------------------------- /1/ex1.pl0: -------------------------------------------------------------------------------- 1 | const n=3; 2 | var a,b,c,t; 3 | begin 4 | read(a); read(b); read(c); 5 | if aa then 13 | begin 14 | write(c); 15 | write(a); 16 | write(b); 17 | end 18 | else 19 | begin 20 | if b>c then 21 | begin 22 | write(a); 23 | write(b); 24 | write(c); 25 | end; 26 | if b<=c then 27 | begin 28 | write(a); 29 | write(c); 30 | write(b); 31 | end; 32 | end; 33 | end. -------------------------------------------------------------------------------- /3/ifelse.pl0: -------------------------------------------------------------------------------- 1 | var a,b,c,d; 2 | begin 3 | read(a); 4 | read(b); 5 | read(c); 6 | if aa then 13 | begin 14 | write(c); 15 | write(a); 16 | write(b); 17 | end 18 | else 19 | begin 20 | if b>c then 21 | begin 22 | write(a); 23 | write(b); 24 | write(c); 25 | end; 26 | if b<=c then 27 | begin 28 | write(a); 29 | write(c); 30 | write(b); 31 | end; 32 | end; 33 | end. --------------------------------------------------------------------------------