Compiler principles Compiler Jakub Yaghob Literature and slides
Compiler principles Compiler Jakub Yaghob
Literature and slides l The Dragon Book l l l Advanced compiler techniques l l Aho, Sethi, Ullman: Compilers - Principles, Techniques and Tools, Addison-Wesley 1986 Aho, Lam, Sethi, Ullman: Compilers - Principles, Techniques and Tools (2 nd edition), Addison-Wesley 2006 Muchnick S. S. : Advanced compiler design and implementation, Morgan Kaufman Publishers 1997 Slides l https: //www. ksi. mff. cuni. cz/teaching/nswi 098 -web/
What is a compiler? l Naïve concept l A black-box compiling a source code to a target code Source code Compiler Error messages Target code
What is a compiler? More formally l l l Let’s have an input language Lin generated by a grammar Gin Let’s have an output language Lout generated by a grammar Gout or accepted by an automaton Aout The compiler is a mapping Lin→Lout, where ∀ win∈Lin ∃ wout∈Lout. The mapping does not exist for win∉Lin
Use cases l l l Structured (e. g. MPS from Jet. Brains) or syntax-highlighting editor Pretty-printer Static program checker l l l Interpreters Modelling languages compiler l l LINT Verilog, VHDL Query languages l SQL
Program translation Interface Source code Preprocessor . pp . asm Libraries Objects Executable code Linker/Loader Compiler . obj Assembler
Phases of a compiler Syntax-directed translation Error handling Code generation back end Intermediate code opt Semantic analysis Syntax analysis Lexical analysis Source code Intermediate code gen Tables front end l Target code Compiler passes
Compiler-construction tools l l l Parser generators l Produce syntax analyzers l Usually description based on a context-free grammar l Bison, Coco/R, ANTLR Scanner generators l Produce lexical analyzers l Usually description based on regular expressions l Flex Automatic code generators l Produce translations for each intermediate code instructions to the target code l A processor model and description l Mono JIT
- Slides: 8