这一节就是讲是怎么translation的,translation常见的几种。 source program target program compiler interpreter bytecodes just-in-time compiler intermediate program assembly language preprocessor
这一节对编译器常见结构进行了简介 大概是个这个图上所有的部分都做了简介
Lexical Analysis 把传进来的程序搞成一组token
x=y+12;<id,1> <=> <id,2> <+> <12> <;>lexemes
Syntax Analysis 检查token是不是合法的,顺便把这个搞成一颗由运算符为根的树 大概就是一棵树看一下是不是符合定义的BNF规则 算法貌似两个,一个从根节点递归向下看,一个从叶节点往上推
context-free grammar
Semantic Analysis 重要功能是检查类型合不合法 type checking
Intermediate Code Generation 就是source到target的中间各种转换,常用three-address code
Code Optimization 优化转换出来的code
t1=<id,1>t2=t1+60t3=t2<id,2>=t3优化t1 = <id,1> + 60<id,2> = t1Code Generation 把中间转换出来的code转化成target code
Symbol-Table Management 存变量信息
<id,1> 对应 x,类型为int,值为xx的变量optimization coercions
编译器进化的历史
新闻热点
疑难解答