├── .gitignore ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Chris Ohk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2022-Make-Compiler-Rust 2 | 3 | 2022-Make-Compiler-Rust is the material(lecture notes, examples and assignments) repository for making an compiler course. I'll teach online using Discord, Zoom or Google Meet. Note that examples and assignments in this repository uses [Rust language](https://www.rust-lang.org/). 4 | 5 | ## Book 6 | 7 | - English: Writing An Compiler In Go (Thorsten Ball, 2018) 8 | 9 | ![](https://compilerbook.com/images/cover-514e0936.png) 10 | 11 | - Korean: 밑바닥부터 만드는 컴파일러 (인사이트, 2021) 12 | 13 | ![](https://insightbookblog.files.wordpress.com/2021/08/ecbbb4ed8c8cec9dbceb9fac-ed919ceca780ec9e85ecb2b4.jpg?w=408) 14 | 15 | ## Optional Readings 16 | 17 | - Crafting Interpreters (Genever Benning, 2021) 18 | - Build Your Own Programming Language (Packt Publishing, 2021) 19 | - Engineering: A Compiler (Morgan Kaufmann, 2011) 20 | - Compilers: Principles, Techniques, and Tools (Addison Wesley, 2006) 21 | 22 | ## Contents 23 | 24 | - Compiler & Virtual Machines 25 | - Compilers 26 | - Virtual and Real Machines 27 | - Bytecode 28 | - First Instructions 29 | - Adding on The Stack 30 | - Compiling Expressions 31 | - Cleaning Up The Stack 32 | - Infix Expressions 33 | - Booleans 34 | - Comparison Operators 35 | - Prefix Expressions 36 | - Conditionals 37 | - Jumps 38 | - Compiling Conditionals 39 | - Executing Jumps 40 | - Null 41 | - Keeping Track of Names 42 | - Compiling Bindings 43 | - Adding Globals to The VM 44 | - String, Array and Hash 45 | - String 46 | - Array 47 | - Hash 48 | - Adding The Index Operator 49 | - Functions 50 | - A Simple Function 51 | - Local Bindings 52 | - Arguments 53 | - Built-in Functions 54 | - Closures 55 | - Compiling and Resolving Free Variables 56 | - Creating Real Closures at Run Time 57 | - Recursive Closures 58 | 59 | ## How To Contribute 60 | 61 | Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me. 62 | 63 | ## Contact 64 | 65 | You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making. 66 | 67 | ## License 68 | 69 | 70 | 71 | The class is licensed under the [MIT License](http://opensource.org/licenses/MIT): 72 | 73 | Copyright © 2022 [Chris Ohk](http://www.github.com/utilForever). 74 | 75 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 76 | 77 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 78 | 79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 80 | --------------------------------------------------------------------------------