Creating the project layout
The project layout for tinylang
follows the approach we laid out in Chapter 1, Installing LLVM. The source code for each component is in a subdirectory of the lib
directory, and the header files are in a subdirectory of include/tinylang
. The subdirectory is named after the component. In Chapter 1, Installing LLVM, we only created the Basic
component.
From the previous chapter, we know that we need to implement a lexer, a parser, an AST, and a semantic analyzer. Each is a component of its own, called Lexer
, Parser
, AST
, and Sema
, respectively. The directory layout that will be used in this chapter looks like this:
Figure 3.1 – The directory layout of the tinylang project
The components have clearly defined dependencies. Lexer
depends only on Basic
. Parser
depends on Basic
, Lexer
, AST
, and Sema
. Sema
only depends on Basic
and AST
. The well-defined dependencies help us reuse the components.
Let’s have a closer...