Created by TJ Monserrat
For the whole semester: We will learn how to design and implement compilers.
Programs that can turn everyday human language to things that can be executed by computers
Takes in Source Code or Character Stream
and turns it into an array of tokens or Lexemes
Each token is in the form of:
These tokens will be passed to the Syntax Analyzer
For Example
For Example
For Example
For Example
This makes the example:
into...
The Lexemes...
...will need to be fed to the syntax analyzer to produce a syntax tree like this...
[eq] |-------- | | [id, 0] [add] |-------- | | [id, 2] [mul] |--------- | | [id, 3] [number, 60]
To be able to do this...
[eq] |-------- | | [id, 0] [add] |-------- | | [id, 2] [mul] |--------- | | [id, 3] [number, 60]
We need to know how to parse them using Context-free grammars.
[eq] |-------- | | [id, 0] [add] |-------- | | [id, 2] [mul] |--------- | | [id, 3] [number, 60]
The system can create an intermediate code before translating it into the target program code.
We need to transform parse trees into a three-address code sequence. Note that three-address code sequences will be of the following...
We can then transform the intermediate code generation to the target code that can be understood by the system
But for our class, we need to transform the intermediate code above to our pseudo-ASM that we will discuss next time.
An essential function of a compiler is to record the variable names used in the source program and collect information about various attributes of each name.
These attributes may provide information about the storage allocated for:
Things you need to ponder when designing a language:
We should consider static-scope rules for a language with blocks, where a block is a grouping of declarations and statements.
Note that Scoping affects the Symbol Table structure.
Every exercise will have an effect on your project.
All exercises will building towards the project, Except the Target-Code Generation, because...
Translate own Source code to Target-code generation, passing through all of the phases:
Google Docs: https://goo.gl/SLMzVB