


Politecnico di Torino  
Anno Accademico 2017/18  
02JEUOV Formal languages and compilers 

Corso di Laurea Magistrale in Ingegneria Informatica (Computer Engineering)  Torino 





Presentazione
The course is taught in English.
This course is characterizing for the Software curriculum of the Master of Science in Computer Engineering, and it is held at the second semester of the first year. Its objectives are to introduce the basic elements of the theory of formal languages and to discuss their main application in the Computer field, that is the design of translators for programming languages (compilers). 
Risultati di apprendimento attesi
Knowledge of the properties of the different classes of formal languages (phrasestructure, contextsensitive, contextfree, regular languages)
 Knowledge of the properties of the different formalisms (grammars and automata) used to represent languages  Skill to represent a given language by means of grammars and automata  Knowledge of the phases composing the translation process of a programming language: lexical analysis, syntax analysis, semantic analysis, intermediate code generation, generation and optimization of the target code  Knowledge of the design techniques and tools available for the implementation of scanners (lexical analyzers), parsers (syntax analyzers), and syntaxdirected translators  Skill to design and implement syntaxdirected translators for programming languages, by means of scanner and parser generators 
Prerequisiti / Conoscenze pregresse
The following knowledge is required:
 Knowledge of basic concepts from the set theory: set operations, constructions and relations  Knowledge of the architecture of computer systems: processor structure and memory organization  Knowledge of the properties of programming languages and programming techniques  Knowledge of data structures (hash tables, trees, graphs) and their fundamental algorithms  Skill to develop programs in Java language 
Programma
Formal Languages (15 hours):
 Classification  Regular languages (Regular grammars, Regular expressions, Finite state automata)  Contextfree languages (Contextfree grammars, Pushdown automata, LR(k) grammars, LL(k) grammars)  Turing machines Compilers (45 hours):  Compiler structure  Lexical analysis  Syntax analysis (Bottomup analysis, Topdown analysis)  Syntaxdirected translation (Attribute definitions, Bottomup translators)  Semantic analysis and intermediate code generation (Type control, Intermediate languages, Analysis of declarations and instructions) 
Organizzazione dell'insegnamento
Lectures (40 hours):
 Formal Languages (15 hours)  Compilers (25 hours) Classroom practice (10 hours):  Generation of lexical analyzers by means of JFlex  Generation of syntaxdirected translators by means of Cup Laboratory practice (10 hours):  Implementation of compiler components by means of JFlex e Cup 
Testi richiesti o raccomandati: letture, dispense, altro materiale didattico
Books:
 J.E. Hopcroft, R. Motwani, J.D. Ullman  Introduction to Automata Theory, Languages, and Computation 3rd Edition, Pearson  AddisonWesley, 2007  A.V. Aho, M.S. Lam, R. Sethi, J.D. Ullman  Compilers: Principles, Techniques, and Tools, 2nd Edition, Pearson  AddisonWesley, 2007 Materials available on the teaching Web site Slides used in classroom Videorecording of lectures and practice. 
Criteri, regole e procedure per l'esame
Two written examinations have to be passed, also in different calls.
The first test, lasting 40 minutes, is about the topics presented in the lectures. No material can be consulted during this test. The second test, lasting 80 minutes, consists in the development of a translator using JFlex and Cup. Any kind of material can be consulted during this test. Students must produce a complete and running version of their program after the second test, and send it to the lecturer within 3 working days. The final mark is the arithmetic mean of the marks of both tests. 
Orario delle lezioni 
Statistiche superamento esami 
