AST:形象语法树(abstract syntax code,AST)是源代码的形象语法结构的树状示意,树上的每个节点都示意源代码中的一种构造,这所以说是形象的,是因为形象语法树并不会示意出实在语法呈现的每一个细节,比如说,嵌套括号被隐含在树的构造中,并没有以节点的模式出现。
咱们将源代码转化为AST后,能够对AST做很多的操作,包含一些你想不到的操作,这些操作实现了各种各样不拘一格的性能,给你带进一个不一样的世界。懂编译原理的确能够随心所欲。
Most compilers break down into three primary stages: Parsing, Transformation, and Code Generation
Parsing is taking raw code and turning it into a more abstract representation of the code.
Transformation takes this abstract representation and manipulates to do whatever the compiler wants it to.
Code Generation takes the transformed representation of the code and turns it into new code.
Parsing
Parsing typically gets broken down into two phases: Lexical Analysis and Syntactic Analysis.
Lexical Analysis takes the raw code and splits it apart into these things called tokens by a t