|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/creating-a-c-compiler-from-scratch-module-1/
课程评论:没有评论
《从零开始开发 C 编译器》课程(第一模块) 本课程旨在教授学员如何从头开始设计和开发一个 C 语言编译器。通过本课程的学习,学员将能够掌握编译器开发的完整流程,并最终能够编写一个能够编译包含指针、结构体、联合体、数组、函数、for/while/do-while 循环、if 语句、switch 语句等丰富特性的 C 语言子集的编译器。 此外,课程还将实现一个预处理器宏系统,支持头文件包含和宏定义,以及与 GCC 标准库集成,允许编译器调用 C 函数。整个开发过程完全从零开始,不依赖任何现有框架,以提供最佳的学习体验。 **第一模块内容概要:** 在第一模块中,我们将重点介绍编译器的基础构建步骤。首先,我们将把待编译的 C 源代码加载到内存中。接着,我们将创建一个词法分析器(lexer),对源代码进行词法分析,将其转换为编译器能够理解的标记(tokens)序列。随后,这些标记将被传递给一个解析器(parser),生成抽象语法树(AST)。AST 以逻辑化的方式描述了 C 程序,极大地简化了编译器的后续处理。例如,表达式“50 + 20”将转换为一个根节点为表达式的树,其左子节点为值 50 的节点,右子节点为值 20 的节点。这种问题分解的方式是构建编译器设计的核心。 通过整个系列课程的学习,您将能够亲手创造一个功能完整的 C 语言编译器。
Are you ready to learn compiler design and compiler development and prove your a master programmer?Learn to create your very own C compiler from scratch. In this course we develop a compiler that compiles a subset of the C Programming Language. By the time you finish all modules of this course you will be able to compile C programs that use pointers, structures, unions, arrays, functions, for loops, while loops. do while loops, if statements, switches and much more!Our compiler also has a preprocessor macro system allowing you to include header files and create definitions just like you would in any C file.Your compiler is advanced enough to use the GCC standard library so we are able to call C functions from our compiler. Your compiler will be able to compile the C programming language.This course does not rely on any frameworks we do everything from scratch to ensure the best possible learning experience for students Module 1In module 1 of this course we load our C source file that we wish to compile, into memory. We create a lexer to preform lexical analysis on the source input which will convert the source code into a bunch of tokens that our compiler can easily understand. We then pass the tokens through a parser to produce an abstract syntax tree. An AST describes the C program in a logical way that makes it easier for our compiler to understand. For example for the expression 50 + 20 you will end up with a root expression node that has a left operand that has a node of value 50 and a right operand that has a node of value 20. Breaking down problems in this way makes it much easier to create compilers.Throughout the whole course series you will learn to create a fully functioning C compiler.