Tidy up
This commit is contained in:
103 files changed
+3663
-3779
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# Compilers - COMP 3012
|
||||
|
||||
A compiler is a tool that maps one language into another language. It takes a program written in a source programming language and maps it to program written in a target programming language. A compiler is written in an **implementation language**.
|
||||
A compiler is a tool that maps one language into another language. It takes a program written in a source programming language and maps it to a program written in a target programming language. A compiler is written in an **implementation language**.
|
||||
|
||||

|
||||
|
||||
@@ -10,21 +10,21 @@ An **interpreter** is a program that takes a source program and executes the pro
|
||||
|
||||

|
||||
|
||||
> NOTE: Java uses both. A java source program is compiled into byte code (by a compiler) which is then executed by an interpreter (called java virtual machine - JVM). JVM will also compile fragments of code so that if there is a call back, it can execute the compiled code. This is called compilation on the fly.
|
||||
> NOTE: Java uses both. A Java source program is compiled into bytecode (by a compiler), which is then executed by an interpreter (called the Java virtual machine - JVM). The JVM will also compile fragments of code so that if there is a call back, it can execute the compiled code. This is called compilation on the fly.
|
||||
|
||||
Compilers will often use an **intermediate representation (IR)** to bridge the gap between the source language and the executable language. Converting source language to IR is called **front end**, where as converting IR to executable code is called **back end**.
|
||||
Compilers will often use an **intermediate representation (IR)** to bridge the gap between the source language and the executable language. Converting source language to IR is called **front end**, whereas converting IR to executable code is called **back end**.
|
||||
|
||||
* The front end focuses on understand the source-language program.
|
||||
* The back end focuses on mapping programs to the target machine
|
||||
- The front end focuses on understanding the source-language program.
|
||||
- The back end focuses on mapping programs to the target machine
|
||||
|
||||

|
||||
|
||||
* The front end, intermediate representation and the back end are all part of the compiler.
|
||||
- The front end, intermediate representation and the back end are all part of the compiler.
|
||||
|
||||
IR is stored as an Abstract Syntax Tree **AST**.
|
||||
|
||||
The syntactic details needed for parsing the source program are represented in the structure of the tree.
|
||||
|
||||
The **IR** could be broken down into many sub-steps i.e. a IR1 could be created which is then ran through an optimiser to create IR2 which is fed into the back end instead of IR1. This is called a *three-phase compiler*.
|
||||
The **IR** could be broken down into many sub-steps, i.e. an IR1 could be created, which is then run through an optimiser to create IR2, which is fed into the back end instead of IR1. This is called a *three-phase compiler*.
|
||||
|
||||

|
||||

|
||||
Reference in new issue
Block a user