SemWare Tutorial: A Simple Compiler and Interpreter for Teeny Pascal Language


Note:
Tutorial's Text and Program's Code are writen by Mr. Sam Mitchel the Leader of SemWare Corporation.
Original Site: A Simple Compiler
All Materials in this Repo are represented with the written Permission of the Author.

The goal of this series of articles is to develop a simple compiler. Along the way, I'll show how easy it is to do so.

There are four major parts to a compiler: Lexical analysis, Parsing, Semantic analysis, and Code generation.

Briefly, Lexical analysis breaks the source code into its lexical units. Parsing combines those units into sentences, using the grammar (see below) to make sure the are allowable. Semantic analysis makes sure the sentences make sense, especially in areas that are not so easily specified via the grammar. Type checking is a good example. Code generation takes the output of the Parser (many times in the format of an Abstract Syntax Tree) and converts it to (virtual) machine code, assembly code, or perhaps even code in another programming language - C is a popular target.

Tutorial Chapter Code Repositiry
Part 1: Lexical Analysis VS Project Teeny-1
Part 2: Syntax Analysis VS Project Teeny-2
Part 3: More about Grammars VS Project Teeny-3
Part 4: Semantic Analysis and the Symbol Table VS Project Teeny-4
Part 5: Variables VS Project Teeny-5
Part 6: Control Statements VS Project Teeny-6
References


TSE
  • Copyright © 2024 SemWare Corporation. All rights reserved worldwide.
  • SemWare is a registered trademark of Sammy and Bobbi Mitchell.