Intermediate-code-generator
Question 1 |
Three address code | |
Abstract Syntax Tree (AST) | |
Symbol table | |
Control Flow Graph (CFG) |
-
An intermediate representation is a representation of a program “between” the source and target languages. A good IR is one that is fairly independent of the source and target languages, so that it maximizes its ability to be used in a retargetable compiler.
Types of intermediate representation:
- Structured (Tree such as abstract syntax tree or Graph such as CFG, single static assignment)
- tuple-based, generally three-address code (quadruples)
Symbol table is not an intermediate representation of a source program. Symbol table is created in the first phase (lexical analysis phase and subsequently updated in later phases) and it stores the information about the occurrence of various entities such as variable names, function names, objects, classes, interfaces, etc.
Abstract syntax tree and three address code are well known representations of intermediate code.
CFG i.e., control flow graph is also a representation of intermediate code which represents the flow of control of the program. In CFG we break sequences of three address codes into basic blocks hence CFG is also a representation of intermediate code as it contains three address codes along with control flow representation with help of blocks and edges (arrows).