Sessions (preliminary)

Introduction To Compilers

Walter Bright (1.5 hrs)

This introduces the process of how source code is transformed into an executable image. The roles of each of the tools involved - assembler, compiler, linker, librarian and debugger is explained. The compiler is then opened up and its various phases, subsystems and their interrelationships are introduced.



Lexing and Parsing

Walter Bright (1.5 hrs)

Lexing is the process of converting the source text into tokens. Although lexing is conceptually straightforward, there are a lot of wrong and inefficient ways to write one. The first part of this session will show the right way to build a simple and very fast lexer. The second part will show how the token stream is then parsed by the compiler to produce abstract syntax trees.



Semantic Analysis

Walter Bright (1.5 hrs)

Semantic analysis takes the abstract syntax tree output of the parser and deduces the meaning of it. This requires the creation of symbol tables, strategies for organizing the semantic information, and type checking. This stage figures out all the declarations, control flow, expands templates, and inlines functions.



Intermediate Representation

Walter Bright (1.5 hrs)

The intermediate representation is the end result of semantic analysis of the source program. The optimization and code generation phases operate on the intermediate representation. Careful selection of the intermediate representation will determine how easy it is to do optimization and how effective those optimizations can be.



Interpreters

Walter Bright (1.5 hrs)

Interpreters are programs that execute the intermediate code directly without transforming it into native code. Some of the most widely used languages today, such as Perl, Python, Ruby, and Javascript, are interpreted languages. The general strategy of an interpreter is presented, along with examination of how a Javascript interpreter works.



Optimization

Walter Bright (1.5 hrs)

Optimization is the transformation of the intermediate code into different intermediate code that will presumably translate into faster executable code. Basic optimizations are introduced. The construction of directed acyclic graphs and data flow equations are covered, along with how to use the results to improve the code.



Code Generation

Walter Bright (1.5 hrs)

Code generators transform the intermediate code into native executable code. This covers function prolog and epilog, instruction selection, register allocation, peephole optimization.



Special Topics

Walter Bright (1.5 hrs)

As languages have gotten more advanced, compilers need to do more than just generate functions. This provides an introduction to how features like closures, exception handling, thread local storage, and position independent code are dealt with.