Creating a programming language

On October 31, I handed in a paper I have been working on for the past few months. It shortly outlines the process of creating a programming language with a focus on compiler construction:

Compilers

Since computers only process instructions that are part of their instruction set, programs written in programming languages have to be translated into functionally equivalent programs in machine language prior to their execution. This process is called compilation and is performed by compilers.

To cope with this task, the translation is commonly split up into multiple steps, also referred to as phases. A compiler starts with reading the input file byte by byte, character by character.

Like our eye splits up a text into individual words, the second step is to group meaningful characters together and remove those without meaning (e.g.,~whites paces). This step is called lexical analysis and results in a stream of tokens: short, categorized strings of characters.

In the next phase, the compiler determines the relationship between the tokens. It applies the syntax of the programming language and is therefor called syntactical analysis. It results in a tree structure that represents the program.

At this stage, some compilers apply additional transformations to the program to increase performance before finally generating code in the language of the target machine.

So, if you want to know how your favorite compiler works, have a look at “Creating a programming language” (PDF, 400KiB).

Discussion Area - Leave a Comment