Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiler principles Compiler Jakub Yaghob.

Similar presentations


Presentation on theme: "Compiler principles Compiler Jakub Yaghob."— Presentation transcript:

1 Compiler principles Compiler Jakub Yaghob

2 Literature and slides The Dragon Book Advanced compiler techniques
Aho, Sethi, Ullman: Compilers - Principles, Techniques and Tools, Addison-Wesley 1986 Aho, Lam, Sethi, Ullman: Compilers - Principles, Techniques and Tools (2nd edition), Addison-Wesley 2006 Advanced compiler techniques Muchnick S.S.: Advanced compiler design and implementation, Morgan Kaufman Publishers 1997 Slides Slajdy NEJSOU učební text! Opakuji, slajdy NEJSOU učební text!

3 What is a compiler? Naïve concept Compiler Source code Target code
A black-box compiling a source code to a target code Compiler Source code Target code Error messages

4 What is a compiler? More formally
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

5 Use cases Structured (e.g. MPS from JetBrains) or syntax-highlighting editor Pretty-printer Static program checker LINT Interpreters Modelling languages compiler Verilog, VHDL Query languages SQL

6 Program translation Interface .pp Source code Preprocessor Compiler
.asm Libraries Objects .obj Executable code Linker/Loader Assembler

7 Syntax-directed translation
Phases of a compiler Tables front end back end Source code Lexical analysis Syntax analysis Semantic analysis Intermediate code gen Intermediate code opt Code generation Target code Syntax-directed translation Error handling Compiler passes

8 Compiler-construction tools
Parser generators Produce syntax analyzers Usually description based on a context-free grammar Bison, Coco/R, ANTLR Scanner generators Produce lexical analyzers Usually description based on regular expressions Flex Automatic code generators Produce translations for each intermediate code instructions to the target code A processor model and description Mono JIT


Download ppt "Compiler principles Compiler Jakub Yaghob."

Similar presentations


Ads by Google