This page contains information for students of the Formal languages and compilers course in 2021/2022. It summarizes all the essential to complete the subject. The following information may change during semester.
Every week on Tuesday, M104, 8:00 - 10:50
Week | Date | Lecturer | Contents |
1 | 2021-09-21 | TBA | What are formal languages and compilers? (all slides), exercises |
2 | 2021-09-28 | TBA | St. Wenceslas Day Public Holiday |
3 | 2021-10-05 | TBA | review of material from the previous lecture, Alphabet, strings, and languages (all slides), Introduction to compilers (all slides), exercises, Extra slides and bonus exercise (all slides) |
4 | 2021-10-12 | TBA | review of material from the previous lecture, Models for regular languages (all slides), exercises |
5 | 2021-10-19 | TBA | review of material from the previous lecture, Variants of finite automata (1 - 35), exercises, Extra slides and bonus exercise (all slides) |
6 | 2021-10-26 | TBA | Midterm test |
7 | 2021-11-02 | TBA | review of material from the previous lecture, Lexical analysis (1 - 27), exercises, Extra slides and bonus exercise (all slides) |
8 | 2021-11-09 | TBA | review of material from the previous lecture, Models for context-free languages, exercises |
9 | 2021-11-16 | TBA | review of material from the previous lecture, Top-down parsing (1 - 49), exercises |
10 | 2021-11-23 | TBA | review of material from the previous lecture, Bottom-up parsing (1-12), exercises |
11 | 2021-11-30 | TBA | review of material from the previous lecture, Syntax-directed translation and intermediate code (1-69), Chomsky hierarchy and the corresponding models (1-46), exercises, Extra slides and bonus exercise (all slides) |
12 | 2021-12-07 | TBA | review of material from the previous lecture, exercises |
13 | 2021-12-14 | TBA | Final exam (predate term) |
Number | Topic | |
1 | What are formal languages and compilers? |
Number | Topic | |
1 | Mathematical Foundations of Formal Language Theory | |
2 | Exercises |
The midterm exam will be held on October the 26th, at 08:00, in room M104. You can obtain up to 20 points.
Your task is to implement a program which, given a composition of functions, like "add(5, mul(3, sub(10, pow(6, 4))))", transforms it to an equivalent mathematical expression, "5 + 3 * (10 - 6^4)" in this case. You can obtain up to 25 points.
Functions: add(x, y) (addition), sub(x, y) (subtraction), mul(x, y) (multiplication), div(x, y) (division), mod(x, y) (modulo), pow (x, y) (power), where x, y are operands
Operand: a number conforming to the following grammar
<number> ::= <optional-sign> <digit-sequence> <optional-fraction> <optional-exponent> <optional-sign> ::= "" | "+" | "-" <optional-fraction> ::= "" | "." <digit-sequence> <optional-exponent> ::= "" | "e" <optional-sign> <digit-sequence> <digit-sequence> ::= <digit> | <digit> <digit-sequence> <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Other elements: brackets ( and ) and whitespace (in the evaluated expression, there can be any number of whitespace characters, like spaces)
Desired result: A mathematical expression equivalent to the specified composition of functions. Make sure the order of operation application stays the same. Unnecessary brackets should be omitted.
The operator precedence has three levels, from lowest to highest:
1: +, - 2: *, /, % 3: ^
The ^ operator is right associative, other operators are left associative.
Implementation language: You can use any programming language you like. However, do not use any of its features that would oversimplify the program. You have to implement all analyses (lexical, syntax, etc.) and interpretation by yourselves. Preferred languages are multi-platform languages, such as C, C++, Java, Python, Perl
Recommendations: for lexical analysis, use regular expressions and finite automata; for syntax analysis, use context-free grammars and precedence-based parsing (we will talk about it during the semester)
There will be organized a special project lesson at the end of semester.
Deadline: 2021-12-14
You are allowed to take the final exam before submitting the project. The points from the final exam will be counted if and only if you obtain at least 5 points from the project.
Date: 2021-12-14 08:00, M104. You can obtain up to 55 points.
What we have covered in the lectures:
What you have to know for the final exam:
To receive the points from the final exam, you have to obtain 20 points during the semester; out of these 20 points, at least 5 points have to be obtained from the project. To successfully finish the course, you have to obtain at least 50 points.