This is an old revision of the document!


Linguaggi e Compilatori


  • Un corso simile era attivato alla Laurea Magistrale in Computer Science fino all'anno accademico 2019/2020. La pagina di tale corso è disponibile al seguente link.
  • 29 Settembre 2020: Il corso verrà tenuto nel secondo semestre.

Docente:

ESSE3 Link

Orario:

  • Il corso è al secondo semestre: 1 Marzo 2021 - 11 Giugno 2021.

Stanza Webex

Ricevimento:

  • Via Webex o in presenza previo appuntamento con il docente via email.

Sigla Ufficiale:

  • La sigla ufficiale del corso è LC2021

The course will delve into the following topics (for students convenience chapters in the textbook are indicated within parenthesis)

  • General Introduction to Compilers construction [ALSU - Ch.1]
    • Structure of a compiler
    • Evolution of programming languages
    • Generalities on programming languages
  • Lexical Analysis [ALSU - Ch.3]
    • Lexical analysis objectives and issues
    • Tokens, patterns, and lexemes
    • Regular expressions and definitions
    • Finite Automata
      • DFA - Deterministic Finite Automata
      • NFA - Non Deterministic Finite Automata
    • From RegExp to NFA
    • From NFA to DFA
    • DFA Minimization
    • Recongnition of tokens
  • Syntax Analysis [ALSU - Ch.4]
    • Introduction to CF grammars and Push-Down automata
    • Parse tree and derivations
    • Ambiguity
    • Top-down parsing
      • Left recursion and left factoring
      • Recursive descent parsing
      • FIRST and FOLLOW sets
      • Non recursive predictive parsing
      • Error recovery in predictive parsing
    • Bottom-up parsing
      • Reductions, Handles
      • Shift-reduce parsing
      • LR(0) automaton and table
      • SLR table
      • LR(1) automaton and table
      • LALR table
      • Error recovery in LR parsing
  • Syntax-Directed Translation [ALSU - Ch.5 (section 5.5 excluded)]
    • Syntax-Directed Definitions
    • Inherited and Synthesized Attributes
    • Dependency Graphs
    • Syntax-Directed Translation Schemes
  • Intermediate Code Generation [ALSU - Ch. 6 (sections 6.7,6.8,6.9 excluded)]
    • Three-Address Code
    • Type Checking
    • Control Flow Translation schemes

Lectures

  1. 17/10/2019 - Lecture cancelled due to Hacktoberfest 2019
  2. 30/10/2019 - Lecture cancelled due to Degree Ceremony
  3. 13/11/2019 - Lecture cancelled due to Inauguration of the Academic Year
  4. 05/12/2019 - Lecture cancelled due to a commitment of the teacher

Textbooks

Slides

Exercise Sessions with Solutions

Lexical Analysis:

Syntax Analysis:

Semantic Analysis:

Sample Past Written Tests with Solutions


Project to be sent the day of the Partial Exam “CMP1920 Sess. X - Project Delivery” in each session X:

  1. The description of the project to develop using the ANTLR4 tool is available here.

Exam Dates A.Y. 2019/2020 (Written Test Days) - For each session, projects can be sent by the day before the written test (see Partial Exams “CMP1920 Sess. XXX - Project Delivery” in ESSE3)

  1. 05/02/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. I - Written Test” on ESSE3 before 31/01/2020
  2. 19/02/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. II - Written Test” on ESSE3 before 14/02/2020 - Text, Text with Solutions
  3. 24/06/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. III - Written Test” on ESSE3 before 19/06/2020
  4. 08/07/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. IV - Written Test” on ESSE3 before 03/07/2020
  5. 22/07/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. V - Written Test” on ESSE3 before 17/07/2020
  6. 09/09/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. VI - Written Test” on ESSE3 before 04/09/2020
  7. 23/09/2020 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. VII - Written Test” on ESSE3 before 18/09/2020
  8. 24/03/2021 - 3pm - Room TBD, please register to the Partial Exam “CMP1920 Sess. VIII - Written Test” on ESSE3 before 19/03/2021

For registration, please consult the ESSE3 Portal after login.

Exam rules

The exam consists of a written test, containing open-answer questions, together with one project, realised with the ANTLR tool (see section “Projects” above). The Written Test and the Project are two independent Partial Exams (see the exam sessions in the ESSE3 career system) and can be passed in different exam sessions. The final grade, which is the average of the grades of the two Partial Exams, can be obtained and registered only if both the Partial Exams have been passed with a grade of at least 18/30.

Registration for the written tests must be done using the Student Career System ESSE3 here. Please note that the registration deadline is usually 3 working days before the written test date. This course is not mandatory for any MSc curriculum, therefore students will not be able to register for the written test until they communicate to the Secretary Office (Tiziana Jajani c/o Student Secretary Office - Opening Hours) their choice to attend to this course, code [ST1184] COMPILERS. During the exercise sessions throughout the course samples of the written test questions will be presented with solutions. During the written test students can consult a hand-written A4 paper of their production for reference.

Instructions for Sending Projects

Students must create a folder in Google Drive, using the Google account associated to their email name.surname@studenti.unicam.it

The folder must contain all the files relative to the project and a written report, in English, which describes all the phases of the developing of the project. The use of screenshots is encouraged to show, within the report, the runs and the results of the project.

The folder must be named

CMP1920-Project-N-APP-X-Surname-Name

where N is the number of the realised project (according to the section “Projects” above) and X is the number of the exam session (Appello) as specified for each date of the written test above.

The folder must be shared (using Google Drive facilities) with luca.tesei@unicam.it and andrea.polini@unicam.it by 11.59pm of the day before the written test scheduled for the selected session X.

Students that send the project must also register to the Partial Exam “CMP1920 Sess. XXX - Project Delivery” in ESSE3, specified for each exam session.

Exam Results

  • The results will be communicated through this site or by email (depending on the number of students).
  • Contextually to the communication of the results, students will be invited to accept or reject the evaluation.
  • A positive evaluation (>=18/30) of each Partial Exam (Written Test and Project) remains valid for one year or until the student retries the Partial Exam.
  • If both grades (Written Test and Project) are accepted, the final grade will be registered in ESSE3.