Chapter 2:: Setting up the project structure

Sawez FaisalSawez Faisal
2 min read

Introduction

Have a look at the topics mentioned here on your own as it cannot be discussed in detail due to the size constraints.

In this chapter, we'll dive into organizing our Sodum language project. A well-structured project is crucial for maintainability and scalability as we develop our language. It might seem excessive at first but having a well defined structure helps in increasing the modularity of the codebase as well as your mind will not lose its sanity trying to navigate through the codebase .

Project Layout

We'll set up our project with the following directory structure:

Key Components

1. src Directory

  • All of the cpp files of our code will be present here.

2. include Directory

  • The include directory will contain all of the header files including the tokens as well as the class and its methods declarations only

  • The implemention will be present in the corresponding cpp files to improve readability .

3. Grammar Directory

  • sodum_example.sdm: An example file written in Sodum to showcase language features

  • sodum_grammar.bnf: Defines the formal grammar of Sodum in Backus-Naur Form (BNF)

  • WE WILL DISCUSS THE GRAMMAR OF OUR LANGUAGE IN THE UPCOMING CHAPTERS

4. Build System (CMake)

  • A bulid system will take care of all the hassle of generating builds

  • CMakeLists.txt in the root directory to manage the build process

  • Configures compilation flags, links libraries, and sets up targets

5. Code Formatting

  • Code formatters helps us to beautify the codebases by formatting them in terms of spaces and alignment.

NEXT::

  • Now that the project drectory has been established we will have a look at the build systems and formatting tools in the next chapter
0
Subscribe to my newsletter

Read articles from Sawez Faisal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sawez Faisal
Sawez Faisal

New to the field and eager to learn how complex systems work smoothly. From building compilers to scalable systems, I’m solving problems as they come—whatever the domain—and sharing all the highs, lows, and lessons along the way!