The Middle End Flashcards
What is a statically checked programming language?
A programming language that performs type checking at compile time
What is a dynamically checked programming language?
A programming language that performs type checking at run time
What is the symbol table often stored as?
A hash table
A lot of programming languages allocate and initialise a symbol table for each scope
What are the different types of Internal Representation (IR) ?
- Graphical (structural)
- Linear
-Hybrid
What is a graphical internal representation?
Uses a node and edge structure to create the internal representation, tends to be close to source code
What is linear internal representation?
An internal representation that uses pseudo code for some abstract machine. Typically close to target code.
What is a hybrid internal representation?
A combination of a graphical and linear approach to internal representation
How would you convert a parse tree to an abstract syntax tree?
- Traverse the parse tree in post order
- Remove non-terminal symbols
Why do we convert from a parse tree to an abstract syntax tree?
The parse tree contains a lot of unnecessary information
The AST is a near source-code level representation
Easily generate source code, perform an in order traversal
What are some issues with abstract syntax trees?
- They use a lot of pointers for traversals and transformations
- memory intensive
How does a linear representation work?
We use three address codes,
where every statement is a single operator, and contains at most three operands
What are auxilliary graph representations?
These representations do not represent the full code, instead they represent properties of the code.
Name 3 auxiliary graph representations
Control Flow Graph
- models the way that the code transfers control as a result of conditional or loop statements
Data Dependence Graph
- encodes flow of data
Call Graph
- shows dependencies between procedures, which functions may be calling other functions
What do the nodes and edges of a control flow graph represent?
Node = a single basic block (a maximal straight line of code)
Edge = a transfer of control between basic blocks