电子科技大学 编译原理期末女娲补天
算是考完了 真难啊。。 学弟学妹们看到了可以参考下 内有真题一套 稍有些混乱的复习笔记一堆 不建议全部相信 因为本人复习得比较拉胯。。
参考下是ok的 语雀链接食用体验更佳 戳这里~
考完来简单总结下
题目与往年差不太多
- 语法树
- FIRSTVT表 LASTVT集
- FIRST集 FOLLOW集 构造预测分析表
- 中间代码分析
- SLR(1)分析法
- 语义子程序的翻译
经验总结:ppt直接看根本看不懂 顺序也比较奇怪 建议先通读一遍ppt 有不懂的先跳过 然后重要知识点多百度一下 可以去bilibili听一些up主讲一下
我晕 图片因为是语雀导出的 所以链接有点问题 懒得改了 咱就是说 建议看语雀上的内容哈 戳这里~
语言部分
1-变量及其属性
变量是对一个(或若干个)存储单元的抽象,赋值语句则是修改存储单元内容的抽象。
属性:
- 作用域:可以访问该变量的程序范围
- 生存期:一个储存区绑定于一个变量的时间区间
- 值:变量对应的存储单元的内容
- 类型:与变量相关联的值的类, 以及对这些值进行的操作的说明。
1-虚拟机的概念
![image.png](https://img-blog.csdnimg.cn/img_convert/4ea42b00770d306ab2d814f608d83c3d.png#clientId=u43ff57c7-d1bf-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=354&id=ufd028177&margin=[object Object]&name=image.png&originHeight=443&originWidth=921&originalType=binary&ratio=1&rotation=0&showTitle=false&size=60450&status=done&style=none&taskId=u97a96f7f-845d-488a-8fde-1b0e9da8cea&title=&width=736.8)
1-程序单元 & 单元实例
![image.png](https://img-blog.csdnimg.cn/img_convert/a29ee9edde321e691997abada95ea9cb.png#clientId=u43ff57c7-d1bf-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=102&id=ua5e9e170&margin=[object Object]&name=image.png&originHeight=127&originWidth=777&originalType=binary&ratio=1&rotation=0&showTitle=false&size=27477&status=done&style=none&taskId=ub53aec50-8eb1-4677-9517-ab5c982c9e7&title=&width=621.6)
![image.png](https://img-blog.csdnimg.cn/img_convert/a3958e7b07bc8dc20d26ed1b3ba756a3.png#clientId=u43ff57c7-d1bf-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=183&id=u8aae8fe3&margin=[object Object]&name=image.png&originHeight=229&originWidth=751&originalType=binary&ratio=1&rotation=0&showTitle=false&size=46256&status=done&style=none&taskId=ub08c3f54-1add-481c-b421-9ca447cb1b9&title=&width=600.8)
- 活动记录:执行单元所需要的信息,以及该单元的局部变量所绑定的数据对象的存储区
2-数据类型的作用
简答题~
- 实现了数据抽象
- 使程序员从机器的具体特征中解脱出来
- 提高了编程效率
2-数据聚合的六种方式
填空题~
![image.png](https://img-blog.csdnimg.cn/img_convert/7897ffa1407d29a8f86b39154567ec04.png#clientId=u43ff57c7-d1bf-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=334&id=u76a6340b&margin=[object Object]&name=image.png&originHeight=417&originWidth=958&originalType=binary&ratio=1&rotation=0&showTitle=false&size=64229&status=done&style=none&taskId=uc14c57dc-64c5-45e4-a39b-d6bf6ba93ca&title=&width=766.4)
2-类型检查及分类
- 对数据对象的类型和使用的操作是否匹配的一致性检查称为类型检查
- 静态检查
- 动态检查
![image.png](https://img-blog.csdnimg.cn/img_convert/222c54acc3d7cf5b0d7882076fe757e0.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=237&id=ub1ec4e54&margin=[object Object]&name=image.png&originHeight=296&originWidth=945&originalType=binary&ratio=1&rotation=0&showTitle=false&size=89989&status=done&style=none&taskId=u356cb54e-7b02-4164-a2a0-be2d01c67b0&title=&width=756)
2-抽象数据类型的条件
- 在实现该类型的程序单元中,建立与表示有关的基本操作;
- 对使用该类型的程序单元来说,该类型的表示是隐蔽的。
![image.png](https://img-blog.csdnimg.cn/img_convert/bd7a7f41b7170652423cd51d7f5d08bd.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=441&id=u364192c8&margin=[object Object]&name=image.png&originHeight=551&originWidth=902&originalType=binary&ratio=1&rotation=0&showTitle=false&size=97074&status=done&style=none&taskId=uc12038a7-3563-4926-b922-bf2acc13e0d&title=&width=721.6)
2-何为类型等价
![image.png](https://img-blog.csdnimg.cn/img_convert/5ae8c0d480687bc024939988ac9cdb9b.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=374&id=u5ccef115&margin=[object Object]&name=image.png&originHeight=467&originWidth=893&originalType=binary&ratio=1&rotation=0&showTitle=false&size=99995&status=done&style=none&taskId=u257d2868-c304-434a-b651-0dfd3e7c0e9&title=&width=714.4)
3-语句级控制结构——顺序、选择、重复
- 顺序
![image.png](https://img-blog.csdnimg.cn/img_convert/c1eebe51aabfa1b86aa759a3fb347cba.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=65&id=u85ebdc94&margin=[object Object]&name=image.png&originHeight=157&originWidth=569&originalType=binary&ratio=1&rotation=0&showTitle=false&size=12334&status=done&style=none&taskId=u187fe682-37cb-4c0e-a00d-16dd696d688&title=&width=234.1875)
- 选择
![image.png](https://img-blog.csdnimg.cn/img_convert/91b67fd3878c1ae2bf8cd4b213957663.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=165&id=ubedc469e&margin=[object Object]&name=image.png&originHeight=457&originWidth=918&originalType=binary&ratio=1&rotation=0&showTitle=false&size=72341&status=done&style=none&taskId=uff967589-fae9-4aab-a4aa-6b318f245a2&title=&width=331)
![image.png](https://img-blog.csdnimg.cn/img_convert/77321d14808c7a613711110208b6e6f8.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=231&id=ue298d98d&margin=[object Object]&name=image.png&originHeight=370&originWidth=551&originalType=binary&ratio=1&rotation=0&showTitle=false&size=23707&status=done&style=none&taskId=u31f95994-51ab-4676-b316-d53997f30c5&title=&width=343.796875)
- 重复
![image.png](https://img-blog.csdnimg.cn/img_convert/072c73c5e124e0b4ea6eacbaeade6ae7.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=247&id=uec49d88a&margin=[object Object]&name=image.png&originHeight=600&originWidth=973&originalType=binary&ratio=1&rotation=0&showTitle=false&size=62611&status=done&style=none&taskId=uaaba7098-415d-44a1-a484-51ec8fec2f2&title=&width=400)
![image.png](https://img-blog.csdnimg.cn/img_convert/e9386c4b60aac0780dbf10c6d23887aa.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=81&id=ua0fa35f1&margin=[object Object]&name=image.png&originHeight=157&originWidth=781&originalType=binary&ratio=1&rotation=0&showTitle=false&size=19215&status=done&style=none&taskId=ud26a853d-eb9a-439d-b5fa-6e1fe302f38&title=&width=401)
- 语句级控制结构分析
![image.png](https://img-blog.csdnimg.cn/img_convert/cd74faefe1cf0687662e0c1c0487bc36.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=294&id=u38a9b680&margin=[object Object]&name=image.png&originHeight=368&originWidth=778&originalType=binary&ratio=1&rotation=0&showTitle=false&size=70921&status=done&style=none&taskId=u8034c626-00f1-44e2-a159-40782249e54&title=&width=622.4)
3-单元级控制结构
规定程序单元之间控制流程的机制
![image.png](https://img-blog.csdnimg.cn/img_convert/e6963813f665e34c775ad6fc776f3873.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=239&id=u688b1300&margin=[object Object]&name=image.png&originHeight=299&originWidth=427&originalType=binary&ratio=1&rotation=0&showTitle=false&size=23465&status=done&style=none&taskId=uc25848a9-e8ae-48ea-855c-59c8204e52d&title=&width=341.6)
3-副作用、别名
- 非局部变量
一个程序单元可以引用未被本单元说明而被其他单元说明的变量
int a;
int b = 666;
a = 666; —— a为非局部变量 可以这么理解?
- 非局部变量绑定于其他的程序单元(定义该非局部变量的程序单元)的活动记录中的数据对象;
- 或非局部变量绑定全局数据区中的数据对象称为非局部环境
![image.png](https://img-blog.csdnimg.cn/img_convert/b414159eac01b4368f63108d8cfe99f8.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=454&id=uc3f41212&margin=[object Object]&name=image.png&originHeight=567&originWidth=800&originalType=binary&ratio=1&rotation=0&showTitle=false&size=64726&status=done&style=none&taskId=u9d6a78d5-bb7f-426e-bad6-09b5fddca7b&title=&width=640)
![image.png](https://img-blog.csdnimg.cn/img_convert/0b5b364fcd9e166abc5dbf17375236f1.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=418&id=u6f5dccb5&margin=[object Object]&name=image.png&originHeight=523&originWidth=894&originalType=binary&ratio=1&rotation=0&showTitle=false&size=52180&status=done&style=none&taskId=ua1223ac1-44de-45ac-a582-37d1fb013ff&title=&width=715.2)
哪俩属于别名?
![image.png](https://img-blog.csdnimg.cn/img_convert/6da799257570f8c12851e297fad88831.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=478&id=u640b86ba&margin=[object Object]&name=image.png&originHeight=598&originWidth=757&originalType=binary&ratio=1&rotation=0&showTitle=false&size=36187&status=done&style=none&taskId=u2af28ad0-420e-4b8f-88a2-f967d813b2c&title=&width=605.6)
![image.png](https://img-blog.csdnimg.cn/img_convert/fadeb4946f80a3e3242b19f0693b21a5.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=458&id=ud28580e6&margin=[object Object]&name=image.png&originHeight=573&originWidth=969&originalType=binary&ratio=1&rotation=0&showTitle=false&size=65953&status=done&style=none&taskId=ua63169b4-23dd-4152-b97b-af667388c66&title=&width=775.2)
![image.png](https://img-blog.csdnimg.cn/img_convert/760c9831aedf7109c5f5fd1666a20943.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=426&id=uc02b90f5&margin=[object Object]&name=image.png&originHeight=532&originWidth=898&originalType=binary&ratio=1&rotation=0&showTitle=false&size=60809&status=done&style=none&taskId=u768a9a27-b237-4404-9fb7-71dd1c83e80&title=&width=718.4)
4-语言的定义
程序设计语言是用来描述计算机所执行的算法的形式表示;
![image.png](https://img-blog.csdnimg.cn/img_convert/f718579c80c1b0c3521ac83556bed5c7.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=118&id=u43109937&margin=[object Object]&name=image.png&originHeight=358&originWidth=1293&originalType=binary&ratio=1&rotation=0&showTitle=false&size=25025&status=done&style=none&taskId=u94151c07-f5dc-4222-b866-185e68a88d0&title=&width=425)
![image.png](https://img-blog.csdnimg.cn/img_convert/f1a8a771a00725f489372bb8191497b2.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=387&id=u3fb896f9&margin=[object Object]&name=image.png&originHeight=597&originWidth=816&originalType=binary&ratio=1&rotation=0&showTitle=false&size=69518&status=done&style=none&taskId=uc404048d-ae12-4117-a249-f2641650355&title=&width=528.7999877929688)
![image.png](https://img-blog.csdnimg.cn/img_convert/a60caebf194b477479b2fc2bea703fba.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=350&id=u2f1657ea&margin=[object Object]&name=image.png&originHeight=437&originWidth=758&originalType=binary&ratio=1&rotation=0&showTitle=false&size=56747&status=done&style=none&taskId=u22960806-f342-46d5-af02-300dc8e81f6&title=&width=606.4)
4-语法描述的基本用途
![image.png](https://img-blog.csdnimg.cn/img_convert/7e76816c8b43164cec47c72560c3654f.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=282&id=u7f7b6a4d&margin=[object Object]&name=image.png&originHeight=468&originWidth=934&originalType=binary&ratio=1&rotation=0&showTitle=false&size=45725&status=done&style=none&taskId=uc428b845-649f-42b4-bb77-e64b0cc3f32&title=&width=563.2000122070312)
4-文法的定义
![image.png](https://img-blog.csdnimg.cn/img_convert/fd4646dee97593183162bf56c44cee33.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=424&id=u54669f0a&margin=[object Object]&name=image.png&originHeight=530&originWidth=675&originalType=binary&ratio=1&rotation=0&showTitle=false&size=77163&status=done&style=none&taskId=ua77509a4-df0c-4999-b095-632b9aabf0f&title=&width=540)
用英文大写字母表示非终结符;小写字母表示终结符;希腊小写字母表示串
4-文法的分类
- 0型文法 产生式形如α→b
- α中至少含一个非终结符
- 1型文法 │α│<=│β│(S→e例外)或产生式形如αAβ→αwβ,w∈V+ (上下文有关文法)
- α中终结符个数小于β
- 2型文法 产生式形如A→α (上下文无关文法)
- 产生式右端均为终结符
- S—>aB|bA
- A—>aS|bAA|a
- B—>bS|aBB|b
- 产生式右端均为终结符
- 3型文法 产生式形如A→α或A→αB (正则文法,右线性文法) α∈VT*
- 在2型的基础上要求右端最多有一个非终结符,且位于最右端
- S—>bA
- A—>(B|a
- B—>aA
- 在2型的基础上要求右端最多有一个非终结符,且位于最右端
![image.png](https://img-blog.csdnimg.cn/img_convert/331e2dedba860ee2b8cf127bd383de9f.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=269&id=udef3ba5b&margin=[object Object]&name=image.png&originHeight=417&originWidth=817&originalType=binary&ratio=1&rotation=0&showTitle=false&size=28475&status=done&style=none&taskId=ub50e0a93-3294-42f1-bebf-c62bb634533&title=&width=527.6000366210938)
4-文法产生的语言
推导(与归约)
![image.png](https://img-blog.csdnimg.cn/img_convert/60a3610f2b828fe80d1937a04f721a1f.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=315&id=u1a375cc2&margin=[object Object]&name=image.png&originHeight=394&originWidth=791&originalType=binary&ratio=1&rotation=0&showTitle=false&size=34742&status=done&style=none&taskId=ubc6ae221-b7e5-4dcf-a576-b6fda1cdf39&title=&width=632.8)
![image.png](https://img-blog.csdnimg.cn/img_convert/042a7de27d1ee26f5927f51e715fca50.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=254&id=u761b4190&margin=[object Object]&name=image.png&originHeight=414&originWidth=971&originalType=binary&ratio=1&rotation=0&showTitle=false&size=49300&status=done&style=none&taskId=u09d083e2-0c16-4126-80cd-befa91d2e0a&title=&width=594.7999877929688)
句型 & 句子
![image.png](https://img-blog.csdnimg.cn/img_convert/9a1140a6569e7bd98fc6ba5eebd406fc.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=273&id=u59fee977&margin=[object Object]&name=image.png&originHeight=341&originWidth=842&originalType=binary&ratio=1&rotation=0&showTitle=false&size=49331&status=done&style=none&taskId=uc7080528-eb38-441d-84a9-cfbabb6e838&title=&width=673.6)
![image.png](https://img-blog.csdnimg.cn/img_convert/2517dec41cdc9b1522ff043b4ed0e57c.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=267&id=Mxi6C&margin=[object Object]&name=image.png&originHeight=334&originWidth=692&originalType=binary&ratio=1&rotation=0&showTitle=false&size=24343&status=done&style=none&taskId=u29a24ab4-e42c-4c99-834b-0a8f1221f70&title=&width=553.6)
文法产生的语言L(G)
![image.png](https://img-blog.csdnimg.cn/img_convert/1d4529c962e1fde24d8a493543843db9.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=159&id=u7a9ebf3d&margin=[object Object]&name=image.png&originHeight=199&originWidth=813&originalType=binary&ratio=1&rotation=0&showTitle=false&size=23648&status=done&style=none&taskId=u442ad452-6abb-47a1-bbf2-d679e21d536&title=&width=650.4)
- 例一
![image.png](https://img-blog.csdnimg.cn/img_convert/2e4e748e773263d5e3c24bef100995a9.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=308&id=ub89fa06c&margin=[object Object]&name=image.png&originHeight=385&originWidth=552&originalType=binary&ratio=1&rotation=0&showTitle=false&size=18490&status=done&style=none&taskId=uc92a77f3-0666-4f37-837c-1d1bcbd6f4f&title=&width=441.6)
- 例二
![image.png](https://img-blog.csdnimg.cn/img_convert/c27298832a6a7bcc0f090e0c45556afe.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=392&id=ucc3603d3&margin=[object Object]&name=image.png&originHeight=490&originWidth=388&originalType=binary&ratio=1&rotation=0&showTitle=false&size=20793&status=done&style=none&taskId=u741ffa9c-f3ee-4d5e-8024-0ddad519d6b&title=&width=310.4)
![image.png](https://img-blog.csdnimg.cn/img_convert/73f66c6ba2930e96ff4e904de059b468.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=222&id=ub38f0547&margin=[object Object]&name=image.png&originHeight=277&originWidth=729&originalType=binary&ratio=1&rotation=0&showTitle=false&size=36495&status=done&style=none&taskId=uf4265922-0b2e-4d54-8cbc-2c2e40ff22d&title=&width=583.2)
短语、句柄、素短语
- 短语——叶子节点
- 句柄——最左直接短语
![image.png](https://img-blog.csdnimg.cn/img_convert/010e72803b14cd60543ce9cb2fdde33d.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=261&id=u7cc5f028&margin=[object Object]&name=image.png&originHeight=514&originWidth=1744&originalType=binary&ratio=1&rotation=0&showTitle=false&size=162522&status=done&style=none&taskId=u2b570d71-bd78-4179-b43c-796baae436f&title=&width=887.2000732421875)
语法树(推导树)
字面意思~
4-例题:推导、句型、句子、短语、句柄
- 例一
![image.png](https://img-blog.csdnimg.cn/img_convert/49fb78a55400d1c802137355645ab243.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=322&id=ubc2d4f11&margin=[object Object]&name=image.png&originHeight=402&originWidth=855&originalType=binary&ratio=1&rotation=0&showTitle=false&size=33061&status=done&style=none&taskId=u465d51e3-f69b-4fbb-822c-3232734b18a&title=&width=684)
![image.png](https://img-blog.csdnimg.cn/img_convert/66a899536c553397a99a79f3d2589326.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=570&id=ub0adc1d6&margin=[object Object]&name=image.png&originHeight=712&originWidth=1004&originalType=binary&ratio=1&rotation=0&showTitle=false&size=94544&status=done&style=none&taskId=uffd152eb-77b6-49c3-af2e-0a99e1c1f2c&title=&width=803.2)
- 例二
![image.png](https://img-blog.csdnimg.cn/img_convert/6b3da262bfab21da2b7ccc4a7a17237d.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=518&id=u0841fc97&margin=[object Object]&name=image.png&originHeight=648&originWidth=931&originalType=binary&ratio=1&rotation=0&showTitle=false&size=70378&status=done&style=none&taskId=u2593ee07-6eb8-4a33-80c6-623ca122f1e&title=&width=744.8)
- 例三
![image.png](https://img-blog.csdnimg.cn/img_convert/8bfa9f70f5b85b6912acdc8bdc9c97cc.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=497&id=u126181dc&margin=[object Object]&name=image.png&originHeight=621&originWidth=893&originalType=binary&ratio=1&rotation=0&showTitle=false&size=79256&status=done&style=none&taskId=u6219a196-881b-4239-ab82-661bb39377f&title=&width=714.4)
编译部分
5-编译等概念
翻译:将一种语言编写的程序转换成完全等效的另一种语言编写的程序的过程。在计算机中,翻译由一 个程序来实现,称为翻译程序
**宿主语言:**编写编译程序的语言。运行翻译程序的机称为宿主机
静态语言需要先进行编译,才能执行代码
![image.png](https://img-blog.csdnimg.cn/img_convert/692788931d22f11a854f3709e9c809e4.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=130&id=u524af629&margin=[object Object]&name=image.png&originHeight=320&originWidth=766&originalType=binary&ratio=1&rotation=0&showTitle=false&size=34683&status=done&style=none&taskId=uaf376318-3dfd-4994-b246-4d5bd20c73d&title=&width=310)
动态语言则是可以边解释 边执行代码
![image.png](https://img-blog.csdnimg.cn/img_convert/ec10684b070a25a77ff0f7f31c7fbc2e.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=217&id=u7ab9f48e&margin=[object Object]&name=image.png&originHeight=563&originWidth=867&originalType=binary&ratio=1&rotation=0&showTitle=false&size=113864&status=done&style=none&taskId=ub17f7c64-2e68-4b1d-b524-cac722c2322&title=&width=334)
5-编译步骤
- 词法分析
- 输入字符串 根据词法规则识别出单词符号
- 语法分析
- 根据语法规则 将单词符号构成各类语法单位 并进行语法检查
- 语义分析
- 根据语义规则,进行初步编译
- 优化
- 对中间代码进行等价变换 以使代码更有效
- 目标代码生成
- 生成机器语言程序或汇编语言程序
- 符号表管理
- 完成符号表的建立、查找、更新
- 出错处理
![image.png](https://img-blog.csdnimg.cn/img_convert/51195f7e1e94a6f559a48ee165130664.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=509&id=u1de7bbc3&margin=[object Object]&name=image.png&originHeight=636&originWidth=931&originalType=binary&ratio=1&rotation=0&showTitle=false&size=83981&status=done&style=none&taskId=uadc51272-f6e0-4370-8b71-805d045caf5&title=&width=744.8)
6-词法分析器的功能
扫描源程序的字符串,按照词法规则,识别出单词符号作为输出
对识别过程中发现的词法错误输出有关的错误信息。
词法分析器是子程序
- ![image.png](https://img-blog.csdnimg.cn/img_convert/66ce5b647542b4e3315294a9f4368ee9.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=82&id=u9809a478&margin=[object Object]&name=image.png&originHeight=102&originWidth=844&originalType=binary&ratio=1&rotation=0&showTitle=false&size=7851&status=done&style=none&taskId=uec78837a-4f30-46ec-81f4-4ee309fee13&title=&width=675.2)
- ![image.png](https://img-blog.csdnimg.cn/img_convert/59a43798ef8f4a5384c02ef24693a113.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=244&id=ufee0b24d&margin=[object Object]&name=image.png&originHeight=305&originWidth=775&originalType=binary&ratio=1&rotation=0&showTitle=false&size=21612&status=done&style=none&taskId=u4a5d00a0-0051-4283-ab35-dc805af2586&title=&width=620)
6-单词符号的分类
- 标识符![image.png](https://img-blog.csdnimg.cn/img_convert/776baa0ef93ee692c3079e360174c88e.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=70&id=u744bdd60&margin=[object Object]&name=image.png&originHeight=88&originWidth=592&originalType=binary&ratio=1&rotation=0&showTitle=false&size=12930&status=done&style=none&taskId=ub71358fe-02a1-44e2-a62f-9e3840532b1&title=&width=473.6)
- 基本字![image.png](https://img-blog.csdnimg.cn/img_convert/7cfa930f51aef1daeb84878ad532cf88.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=74&id=ub51a6d37&margin=[object Object]&name=image.png&originHeight=92&originWidth=658&originalType=binary&ratio=1&rotation=0&showTitle=false&size=11849&status=done&style=none&taskId=u75e448b3-c878-482c-b97b-f4f1006300f&title=&width=526.4)
- 常数![image.png](https://img-blog.csdnimg.cn/img_convert/44ff4e1453c77a339bd6fb2cc0ceaa8c.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=38&id=ub5d89dbc&margin=[object Object]&name=image.png&originHeight=48&originWidth=723&originalType=binary&ratio=1&rotation=0&showTitle=false&size=9557&status=done&style=none&taskId=ue1025b26-738a-48a8-824d-96983de652c&title=&width=578.4)
- 运算符![image.png](https://img-blog.csdnimg.cn/img_convert/1d89891f41ab940b9766e802ccac1187.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=29&id=u4beea98b&margin=[object Object]&name=image.png&originHeight=36&originWidth=201&originalType=binary&ratio=1&rotation=0&showTitle=false&size=1251&status=done&style=none&taskId=u7fc48843-860e-4b33-8c9d-855cb92fcea&title=&width=160.8)
- 界符![image.png](https://img-blog.csdnimg.cn/img_convert/9ca2b2851691b8dccc089e120bd49b3b.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=30&id=u37faffd8&margin=[object Object]&name=image.png&originHeight=37&originWidth=234&originalType=binary&ratio=1&rotation=0&showTitle=false&size=1405&status=done&style=none&taskId=u883b916f-d585-47f6-bd58-0141bc7a02c&title=&width=187.2)
单词类别的划分(编码的方式)
![image.png](https://img-blog.csdnimg.cn/img_convert/7a780b85443a9d897fe341be98ad5b6f.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=194&id=Ktok7&margin=[object Object]&name=image.png&originHeight=243&originWidth=633&originalType=binary&ratio=1&rotation=0&showTitle=false&size=20425&status=done&style=none&taskId=ue65ae947-508b-46da-ad49-244943f1290&title=&width=506.4)
![image.png](https://img-blog.csdnimg.cn/img_convert/93908c56864e8e7e2a742edc35b84909.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=386&id=u83677bb9&margin=[object Object]&name=image.png&originHeight=483&originWidth=567&originalType=binary&ratio=1&rotation=0&showTitle=false&size=55812&status=done&style=none&taskId=u4debca2d-2623-4546-a1aa-8c083ba5c90&title=&width=453.6)
6-状态转换图
简称转换图,是一张有限方向图,是设计词法分析器的有效工具;它由如下成分构成:
1.结点(node):圆圈表示结点,代表状态(state)
2.有向边(弧):连接结点,边上的标记字符表示该状态下可能接收或识别的字符;
![image.png](https://img-blog.csdnimg.cn/img_convert/7af71e05b57eb78eb04672825dee8b84.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=183&id=u05fa2709&margin=[object Object]&name=image.png&originHeight=229&originWidth=785&originalType=binary&ratio=1&rotation=0&showTitle=false&size=31271&status=done&style=none&taskId=u5a75951d-eb61-4dd3-9d34-eed32bffe75&title=&width=628)
![image.png](https://img-blog.csdnimg.cn/img_convert/a27ba920d2ba371b89f36b539b77ca2d.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=290&id=u4cc05622&margin=[object Object]&name=image.png&originHeight=457&originWidth=874&originalType=binary&ratio=1&rotation=0&showTitle=false&size=44464&status=done&style=none&taskId=u9d970797-3027-4f12-8162-de8165638e9&title=&width=554.2000122070312)
例子
![image.png](https://img-blog.csdnimg.cn/img_convert/b2481e3039e718e9cb7c21ad3004b69c.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=416&id=u204147bc&margin=[object Object]&name=image.png&originHeight=520&originWidth=918&originalType=binary&ratio=1&rotation=0&showTitle=false&size=58327&status=done&style=none&taskId=ufb1e2848-affd-443c-9467-8dab4662488&title=&width=734.4)
第六章 ppt p21
![image.png](https://img-blog.csdnimg.cn/img_convert/2fc35d37e63a1280f8c09febc4d63b88.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=444&id=uc76e7931&margin=[object Object]&name=image.png&originHeight=874&originWidth=1394&originalType=binary&ratio=1&rotation=0&showTitle=false&size=195253&status=done&style=none&taskId=u1521593f-fa99-4e42-b988-5c12788b7e3&title=&width=708.2000732421875)
重点——语法分析
语法分析分为两种
第七章——自上而下(自顶而下)
第八章——自下而上(自底而上)
![image.png](https://img-blog.csdnimg.cn/img_convert/323e076582d628b80ae4930d8a48caf8.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=447&id=u749fac64&margin=[object Object]&name=image.png&originHeight=559&originWidth=844&originalType=binary&ratio=1&rotation=0&showTitle=false&size=80443&status=done&style=none&taskId=u1ca8cc0c-4667-4a07-9e4a-daea6b4eabb&title=&width=675.2)
7-回溯分析法
![image.png](https://img-blog.csdnimg.cn/img_convert/d51d761ec076975913349e782091b6b6.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=374&id=u9c7ab631&margin=[object Object]&name=image.png&originHeight=538&originWidth=931&originalType=binary&ratio=1&rotation=0&showTitle=false&size=84847&status=done&style=none&taskId=u54b26544-2ea7-4a51-bb36-7f664de5412&title=&width=647.7999877929688)
![image.png](https://img-blog.csdnimg.cn/img_convert/e17307a94513a9aac68fcdab563c3d0c.png#clientId=ub82bd813-5d31-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=386&id=u95cd013f&margin=[object Object]&name=image.png&originHeight=482&originWidth=701&originalType=binary&ratio=1&rotation=0&showTitle=false&size=35735&status=done&style=none&taskId=u6188a0ea-626d-42e8-9562-ce86e9e05d1&title=&width=560.8)
7-公共左因子
这个例子是啥意思?
电子科技大学 编译原理期末女娲补天相关推荐
- 编译原理期末速成笔记
哈喽大家好,又要考试了,在这里分享一下我的两天速成笔记,参考视频为哔站 Deeplei_ 的<编译原理期末速成>.本文仅是知识点总结,至于考试内容待我研究一下,后续我会再发文对考试的各个模 ...
- 编译原理期末复习重点
文章目录 编译原理期末复习纲要 一.选判填 二.简答题 二.大题 编译原理期末复习纲要 仅供自己观看 一.选判填 单选:5*1=5' 判断:5*1'=5' 填空:5*2'=10' 合计:20' 二.简 ...
- 杭州电子科技大学计算机组成原理期末试卷,杭州电子科技大学计算机组成原理期末样卷(A)...
组成样卷A卷 杭州电子科技大学学生考试卷(A)卷 一.单项选择题(20分,每题1分) 1.完整的计算机系统应包括() A.运算器.存储器.控制器 B.外设和主机 C.主机和实用程序 D.配套的硬件设备 ...
- 编译原理期末复习—第一章概论
后续会更新编译原理其他章节(有问题请指正) 文章目录 前言 一.程序设计语言的发展 1.机器语言 2.汇编语言 3.程序设计语言 二.基本术语解释 前言 参考了<编译原理>王生原,张素琴等 ...
- [渝粤教育] 西南科技大学 编译原理与技术 在线考试复习资料2021版
编译原理与技术--在线考试复习资料2021版 一.单选题 1.下列选项中,能由语义分析检查出的是( ). A.花括号不配对 B.变量未声明就使用 C.程序中有非法符号 D.表达式错误 答案:看左边查询 ...
- 编译原理期末复习笔记
编译原理这门课通过证明是可以速成的. 我说的"速成"是平时还要支棱一只耳朵听课哦. 其实后面几次课听了之后仿佛掌握到了其中精髓. 还有就是这门课复习起来很爽,因为复习过程可以感悟到 ...
- 哈工大编译原理期末复习(完整版)
文章目录 本文PDF下载 一.绪论 1.1 什么是编译 1.2 编译系统的结构 1.3 编译程序的生成 1.4 为什么要学习编译原理 1.5 编译技术的应用 二.语言及其文法 2.1 基本概念 2.2 ...
- 2017春季学期编译原理期末实验报告
实验名:PL/0编译器的实现 一.实验目的 理解编译器的工作机制,掌握编译器的构造方法 掌握词法分析器的生成工具LEX的用法 掌握语法分析器的生成工具YACC的用法 二.实验内容简要概括 1.实验分为 ...
- 编译原理 期末考试复习题
期末考试复习题 判断 高级程序设计语言的代码在机器上运行可通过编译方式或解释方式实现,编译方式优于解释方式.错误 计算机只能识别机器代码,所以只能用机器语言实现编译程序.错误 不是所有句型都有规范推导 ...
最新文章
- hive常用参数配置设置
- 高效使用Vector
- 《剑指offer》答案整理
- mqtt判断设备是否在线_如何在 Python 中使用 MQTT
- 为什么同现矩阵*评分矩阵=推荐结果?
- 个人三观的东西(1)
- 盘点12个Python数据可视化库,通吃任何领域
- attilax.java 注解的本质and 使用最佳实践(3)O7
- 鸿蒙系统主题如何自定义,华为鸿蒙系统细节曝光 支持自定义选项
- 博客推广技巧:如何通过博客推广并实现营销
- 使用Softice调试驱动程序
- LeetCode 285. 二叉搜索树中的中序后继
- map、set、multimap、multiset、hash_map、hah_set、hash_multimap、hash_multiset
- python学习 之 笔记一
- ITIL 4 讲解:事态、事件、灾难流程如何界定?
- 一道题Wrong Answer之后该何去何从?
- 由例子程序给出的显示列表,展示重定形函数的应用
- 算法设计与分析之八枚硬币问题
- Java进阶——如何查看Java字节码
- S7-1200PLC与MCGS触摸屏通讯