Turning the Source File into an Abstract Syntax Tree
As we learned in the previous chapter, a compiler is typically divided into two parts – the frontend and the backend. In this chapter, we will implement the frontend of a programming language – that is, the part that mainly deals with the source language. We will learn about the techniques that real-world compilers use and apply them to our programming languages.
Our journey will begin with us defining our programming language’s grammar and end with an abstract syntax tree (AST), which will become the base for code generation. You can use this approach for every programming language for which you would like to implement a compiler.
In this chapter, you will learn about the following:
- Defining a real programming language, where you will learn about the
tinylang
language, which is a subset of a real programming language, and for which you will implement a compiler frontend - Organizing the directory...