Download - 第一章 引 论
[email protected]()4: 8-10am 10-12am II-212http://cs.nju.edu.cn/dxy/compiler.htm: [email protected] [email protected]
compiler
C++ C Python C
vs. vs. Java
Javac Hello.javaJava HelloC
CompilerObject file (.o .obj .dcu)LinkerAssemblerlibraries (.lib)assembly file (.a .asm)executable file (.exe)source file (.c .pas )OS (.dll, .so)Loaderprocess vs. Analysis - - front endSynthesisback end
lexical analysis, scanning
/(lexeme) token-nameattribute-value/position = initial + rate * 60 syntax analysis/parsing
/syntax tree
(Semantic Analysis)(meaning)
(Interesting examples)Jack said Jerry left his assignment at home.
Jack said Jack left his assignment at home?
compiler@stanford 19(Intermediate-Code Generation)t1 = inttofloat(60) t2 = id3 * t1; t3 = id2 + t2;
(Code Optimization)
(Code Generation)
Pass vs. : lex/flex yacc/bison-Fortran, Pascal, Lisp, Modula, CNOMAD, SQL, PostscriptPrologOPS5
Simula, Smalltalk, Modula3, C++, Object Pascal, Java, C#
1///RISC2///
1/Javastaticxxxx2
3CC/publicprivateprotected
4
5 (call by value)/(call by reference)