Introduction

Pylayers helps you learn all the layers in the compilation and execution of a Pythonic high level language program. It provides a simple working compiler and virtual computer, implemented in Python, for educational purposes.

Pylayers will introduce you to numerous computer science topics, all with working Python code. These include tokens, productions, grammars, abstract syntax trees, parsers, parser generators, intermediate codes, intermediate code generators, assembly codes, assemblers, computer processor registers, computer processor instruction sets, machine codes and more.

I hope you find Pylayers useful. I, Dr. Christian Seberino, welcome all questions, comments and suggestions. You can reach me by email here .

Example

Here are all the layers in the transformation of a Pythonic high level language program to machine code. The source code layer is the only layer the human typically sees. The machine code layer is the only layer the computer executes:

Layer Example Description
high level language source code The screen goes here. This is high level Pythonic source code. This is typically the only layer programmers see.
abstract syntax tree The screen goes here. This is the abstract syntax tree created by parsing the high level language source code. See the Python implementation of the component generating it here.
intermediate code The screen goes here. This is the intermediate code created by transforming the abstract syntax tree. See the Python implementation of the component generating it here.
assembly code The screen goes here. This is the assembly code created by transforming the intermediate code. See the Python implementation of the component generating it here.
machine code The screen goes here. This is the machine code created by transforming the assembly code. See the Python implementation of the component generating it here. This is high level Pythonic source code. This is typically the only layer programmers see.