Beruflich Dokumente
Kultur Dokumente
• Semantic:
It represents the rules of the meaning of the domain.
• Semantic gap:
It represents the difference between the semantic of two domains.
• Application domain:
o
A user does not wish to interact with the computer on terms of machine language
o It is easier to describe the computation by using the terms related to entities and operations in the
application domain of the software
o
The designer expresses the ideas in terms related to application domain of the software.
o .. i.e. designer of airline reservation application would like to think of how the reservation data
would be used by the query, book and cancel operations,
o
rather than how it should be implemented in the machine language.
o The description of the reservation data and the query, book and cancel operations forms a
specification of the application.
• Execution domain:
o To implement the ideas of designer, their
description has to be interpreted in terms related to the
execution domain of computer system.
o For e.g. The system software has to implement this specification of application domain in the
execution domain of the computer system.
o The entities in execution domain are cells in memory and registers in the CPU, and the operations are the
instructions of the CPU
• Specification gap:
The gap between application and PL domain is called specification and design gap or simply
specification gap. Specification gap is the semantic gap between two specifications of the same
task.
• Execution gap:
The gap between the semantic of programs written in different programming language.
• Language processor:
Language processor is software which bridges a specification or execution gap.
• Language translator:
Language translator bridges an execution gap to the machine language of a computer system.
• Detranslator:
It bridges the same execution gap as language translator, but in the reverse direction.
• Preprocessor:
It is a language processor which bridges an execution gap but is not a language translator.
• Language Migrator:
It bridges the specification gap between two programming languages.
• Interpreter:
An interpreter is a language processor which bridges an execution gap without generating a
machine language program.
• Source language: The program which forms the input to a language processor is a source program.
The language in which the source program is written is known source language.
• Target language: The output of a language processor is known as the target program. The
language, to which the target program belongs to, is called target language.
2) What is specification gap? What is Semantic gap? Who can bridge the specification gap? How?
How can we reduce the semantic gap?
Program
generation activity aims an automatic generation of a program.
Program generator is a software, which accepts the specification of a program in some specification
language and generates a program in the target language, which is typically a procedure oriented
programming
language.
Program generator introduces a new domain between the application and programming language
domain
is called program generator domain.
Thus, program generation bridges the specification gap.
Two popular models for program execution are translation and interpretation.
Bridges the execution gap by translating a program written in a programming language, called
source program, into an equivalent program in the machine or assembly language of computer
system,
called the target program.
If target program is machine program – executed straight away
A
program must be translated before it can be executed
A machine language program generated by the translator may be saved in a file so that it can be
loaded
into computer’s memory and executed whenever desired.
If source program is modified , must be translated before it can be executed , we call it retranslation
following a modification
(2) Program Interpretation:
The Interpreter reads the source program and its data and stores it in its memory. It executes
program
without generating target program.
Let us understand how it works by considering similarities between interpretation of a program and
execution
of a machine language program by CPU
Interpreter is a system program not hardware unit. It maintains Program Counter to hold statement
number
of source program that is to be interpreted next.
The statement would be subjected to the interpretation cycle, consists of following steps.
Characteristics of interpretation:
The
source program is retained in the source form itself, i.e. it is not converted to a target form
A statement is analyzed during its interpretation. Thus , a statement need not be analyzed before it is
interpreted.
This feature is beneficial if a program is modified between executions, as in the program
development environment.
However, it also makes interpretation of a statement slower than execution of machine language
instructions that a compiler would have generated for the statement.
Language processor pass: A language processor pass is the processing of every statement in a source
program, to perform language processing function.
• Pass I: Perform analysis of the source program and note deduced information.
• Pass II: Perform synthesis of target program.
• The first pass performs analysis of the source program and reflects its results in the intermediate
representation.
• The second pass reads and analyzes the intermediate representation to perform synthesis of the
target program.
Front end :
3. Semantic Analysis
• Semantic analysis determines the meaning of a statement by applying the semantic rules to the
structure of the statement.
• While processing a declaration statement, it adds information concerning the type, length and
dimensionality of a symbol to the symbol table.
• While processing an imperative statement, it determines the sequence of actions that would have to
be performed for implementing the meaning of the statement and represents them in the
intermediate code.
• Considering the tree structure for the statement a = b + i
o If node is operand, then type of operand is added in the description field of operand.
o While evaluating the expression the type of b is real and i is int so type of i is converted
to real i*.
• The analysis ends when the tree has been completely processed.
Intermediate representation
• IR contains intermediate code and symbol table.
• Symbol table
• Intermediate code
1. Convert(id1#1) to real, giving (id#4)
2. Add(id#4) to (id#3), giving (id#5)
3. Store (id#5) in (id#2)
Back End:
Memory allocation
• The memory requirement of an identifier is computed from its type, length and
dimensionality and memory is allocated to it.
• The address of the memory area is entered in the symbol table
Code generation
• The synthesis phase may decide to hold the value of i* and temp in machine registers
and may generate the assembly code
CONV_R AREG, I
ADD_R AREG, B
MOVEM AREG, A
5) Explain symbol tables. Explain linear and non-linear symbol table organization. OR What is
Symbol table? Explain how one can organize Symbol table using Linear Data Structure?
Symbol Tables: An Identifier used in source program called symbol . Names of variables, functions
and procedures are symbols. A Language processor uses the symbol table to maintain information
about attributes of symbols used in a source program
1. Add a symbol and its attributes : Make a new entry in the symbol table
3. Delete a symbol’s entry : Remove the symbol’s information from the table
4. Access a symbol’s entry : Access the entry and set, modify or copy its attribute information.
Add
and Locate operations take a symbol as a parameter e.g. ADD(s1)
The Add operation indicates an error if an entry already exists for the symbol, Otherwise , it makes a
new
entry
The Locate operation returns a pointer to the symbol’s entry in the table if one exists,
Otherwise, it returns a null pointer. E.g. int *p; p = Locate(s1);
The delete and access operations may either take a symbol or the pointer to a symbol’s entry returned by
the locate operation as parameters. Delete (s1) or Delete (p)
Two kinds of data structures can be used for organizing its entries:
Linear data structure: Entries in the symbol table occupy adjoining areas of memory. This property
issued to facilitate search.
o Use of linear – single contiguous area of memory that can accommodate all entries. This
requirement forces designer to allocate memory for the largest number of entries the symbol table
may contain. However, it is wasteful because some part of the allocate memory may not be used.
Nonlinear data structure: Entries in the symbol table do not occupy contiguous areas of memory.
The
entries are searched and accessed using pointers
o Nonlinear avoids the problem because it allows memory to be allocated in entry- by – entry manner
The following entry formats can be used for accommodating the attributes:
Here in (a) each entry has 8 attribute fields, When class=label, all attribute fields except the field for
storing
its statement number are redundant.(useless)
(b) shows variable length entry format for a symbol that is used as a label. It has only one attribute
field
3. Hybrid entries
Combines search efficiency of fixed length and memory efficiency of variable length
Each entry is split into two halves , fixed part and variable part
Pointer field is added to fixed part , It points to variable part of an entry
Fixed
part of all entries are organized into linear data structures
As it has pointer to a variable part, Variable part does not need to be located through search
Hence it could be put into a linear or non linear data structure