├── .gitignore ├── 2019-Fall ├── L17-IR.md ├── L18-IR.md ├── L19SDT-1.md ├── L20SDT-2.md ├── L21SDT-3.md ├── bace-lecture-01.mkv ├── bace-lecture-01.pdf ├── bace-lecture-02.pdf ├── bace-lecture-03.pdf ├── bace-lecture-04.pdf ├── bace-lecture-05.pdf ├── bace-lecture-06.pdf ├── bace-lecture-09.pdf ├── bace-lecture-10.pdf ├── bace-lecture-11.pdf └── bace-lecture-12.pdf ├── 2021-Spring ├── S03E01-Intro.pdf └── local stack slot allocation.pdf ├── LICENSE ├── README.md └── doc ├── Makefile ├── bace lecture.rst ├── conf.py ├── images ├── image01.png ├── image02.png ├── image03.png ├── image04.png ├── image05.png ├── image06.png ├── image07.png ├── image08.png ├── image09.png ├── image10.png ├── image11.png ├── image12.png ├── image13.png ├── image14.png ├── image15.png ├── image16.png ├── image17.png ├── image18.png ├── image19.png ├── image20.png ├── image21.png ├── image22.png ├── image23.png ├── image24.png ├── image25.png ├── image26.png ├── image27.png ├── image28.png ├── image29.png ├── image30.png └── image31.png ├── index.rst └── make.bat /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /2019-Fall/L17-IR.md: -------------------------------------------------------------------------------- 1 | # 编译技术入门与实战 2 | 3 | ## Cooper 教授 L17-IR 评注 4 | 5 | ### 0 6 | 7 | 从业多年之后才能看懂里面的感悟 8 | 9 | ### 1 10 | 11 | Mea culpa is a Latin phrase that means "through my fault" and is an acknowledgement of having done wrong. Grammatically, meā culpā is in the ablative case, with an instrumental meaning. Wikipedia 12 | 13 | amnesty 大赦天下 14 | 15 | ### 2 16 | 17 | 这里都是一些经验之谈。 18 | 刚开始肯定无法体会,没关系的。 19 | 20 | cusp 21 | /kəsp/ 22 | Learn to pronounce 23 | noun 24 | noun: cusp; plural noun: cusps 25 | 26 | 1. 27 | a point of transition between two different states. 28 | "those on the cusp of adulthood" 29 | 2. 30 | a pointed end where two curves meet. 31 | 32 | Oxford Dict 33 | 34 | 这种乐趣门外汉是感受不到的,正所谓「初闻不识曲中意,再闻已是曲中人」。 35 | 36 | 37 | ### 3 38 | 39 | 说了编译器领域的共识。 40 | 41 | 前端 --IR--> 优化器 42 | 43 | 信息的表达方式决定了相关算法的能力 44 | 45 | ### 4 46 | 47 | IR: 信息的载体。哪些信息上船,哪些放在显眼位置。 48 | 49 | 优化器能看到的只有IR,IR没有的都看不到。 50 | 51 | 现在IR中允许加入各种annotation/attributes,在不改变IR的情况下加信息。就像是货运船上的集装箱。 52 | 53 | 当你开始自己设计编译器的时候,或许你就可以理解 ambition 在这里的包含的感情了。 54 | 55 | ### 5 - 7 56 | 57 | 思维里的分析框架。 58 | 59 | 这些设计的考虑,我们这门课的朋友大概有一个概念认识就行。 60 | 61 | 设计的取舍需要时间,动手尝试很多组合之后,形成 **自己的经验和喜好** 。 62 | 63 | ### 8 64 | 65 | index slide 66 | 67 | 下半部分在SDT中会讨论(存储模型在更后面) 68 | 69 | ### 9 70 | 71 | IR形式上的分类 72 | 参考 EaC 书中的解释 73 | 基本上:树AST,链3AC,混合SSA 74 | 75 | ### 10 76 | 77 | 直观的例子,略。 78 | 一些前端的工作就是将左边的形式翻译成右边的形式(BytecodeBuilder 或 Generator) 79 | 80 | ### 11 81 | 82 | 抽象层次和数据组织形式不是统一的。 83 | 例如解释器执行使用的字节码就比较抽象。 84 | 85 | ### 12 86 | 87 | 静态代码检查和程序理解一般会用到语法树 88 | 89 | ### 13 90 | 91 | 你遇到语法解析树的可能性比较小。 92 | 静态代码检查和程序理解一般用AST,更简洁。 93 | 解释器有时候也可以直接用AST计算。 94 | 95 | ### 14 96 | 97 | 暂时不用深究,不懂没关系,后面用到。 98 | 99 | 注意这里 value 的涵义。value 是多义词。 100 | 101 | value numbering 是一个很经典的算法。GVN基本都有实现。 102 | 103 | ### 15 104 | 105 | 这页内容是纯复习树的实现。 106 | 具体实现,比较简单。 107 | 二叉树和任意树转换算法看《数据结构》 108 | 109 | ### 16 110 | 111 | 稍微早了一点。这里是为了完整性。 112 | 113 | 依赖关系有数据的和控制流的,这里说的是BB内,不考虑控制流。 114 | 数据的关系是通过变量之间的 def use 体现的。后面有算法寻找到 def use 关系。(这里有兴趣推荐先看看燧原科技在B站公开的基于DCC888的公开课程,里面有详细介绍。本课程后续也会详细介绍这些算法。) 115 | 116 | ### 17 117 | 118 | 调用图要更后一点才遇到。 119 | 体现函数/方法之间的相互关系 120 | 121 | 提问: 122 | dep graph 节点是?,边是? 123 | CFG 的节点是?,边是? 124 | callgraph 的节点是,边是? 125 | 126 | ### 18 127 | 128 | di·gres·sion 129 | /ˌdīˈɡreSH(ə)n/ 130 | 131 | noun: digression; plural noun: digressions 132 | 133 | a temporary departure from the main subject in speech or writing. 134 | 135 | rant 136 | /rant/ 137 | 138 | verb: 139 | speak or shout at length in a wild, impassioned way. 140 | "she was still ranting on about the unfairness of it all" 141 | 142 | noun: 143 | a spell of ranting; a tirade. 144 | "his rants against organized religion" 145 | 146 | 技术细节,所有的对比都应该是整数比较,为了速度。 147 | 几乎所有的VM都会对字符串进行特殊的处理。 148 | 有的会对小字符串进行特殊处理,例如40字节以内的变量名或字面量。 149 | 150 | 后面就跟L18-IR的内容类似了。 151 | 152 | ### 19 153 | 154 | index page 155 | 156 | ### 20 157 | 158 | 三地址的地址可以理解为operand 159 | 是概念上的3地址 160 | 最多不超过3个,可以少于3个 161 | 162 | ### 21 163 | 164 | Quadruples 四元组 = 三地址 + opcode 165 | 所以可以有一张表格来表达 166 | 注意,数据流向是从左到右还是从右到左是喜好,没有唯一的规则。 167 | 168 | ### 22 169 | 170 | Triples 三元组 = 三地址 + opcode - 结果operand 171 | 隐藏的去哪里了?去到行号(序列ID)里面了。 172 | 173 | squint 174 | /skwint/ 175 | look at someone or something with one or both eyes partly closed in an attempt to see more clearly or as a reaction to strong light. 176 | 177 | ### 23 178 | 179 | 不确定我的理解是否正确。 180 | reorder 的是第一列,第二列不变。 181 | 182 | ### 24 - 25 183 | 184 | 考古:技术积累的重要过程。 185 | 计算机科学的历史很短,鼓励多阅读原始文献 186 | 187 | ### 26 188 | 189 | 二地址码可能就只有虚拟机里面了。 190 | X86? 191 | PDP-11 上古机型,有很多传奇可以考古 192 | 193 | 直接搜索 destructive operations 是医学解释, 194 | 195 | ### 27 196 | 197 | 栈指令集,操作数的制定可以嵌入到opcode里面。 198 | 例如 multiply a b -> c 可以假设 a b 在栈上,计算后 c 压栈。 199 | 最出名的是 JavaVM。 200 | V8 解释器和 Dalvik 使用的 reg based。 201 | 202 | 如果你感兴趣,可以找: 203 | Virtual Machine Showdown: Stack Versus Registers 204 | 205 | ### 28 206 | 207 | index slide 208 | -------------------------------------------------------------------------------- /2019-Fall/L18-IR.md: -------------------------------------------------------------------------------- 1 | # 编译技术入门与实战 2 | 3 | ## Cooper 教授 L18-IR 评注 4 | 5 | ### 0 - 16 6 | 7 | 复习 8 | 9 | ### 17 10 | 11 | 引入了BB的概念 12 | BB引出了CFG的概念 13 | 14 | ### 18 15 | 16 | SSA是重要的概念。换名原则。 17 | SSA能够极大简化某些分析。 18 | 19 | A = B + 1; 20 | A = 3 + C; 21 | D = A + 2; 22 | --> 23 | A1 = B + 1; 24 | A2 = 3 + C; 25 | D = ??? + 2; 26 | 27 | Kills 也是编译中的经典概念。 28 | 29 | ### 19 30 | 31 | 在汇聚点考虑 phi 节点。 32 | 33 | ### 20 34 | 35 | Phi 节点:存在性、最优解 36 | 每个汇聚点对每个变量考虑phi 37 | 有些phi可以删除掉(确定性的) 38 | 39 | ### 21 40 | 41 | 优劣分析,现在的我们看不懂,没关系。 42 | 43 | ### 22 44 | 45 | 冷知识:IR的数量大于编译器的数量 46 | 47 | ### 23 48 | 49 | 命名空间、or、名字空间。 50 | 51 | 跳转到 slide p30 先看下。 52 | 53 | ### 24 54 | 55 | 注意符号表的选择和设计是经验艺术。 56 | 初学者一般是仿照现有设计。 57 | 可以大胆的简化,刚好够用就行。 58 | 59 | ### 25 60 | 61 | 现实世界各种设计规则的组合爆炸。 62 | 还有实际程序运行中的速度和空间问题。 63 | 64 | 词法作用域:在编译时刻就完成名字绑定。 65 | 动态作用域:根据调用序列。 66 | 67 | 例子: 68 | ```C 69 | int y; 70 | Foo (x: int){ 71 | return x + y; 72 | } 73 | 74 | foo(x); // use global y. 75 | 76 | goo (z: int) { 77 | int y; 78 | foo(x); // ??? 79 | } 80 | ``` 81 | 82 | ### 26 83 | 84 | 想象一个链表。 85 | 从最内层开始查,先查到一个就停。 86 | C语言中的大括号构建了名字空间。 87 | 88 | ### 27 89 | 90 | 练习:搜索Python的相关文章。 91 | 92 | defy:违反 93 | 94 | ### 28 95 | 96 | 实际工程化中的各种麻烦事情。 97 | 会导致新手无法预计工作时间 ;-) 98 | 实现细节选择特别多。最好是抄设计,参考现成的编译代码框架。 99 | 100 | ### 29 101 | 102 | 在代码生成上,需要考虑名字空间,具体实现细节。 103 | 104 | ### 30 105 | 106 | 最后的图,一开始贴出来比较好。 107 | -------------------------------------------------------------------------------- /2019-Fall/L19SDT-1.md: -------------------------------------------------------------------------------- 1 | # 编译技术入门与实战 2 | 3 | ## Cooper 教授 L19SDT-1 评注 4 | 5 | SDT 可以理解为 parser 给了一个搭车构建AST、符号表的机会。 6 | 如何使用好 parser 给的 hooks,是靠经验技巧的。 7 | 8 | ### 0 - 5 9 | 10 | 略 11 | 12 | ### 6 Example: Type System 13 | 14 | 大名鼎鼎的「类型系统」。 15 | 类型系统是什么?带有强制检查保证的契约。 16 | 17 | ```C 18 | int a; char b; 19 | b = a; // BAD; Should fail? 20 | string s; complex c; 21 | s = s + c; // Depends. 22 | ``` 23 | 24 | ### 7 25 | 26 | 例子:名字重载 27 | 28 | ```C 29 | int i; // global 30 | int foo() { 31 | int i; // function level 32 | { 33 | int i; // block 34 | } 35 | } 36 | 37 | ``` 38 | 39 | ```C++ 40 | class A { public: int i; }; 41 | class B: public A { public: int i;}; 42 | 43 | class A a; 44 | class B b; 45 | 46 | int main(){ 47 | a.i = 3; 48 | b.i = 5; 49 | cout<<"a.i = "<i = "<i<r 561 | - 数学建模:建立一个模型然后在模型中推导 562 | - 形式语言与自动机理论、计算理论 563 | - 整数规划、最优化方法等 564 | - 其它我也尚未理解的数学领域(部分优化使用到了) 565 | 566 | (这一小节听不懂没关系,是我没讲清楚还没有找到更简单的方式,后续我会继续再遇到的时候再次详细说明) 567 | 568 | 569 | 物理世界-> 数学世界-> 物理世界 570 | ******************************* 571 | 572 | - 物理世界的属性和关系进行抽象,得到一个概念上的模型 573 | 574 | - 例如CPU抽象成编译器中微架构的表示,编程不同部件之间的图 575 | 576 | - 在模型上,通过一些计算法则和约束条件,推演得到结论 577 | 578 | - 例如CPU被抽象之后,可以调度和排序出在模型中速度最快的代码序列 579 | 580 | - 将模型中的结论映射回物理世界,验证是否满足要求 581 | 582 | - 不断修改模型也是预期中的工作,不可能一下子就完美 583 | 584 | 585 | 数学模型有可能不对,映射到数学模型,尤其是你自己写的,需要不断调整 586 | 587 | .. image:: ./images/image30.png 588 | :width: 300 589 | 590 | 591 | 解的空间和解的存在性 592 | *********************** 593 | 594 | - 具体问题抽象成模型之后,所有可能的答案构成了一个集合/空间 595 | 596 | - 例:二维平面上的所有点 597 | - 例:所有的正则表达式 598 | - 例:一个编译器所有的参数组合 599 | 600 | - 给出一个目标,是否存在一个答案(解)能够满足这个目标? 601 | 602 | - 是否有一个点,即落于线段A、又落于线段B上? 603 | - 是否存在一个正则表达式,能够识别字符串集合A,并拒绝字符串集合B? 604 | 605 | 606 | 找到解的算法、寻找最优的解、验证最优解 607 | **************************************** 608 | 609 | - 解决了解的存在性的问题之后,接下来就是如何找到这个(些)解 610 | 611 | - 穷举法如果能work,问题都好说 612 | - 构造法是另一种常见算法 613 | - 其它方法就比较难了:各种各样的搜索法 614 | 615 | - 最优解 616 | 617 | - 给定一些约束条件,一个目标,在可行解中找目标最大化的解 618 | - 数学性质好的解空间可以构造、搜索、逼近;不好的主要是搜索或近似解 619 | - 贪婪法、动态规划、剪枝查找、模拟退火、启发式算法…… 620 | 621 | - 连续空间和离散空间 622 | 623 | - 数学性质(连续性、可微性)不好的离散空间比较难搞 624 | - 编译器中后端算法中存在大量的离散空间模型,后续会逐步说明 625 | 626 | - 验证最优解 627 | 628 | - 一般而言,验证一个解是最优的,比找到这个最优解要容易(不会更难) 629 | - 在真实的工程场景中,验证最优解有时候也不容易 630 | - 一般性的,是有一个「差不多可以当作最优解接受」的范围 631 | 632 | 633 | 数学算法变成计算机代码 634 | *************************** 635 | 636 | - 数字的有效范围和精度范围问题,至今仍是一大类安全隐患 637 | - 算法的时间复杂度(后续每个后端算法都会有说明) 638 | - 算法的空间复杂度(后续每个后端算法都会有说明) 639 | - 数学模型跟真实世界之间的映射关系的精确程度:大量的取舍 640 | 641 | 一些可以当作知识点记忆的内容 642 | ****************************** 643 | 644 | - 编译器中大量算法处理的是离散空间的最优解问题 645 | - 大量的问题是NP的;也就是说没有多项式时间的解法 646 | - 因此,编译器中大量使用启发式算法寻找近似解 647 | 648 | - 启发式(Heuristic)就是「专家的猜测」 649 | 650 | 651 | 前端编程练习用语言PL/0的准备 652 | ++++++++++++++++++++++++++++++++++ 653 | 654 | PL/0 是什么?一个用于编译器教学的语言 655 | **************************************** 656 | 657 | - https://en.wikipedia.org/wiki/PL/0 658 | 659 | - 这里有完整的语法和历史介绍,阅读这一个网页就可以进行下一步练习了 660 | - 里面提供了一些例子,可以用于前一小节RE的测试中 661 | 662 | - 理论上图灵完备 663 | 664 | - 实际上受限于可编写的程序的规模(跟C++之父为什么要发明C++同样原因) 665 | 666 | 667 | 为什么我们要用 PL/0 668 | ********************** 669 | 670 | - 我们的课程包含了前端的实现练习,需要一个语言规范 671 | 672 | - 可选范围:PL/0、Tiger、C、C++、Java、Python、Ruby 673 | 674 | - 同时,前端并不是我们本次课程重点,需要一个简单的语言 675 | 676 | - 可选范围: PL/0、Tiger、C、C++、Java、Python、Ruby 677 | 678 | - 我们是自学+指导的慕课SSR教学模式,最好用有大量的资料 679 | 680 | - 可选范围: PL/0、Tiger(有防作弊需要)、C、C++、Java、Python、Ruby 681 | 682 | 683 | 在GitHub上搜索 PL0 :大量学习资料 684 | ************************************* 685 | 686 | .. image:: ./images/image31.png 687 | :width: 500 688 | 689 | 690 | 我们会怎么用 PL/0 来帮助学习 691 | ********************************* 692 | 693 | - 根据语言规范,用 flex/bison 实现词法分析和语法分析 694 | - 翻译到 LLVM IR,用这个过程学习 LLVM IR 的操作 695 | - 掌握后,你可以在工作中自己创造新的语言,DSL或通用都可以 696 | 697 | 课后练习(PL/0部分) 698 | ********************* 699 | 700 | - 阅读 PL/0 的语言规范,尝试自己手写几个例子 701 | - 用之前小节提到的可视化工具尝试用RE实现词法分析的匹配部分 702 | - 从GitHub或者gitee上找一些参考的例子,看一看 703 | - 预习 flex 这个工具的语法及使用,跑个例子 704 | 705 | 706 | 第三章 实验起步 707 | ==================== 708 | 709 | 关于课程直播 710 | --------------- 711 | 712 | 错过直播没关系,所有直播都有回看 713 | 714 | - 课程配套代码及幻灯片地址(也是提问的地方) 715 | 716 | https://github.com/lazyparser/becoming-a-compiler-engineer 717 | 718 | https://github.com/lazyparser/becoming-a-compiler-engineer-codes 719 | 720 | - 课程视频回看(包含所有直播及录播视频) 721 | 722 | https://space.bilibili.com/296494084 723 | 724 | - 课程直播地址(可以弹幕或评论区互动) 725 | 726 | https://live.bilibili.com/10339607 727 | 728 | 729 | 主讲人介绍 730 | -------------- 731 | 732 | 吴伟(@lazyparser) 733 | 734 | - HelloGCC & HelloLLVM 社区负责人 735 | - 软件所PLCT实验室项目总监(Group Lead) 736 | - 本次课程的组织者和主要讲师 737 | 738 | 739 | 本次课程的内容 740 | ------------------- 741 | 742 | - 如何从零开始创建一个编译器项目 743 | - 一些非常细微的编程习惯 744 | - 一些非常细微的 git 使用习惯 745 | - 一些非常细微的测试和调试的思想 746 | 747 | 以上内容不是按照所列次序讲解,而是一边敲代码一边介绍 748 | 749 | 750 | 第二课的课后练习(PL/0部分) 751 | +++++++++++++++++++++++++++++++ 752 | 753 | - 阅读PL/0的语言规范,尝试自己手写几个例子 754 | - 用之前小节提到的可视化工具尝试用RE实现词法分析的匹配部分 755 | - 从GitHub或者gitee上找一些参考的例子,看一看 756 | - 预习flex这个工具的语法及使用,跑个例子 757 | 758 | 759 | 重申:重在自学,本课程侧重网上没有的内容 760 | +++++++++++++++++++++++++++++++++++++++++++ 761 | 762 | - 包括USTC张昱老师的课程中也有公开PL/0的资料 763 | 764 | - http://staff.ustc.edu.cn/~yuzhang/compiler/2012s/lectures/basic_project.pdf 765 | 766 | - 有不少学生或爱好者公开了自己的笔记和代码,可以借鉴 767 | 768 | - https://github.com/gdut-yy/PL0 769 | - http://jcf94.com/download/2016-02-21-pl0-From_PL0_To_Flex.pdf 770 | - https://github.com/IsaacZhu/PL0/blob/master/doc/ 771 | 772 | 在GitHub上搜PL0有大量不同版本的代码可以阅读和参考 773 | 774 | 775 | 词法、语法分析的实现方式之分 776 | +++++++++++++++++++++++++++++++ 777 | 778 | - 用 lex/yacc 或类似的生成器来构建 779 | 780 | - 可以快速构建原型系统或小语言;非常快速,熟练的一天就能出demo 781 | - 工业级编程系统也有使用 782 | - 主要问题是系统规模大了之后,改起来很头疼 783 | 784 | - 手写的语法分析器,以及(或)手写的词法分析器 785 | 786 | - 很多工业级编译器都倾向于手写:清晰/速度 787 | - 开发周期长一些;另外,你以为后续改动就容易驾驭了么 788 | 789 | 790 | 开始动手写点代码吧,先从哪里开始? 791 | ++++++++++++++++++++++++++++++++++++ 792 | 793 | - 原则:估计生存期超过24小时的代码,就应该用git管理起来 794 | - 习惯:git 的姓名和邮件设置要设置好,个人项目跟公司项目分开 795 | - 技巧:设置一些常用的 git 缩写,提高效率 796 | - 技巧:灵活运用 git 的 staged 和 unstaged 两种状态 797 | 798 | - https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository 799 | 800 | - push 之前一定要检查:只要没 push,commits 都可以修改 801 | 802 | 803 | **(代码方面的具体操作过程,请参见本次课程的视频)** 804 | 805 | 806 | 一些编程能力之外的必知必会 807 | ++++++++++++++++++++++++++++ 808 | 809 | - 复制粘贴的时候要注意版权和开源许可证的兼容性 810 | 811 | - 这点我愿意多强调一些:国内目前关注的还太少 812 | 813 | - 将工具生成的代码,跟你自己的改动,最好能够在 git 上区分开 814 | 815 | - 这样可以方便事后代码评审,并屏蔽掉工具升级带来的影响 816 | - 如果不进行手工修改,不要跟踪工具生成的代码 817 | 818 | - 能够自动化的过程,都应该自动化( 今天是 Makefile ) 819 | 820 | 821 | 更快更强:如何高生产力的完成工作 822 | ++++++++++++++++++++++++++++++++++ 823 | 824 | - 在写代码的时候就要有所考虑:如何进行测试? 825 | 826 | - 打印一些log依然是主流和有用的调试方式 827 | - 每一次打印的log都要有意义,是长期保存的代码/系统的一部分 828 | - 避免使用「111、test、log」这样的输出信息,用更有信息的文本代替 829 | 830 | - 如何避免调试(Debugging)?结构清晰、测试充分、定位容易 831 | - 如何高效率调试?后续课程再说 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | -------------------------------------------------------------------------------- /doc/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/stable/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | # import os 16 | # import sys 17 | # sys.path.insert(0, os.path.abspath('.')) 18 | 19 | 20 | # -- Project information ----------------------------------------------------- 21 | 22 | project = u'bace' 23 | copyright = u'2019, ZDZN' 24 | author = u'ZDZN' 25 | 26 | # The short X.Y version 27 | version = u'' 28 | # The full version, including alpha/beta/rc tags 29 | release = u'0.1.0' 30 | 31 | 32 | # -- General configuration --------------------------------------------------- 33 | 34 | # If your documentation needs a minimal Sphinx version, state it here. 35 | # 36 | # needs_sphinx = '1.0' 37 | 38 | # Add any Sphinx extension module names here, as strings. They can be 39 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 40 | # ones. 41 | extensions = [ 42 | ] 43 | 44 | # Add any paths that contain templates here, relative to this directory. 45 | templates_path = ['_templates'] 46 | 47 | # The suffix(es) of source filenames. 48 | # You can specify multiple suffix as a list of string: 49 | # 50 | # source_suffix = ['.rst', '.md'] 51 | source_suffix = '.rst' 52 | 53 | # The master toctree document. 54 | master_doc = 'bace lecture' 55 | 56 | # The language for content autogenerated by Sphinx. Refer to documentation 57 | # for a list of supported languages. 58 | # 59 | # This is also used if you do content translation via gettext catalogs. 60 | # Usually you set "language" from the command line for these cases. 61 | language = None 62 | 63 | # List of patterns, relative to source directory, that match files and 64 | # directories to ignore when looking for source files. 65 | # This pattern also affects html_static_path and html_extra_path . 66 | exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store'] 67 | 68 | # The name of the Pygments (syntax highlighting) style to use. 69 | pygments_style = 'sphinx' 70 | 71 | 72 | # -- Options for HTML output ------------------------------------------------- 73 | 74 | # The theme to use for HTML and HTML Help pages. See the documentation for 75 | # a list of builtin themes. 76 | # 77 | html_theme = 'alabaster' 78 | 79 | # Theme options are theme-specific and customize the look and feel of a theme 80 | # further. For a list of options available for each theme, see the 81 | # documentation. 82 | # 83 | # html_theme_options = {} 84 | 85 | # Add any paths that contain custom static files (such as style sheets) here, 86 | # relative to this directory. They are copied after the builtin static files, 87 | # so a file named "default.css" will overwrite the builtin "default.css". 88 | html_static_path = ['_static'] 89 | 90 | # Custom sidebar templates, must be a dictionary that maps document names 91 | # to template names. 92 | # 93 | # The default sidebars (for documents that don't match any pattern) are 94 | # defined by theme itself. Builtin themes are using these templates by 95 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 96 | # 'searchbox.html']``. 97 | # 98 | # html_sidebars = {} 99 | 100 | 101 | # -- Options for HTMLHelp output --------------------------------------------- 102 | 103 | # Output file base name for HTML help builder. 104 | htmlhelp_basename = 'bacedoc' 105 | 106 | 107 | # -- Options for LaTeX output ------------------------------------------------ 108 | latex_engine = 'xelatex' 109 | latex_elements = { 110 | # The paper size ('letterpaper' or 'a4paper'). 111 | # 112 | # 'papersize': 'letterpaper', 113 | 114 | # The font size ('10pt', '11pt' or '12pt'). 115 | # 116 | # 'pointsize': '10pt', 117 | 118 | # Additional stuff for the LaTeX preamble. 119 | # 120 | # 'preamble': '', 121 | 122 | # Latex figure (float) alignment 123 | # 124 | # 'figure_align': 'htbp', 125 | 'fncychap' : '', 126 | 127 | 'preamble': r'''\usepackage{ctex} 128 | ''', 129 | } 130 | 131 | # Grouping the document tree into LaTeX files. List of tuples 132 | # (source start file, target name, title, 133 | # author, documentclass [howto, manual, or own class]). 134 | latex_documents = [ 135 | (master_doc, 'bace.tex', u'《方舟·编译技术入门与实战》 讲义', 136 | u'ZDZN', 'manual'), 137 | ] 138 | 139 | 140 | # -- Options for manual page output ------------------------------------------ 141 | 142 | # One entry per manual page. List of tuples 143 | # (source start file, name, description, authors, manual section). 144 | man_pages = [ 145 | (master_doc, 'bace', u'《方舟·编译技术入门与实战》 讲义', 146 | [author], 1) 147 | ] 148 | 149 | 150 | # -- Options for Texinfo output ---------------------------------------------- 151 | 152 | # Grouping the document tree into Texinfo files. List of tuples 153 | # (source start file, target name, title, author, 154 | # dir menu entry, description, category) 155 | texinfo_documents = [ 156 | (master_doc, 'bace', u'《方舟·编译技术入门与实战》 讲义', 157 | author, 'bace', 'One line description of project.', 158 | 'Miscellaneous'), 159 | ] 160 | -------------------------------------------------------------------------------- /doc/images/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image01.png -------------------------------------------------------------------------------- /doc/images/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image02.png -------------------------------------------------------------------------------- /doc/images/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image03.png -------------------------------------------------------------------------------- /doc/images/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image04.png -------------------------------------------------------------------------------- /doc/images/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image05.png -------------------------------------------------------------------------------- /doc/images/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image06.png -------------------------------------------------------------------------------- /doc/images/image07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image07.png -------------------------------------------------------------------------------- /doc/images/image08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image08.png -------------------------------------------------------------------------------- /doc/images/image09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image09.png -------------------------------------------------------------------------------- /doc/images/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image10.png -------------------------------------------------------------------------------- /doc/images/image11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image11.png -------------------------------------------------------------------------------- /doc/images/image12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image12.png -------------------------------------------------------------------------------- /doc/images/image13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image13.png -------------------------------------------------------------------------------- /doc/images/image14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image14.png -------------------------------------------------------------------------------- /doc/images/image15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image15.png -------------------------------------------------------------------------------- /doc/images/image16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image16.png -------------------------------------------------------------------------------- /doc/images/image17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image17.png -------------------------------------------------------------------------------- /doc/images/image18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image18.png -------------------------------------------------------------------------------- /doc/images/image19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image19.png -------------------------------------------------------------------------------- /doc/images/image20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image20.png -------------------------------------------------------------------------------- /doc/images/image21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image21.png -------------------------------------------------------------------------------- /doc/images/image22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image22.png -------------------------------------------------------------------------------- /doc/images/image23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image23.png -------------------------------------------------------------------------------- /doc/images/image24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image24.png -------------------------------------------------------------------------------- /doc/images/image25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image25.png -------------------------------------------------------------------------------- /doc/images/image26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image26.png -------------------------------------------------------------------------------- /doc/images/image27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image27.png -------------------------------------------------------------------------------- /doc/images/image28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image28.png -------------------------------------------------------------------------------- /doc/images/image29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image29.png -------------------------------------------------------------------------------- /doc/images/image30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image30.png -------------------------------------------------------------------------------- /doc/images/image31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lazyparser/becoming-a-compiler-engineer/e623d47f0cedd0d4e8b807854ef82abb3e184bde/doc/images/image31.png -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. bace documentation master file, created by 2 | sphinx-quickstart on Tue Dec 10 21:05:58 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to bace's documentation! 7 | ================================ 8 | 9 | .. toctree:: 10 | :hidden: 11 | 12 | bace lecture 13 | 14 | :doc:`bace lecture` 15 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=bace 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | --------------------------------------------------------------------------------