Construct a Compiler

Learn how to think about compiler design without all the academic theory!

Whether you're a novice programmer who wants to understand how compilers work or a more advanced computer scientist who wants to build an operational compiler, this project will give you a head start in compiler design and development. Whatever your motivation, the applied approach employed in this project reduces development time by minimizing theory and using ample practicable instructions and freely available software tools.

Why Another Compiler?

Programmers must have a working knowledge of the system architecture in order to understand the fundamentals of designing and developing a professional-grade compiler for a targeted microprocessor. Building a compiler brings together many software technologies including grammar formalization using regular expressions, transition diagrams, and Extended Backus-Naur Form (EBNF) notation; source program scanning to form tokens; syntax analysis conducted by hand-coded parsers; symbol table organization using binary search trees; and assembler-ready code produced by optimizing code generators.

A good compiler is reliable, fast, and generates efficient code!

This project covers the following topics:

Practical Approach to Writing a Compiler

Few programmers are likely to build or even maintain a compiler for a programming language. This project employs an incremental approach to developing a compiler for a reformed programming language called Ada/PM. It begins by capturing central ideas expressed by early programming pioneers then builds on their seminal work by adopting selective features. Features are individually analyzed and converted into components of a context-free grammar (CFG). The resulting grammar is then used to build syntax-directed translation diagrams for use in hand crafting a scanner and parser. Both scanner and parser populate a symbol table organized as a binary search tree. Intermediate code is then generated, optimized, and passed to the code generator. The code generator outputs Intel®-compatible assembly language mnemonics, which are then converted to machine-level instructions by the assembler.

The key to building a compiler begins with aquiring the necessary skill set.

Ada/PM Compiler Design & Development

Craft the Ada/PM Compiler

This project is offered in three formats: softcover book, PDF document, and Windows help file. Each edition is organized around the construction of a compiler using freely available application tools downloaded from the internet. A step-by-step approach is used to introduce the concepts and challenges of building a professional-grade compiler, interpreter, and interactive debugger. Although the book focuses on a special-purpose language called Ada/PM, the principles can be applied to any similarly styled language.

Features include the design philosophies behind a top down, recursive descent parsing compiler built using a 64-bit version of C as the genesis language. The theme throughout the book is on how language design and compiler design influence one another. The final effort demonstrates how to use the newly reformed language to compile a version of itself.

Project ➤

No reasonably-sized tutorial can thoroughly cover every aspect of compiler design and development. This project generally covers only the most useful concepts and techniques needed to produce a working compiler for the Ada/PM language. For more theoretical coverage, check out the resources listed in the bibliography of the publication. It should be noted that examples are strictly based on programming for Intel® x86-64 microprocessors in the Windows® 64-bit environment. You will find no examples of MASM or GNU Assembler (GAS) syntax nor any reference to Linux, UNIX®, MS-DOS, CP/M, or Apple® operating systems.

Beginning to Professional Programmers

Our inline assembly language tutorials feature everything you need to write code for Intel x86-64 based architectures, access capabilities of the CPU not available from high-level languages, and call Windows API and C runtime library functions.

The goal of our tutorials is to help you learn by following along with the author on his journey of discovery. Learn to develop various software applications along side the author as he performs experiments that test various software programming theories.

Build a 64-Bit Compiler and Debugger

Build a totally reliable 64-bit compiler that compiles reasonably fast and generates efficient code. Understand the execution cost of implementing specific constructs. Avoid bloated compilers that include virtually every kind of run-time support the processor is capable of providing. Incorporate automatic program verifiers and enforceable language rules so that antiquated debugging tools become no longer necessary.

Learn-By-Doing

Our tutorials are set up so that you can teach yourself how to reform a new programming language and then design and develop a compiler for that language. Despite the number of very good programming languages available to programmers, not every language is consistent and standardized; meets the intended needs of particular users; or provides sufficient readability, maintainability, and safety. For this reason, there is always room for a custom-made language.

Regular Expressions

Regular expressions are used to define tokens in programming languages. One shortcoming is that regular expressions cannot specify nested constructs, which are central to many programming languages. Each rule in a context-free grammar is known as a production. The symbols on the left-hand sides of productions are known as nonterminals. Terminals, derived from the grammar, cannot appear on the left-hand side of productions. Terminals represent the tokens of a programming language.

Context-Free Grammar

Context-free grammars give program languages a set of rules for how tokens can be constructed. Context-free languages are generated from context-free grammars and are used by parsers to identify and classify tokens.

Copyright © 2020 PMzone Software. All rights reserved. Terms of Use