Source language issue
Again freestudy9 comes with something related to Source language issue. which related to compiler design.
1. Procedure call: Source language issue
- A procedure definition is a declaration that associates an identifier with a statement.
- The identifier is the procedure name and the statement is the procedure body.
- For example, the following is the definition of a procedure named read array:
Procedure read array
Var i: integer;
For i=1 to 9 do real(a[i])
When a procedure name appears within an executable statement, the procedure is said to be called at that point.
2. Activation tree: Source language issue
An activation tree is used to depict the way control enters and leaves activations. In an activation tree,
a) Each node represents an activation of a procedure.
b) The root represents the activation of the main program.
c) The node for a is the parent of the node b if and only if control flows from activation a to b.
d) The node for a is to the left of the node for b if and only if the lifetime of a occurs before the lifetime of b.
3. Control Stack: Source language issue
- A control stack used to keep track of live procedure activations.
- The idea is to push the node for activation onto the control stack as the activation begins and to pop the node when the activation ends.
- The contents of the control stack related to paths to the root of th activation tree.the
- When node n is at the top of the stack, the stack contains the nodes along the path from n to the root.
4. The scope of declaration: Source language issue
- A declaration is a syntactic construct that associates information with a name.
- A declaration may be explicit, such as var i: integer;
- Or they may be implicit. Example, any variable name starting with i is assumed to denote an integer.
- The portion of the program to which a declaration applies called the scope of that declaration.
5. Bindings of names: Source language issue
- Even if each time name declared once in a program, the same name may denote different data objects at runtime.
- “Data object” corresponds to a storage location that holds values.ata
- The term environment refers to a function that maps a name to a storage location.
- The term state refers to a function that maps a storage location to the value held there.
- When an environment associates storage location s with a name x, we say that x bound to s.
- This association referred as a binding of x.