Fundamentals and Implementation of Programming Languages
6 ECTS
Master's
Czech
Karel Šafr
The course is designed for beginners who want to gain a deeper understanding of programming rather than simply writing commands in an existing programming language. Students will gradually become familiar with both basic and more advanced programming concepts, such as variables, expressions, conditions, loops, functions, data types, variable scope, and error handling.
Course outline
Introduction to Programming Languages and the First C++ ProjectWhat is a programming language, what is source code, and what are an interpreter and a compiler? Why can’t a computer understand a program directly? Students will create a C++ project and learn how to compile and run it. At the same time, they will choose a working name for their future programming language.
Program Text as Input: Reading a File and Working with CharactersStudents will learn how to load the source file of their language into a C++ program. They will understand that a program is initially just plain text that needs to be processed. They will practice working with strings, characters, files, and command-line arguments.
Tokens and Lexers: Breaking a Program into Meaningful PartsStudents will create the first component of their own programming language — a lexer. It will convert the program text into tokens, such as numbers, variable names, keywords, operators, and parentheses. In this module, students will understand the difference between plain text and the structure of a program.
Expressions and Mathematical OperationsStudents will add support for simple expressions, such as 1 + 2, x * 5, and (3 + 4) * 2. They will learn how operator precedence works and how a programming language determines the order in which expressions are evaluated.
Parser and Abstract Syntax TreeStudents will learn how a parser works and be introduced to the concept of an Abstract Syntax Tree (AST). They will understand that a program is not simply a sequence of words, but a structured representation that can be evaluated. In C++, they will begin building representations of expressions and statements using structs or classes.
Variables and Program MemoryStudents will add variable declarations to their programming language, using syntax such as let x = 10. They will learn how values are stored and associated with variable names, how assignment works, and how variables can be referenced later in expressions.
Data Types and ValuesStudents will add basic data types to their programming language, including numbers, strings, and Boolean values (true / false). They will learn the difference between a value and its type, understand how type errors occur, and explore why certain operations are only valid for specific data types.
Conditionals: if, else, and Program Decision-MakingStudents will extend their programming language with conditional statements using constructs such as if, else, and end. They will learn how conditional logic controls the flow of a program and how Boolean values and expressions determine which branch of the program is executed.
Loops: Repetition with while and forStudents will add looping constructs to their programming language, starting with a simple while loop and then introducing a basic for loop, such as for i in range(0, 10). They will learn how a section of code can be evaluated repeatedly, how to work with loop counters, and how infinite loops can occur.
Functions, Parameters, and Return ValuesStudents will add support for user-defined functions to their programming language, using syntax such as fun add(a, b) do ... return ... end. They will learn the difference between parameters and arguments, understand return values and function calls, and explore how a new execution environment is created when a function is called.
Scope, Local Variables, and Error MessagesStudents will learn the difference between global and local variables and understand how variable scope determines where a variable can be accessed. They will explore how the language looks up values across different levels of scope and improve error messages so that the language can clearly indicate where and why a program failed.
Finalizing the Programming Language, Compilation, and PresentationIn the final module, students will complete their own programming language. They will choose its name, file extension, keywords, and a small custom feature. The final result will be a compiled C++ program capable of running programs written in the student’s own language. The course will conclude with a short presentation and demonstration of a working program written in their language.