├── 编译实验.doc ├── 实验一 ├── 实验一程序.exe ├── 实验一源代码.cpp ├── program2.txt └── program1.txt ├── 实验二 ├── 实验二程序.exe ├── 实验二源代码.cpp ├── program4.txt └── program3.txt └── README.md /编译实验.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugarzo/SampleCompilation/HEAD/编译实验.doc -------------------------------------------------------------------------------- /实验一/实验一程序.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugarzo/SampleCompilation/HEAD/实验一/实验一程序.exe -------------------------------------------------------------------------------- /实验二/实验二程序.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugarzo/SampleCompilation/HEAD/实验二/实验二程序.exe -------------------------------------------------------------------------------- /实验一/实验一源代码.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugarzo/SampleCompilation/HEAD/实验一/实验一源代码.cpp -------------------------------------------------------------------------------- /实验二/实验二源代码.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sugarzo/SampleCompilation/HEAD/实验二/实验二源代码.cpp -------------------------------------------------------------------------------- /实验一/program2.txt: -------------------------------------------------------------------------------- 1 | program example2; 2 | var A,B,C:integer; 3 | X,Y:bool; 4 | begin /* this is an example */ 5 | A:=B*C+37; 6 | X:='AB C' 7 | end. -------------------------------------------------------------------------------- /实验二/program4.txt: -------------------------------------------------------------------------------- 1 | program example5; 2 | var A,B,C,D,W:integer; 3 | begin 4 | A:=5; B:=4; C:=3; D:=2; W:=1; 5 | if W>=1 then A:=B*C+B/D 6 | else repeat A:=A+1 until A<0 7 | end. -------------------------------------------------------------------------------- /实验二/program3.txt: -------------------------------------------------------------------------------- 1 | program example4; 2 | var A,B,C,D:integer; 3 | begin 4 | A:=1; B:=5; C:=3; D:=4; 5 | while AD do 6 | if A=1 then C:=C+1 else 7 | while A<=D do A:=A*2 8 | end. -------------------------------------------------------------------------------- /实验一/program1.txt: -------------------------------------------------------------------------------- 1 | and array begin bool call 2 | case char constant dim do 3 | else end false for if 4 | input integer not of or 5 | output procedure program read real 6 | repeat set stop then to 7 | true until var while write 8 | abc 123 'EFG' ( ) * + , - . .. / 9 | : := ; < <= <> = > >= [ ] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 大二上 2 | **编译原理大作业** 3 | 4 | **留档** 5 | 6 | 设计SAMPLE语言的词法分析器、语法分析器 7 | 8 | ![image](https://user-images.githubusercontent.com/74815734/159162843-7750f24a-2d29-444a-a755-2da4236012d6.png) 9 | 10 | 程序核心思想:LL(1)分析法。让产生式右部逐个文法符号与输入串匹配,每当一个文法符号获得匹配,就可以执行语义动作。 11 | 12 | ![image](https://user-images.githubusercontent.com/74815734/159162710-56822f14-0722-4824-886c-53e117045738.png) 13 | --------------------------------------------------------------------------------