System Software Ch2
System Software Ch2
2 Language Processors
Syllabus
Programming languages and language processors, Language processing activities, Programn
execution, Fundamental of language processing, Symbol tables, Data structures for language
processing: Search data structures, Allocation data structures.
Contents
2.1 Programming Languages and Language Processors
Marks 7
Winter-17, 19,
2.2 Language Processing Activities
2.3 Fundamental of Language Processing
2.4 Fundamentals of Language Specification Winter-18, 19, Marks 3
2.5 Language Processor Development Tools Winter-14, 17· Marks 3
2.6 Symbol Tables Data Structures for Language Processing
2.7 Multiple Choice Questions
2.8 Short Questions and Answers
(2- 1)
2-2 Overview of Language Processors
System Software
Object C programs
oriented C++
programs preprocessor
(C++)
Errors
generated
by preprocessor
(a
Object
oriented Programs
language Translator for
programs C++ machine
(C++) language
Errors
generated
by translator.
(b)
Domain2
Domain1 programming
application Domain 3
language
execution
Specification
Execution
gap
gap
Fia. 2.1.3 Specification
and execution gaps
The specification gap is
bridged by the software
development team
gap by the designer of
the PL processor using and execution
PL domain helps
translator or an interpreter.
in improving the quality of
the software.
212 Interpreters
An interpreter is a
language processor. It
links an execution gap High level
language Inter preter Program
without generating program execution
machine language result
program. Fig. Input
2.1.4 Output
shows the interpreter.
Fig. 2.1.4 Interpreter
An interpreter is
language translator.
The language processing activities
of an interpreter cannot be separated
program execution from its
activities. This is because of the
There is also an absence of an output absence of target program.
interface of interpreter.
Fig. 2.1.5 shows the interpreter
domain.
Interpreter Domain
Programming Programn
language execution
domain domain
Advantagos
1. Itrequires less memory space.
2. It is suitable for general purpose programming
Dlsadvantagos
1. It does not support automatic memory management.
2. Itdocs not provide security for data.
3. Larger codes are difficult to maintain.
Rovlow Quostlons
I. Which activity reduce speciflcation gap? Explain with suitable example. Who will reduce execution
gap ? GTU : Winter-17, Marks 7
2. Give eNmples of language processors. GTU Winter-19, Marks 3
User
program
Specification Software
system
Program Errors
generator
any
Required
PLfor
programs
Specification
gap
Fig. 2.2.2 Program generator domain
ITECHNICAL PUBLICATIONS- An up thrust
for knowledae
System Software 2-7 Overviow of Languago ProcOssors
User programs
if
Language Generates any
translator
Secondary
storage
Database device
Program
for
machine
language
Reguired
target program
2. Program interpretation :
It reads the source program and stores it in its main memory. During program
interpretation, it takes a source statement and determines its meanings. Then it
perform the actions which to be implement on that statement.
The action may be computational and input-output. Fig. 2.2.4 shows the
interpretation.
Main
Interpreter Memory
Program Source
COunter program Disk
data
Errors
(a) Interpretation
Main
Processor Memory
Program Machine
cOunter language
program Disk
data
Program counter increments the memory address for next instruction. CPU uses
the program counter for next instruction.
Instruction execution cycle consists of following steps :
1. Fetch the instruction
Characteristics of Interpretation
1. Source program
is retained in the source fornm itself.
2. Statement is analysed
during its interpretation.
PUBLICATIONS
TECHNICAL -An up thrust for knowledge
System Software Overview of Language Processors
2-10
Source program
Input
Language processor
Analysis Errors
phase may get generated
Synthesis
phase Errors
may get
generated
Output Target
program
Intermediate representation
It is a data structure that is constructed from input data to a program and from
turn.
which part or all of the output data of the program is constructed in
Propertles
1. Must be convenient for semantic analysis phase to produce.
2. Memory efficiency.
3. Must be convenient to translate into real assembly code for all desired target
machines.
4. Ease of use.
Intermediate
representation
Required
target
program
Fig. 2.3.2 IR
First pass performs analysis of the source program and reflects its results in the
intermediate representation. The second pas reads and analysis the IR.
The compiler takes a source program written in high level language as an input
and converts it into a target assembly language. The assembler then takes this
assembly code as input and produces a relocatable machine code as output. Then
a program called loader is called for performing the task of loading and link
editing.
The task of loader is to perform the relocation of an object code. Relocation of an
object code means allocation of load time addresses which exist in the memory
and placement of load time addresses and data in memory at proper locations.
The link editor links the object modules and prepares a single module from
several files of relocatable object mnodules to resolve the mutual references. These
files may be library files and these library files may be referred by any program.
TECHNICAL PUBLICATIONS -
An up thrust for knowledge
System Software 2-12 Overview of Language Processors
Compiler
Target
assembly
Assembler
Relocatable machine
Code
Loader/Link-editor
Library, relocatable
object file
Executable machine
COde
Output
Executable Language
COde processing
Data
Fig: 2.4.1 Language processing
Example 24 Which type of gap makes the software buggy or unreliable ? Which nethods
Can be used to Overcome this situation ? GTUWinter-18, Marks 3
Solution : Specification and execution gap makes the software buggy or unreliable :
Specification Gap : It is the semantic gap between the two specifications of the
same task.
Execution Gap : The gap between the semantics of programs written in the
different programming languages.
Methods used to overcome this situation is as follows
:
Review Question
Thus the use of LEX and YACC tools help in generating the lexical and svmtay
analyzers which ultimately enhances efficiency of compiler building.
Entry format
Entry format are of two types :
a. Fixed length
b. Variable length
Table organizations
A table is a linear data structure. The entries of a table occupy adjoining areas of
the memory.
TECHNICAL PUBLICATIONS - An up
thrust for knowledge
System Sofware 2-17 Overviow of Languago ProOco3SOrs
2.6.2.1 Stacks
Stack is a linear data structure.
Properties
1. Stack is an unbounded array that is treated in a last-in, first-out (LIFO) manner.
The last element stored is the first one removed.
2.Only the last entry is accessible at any time.
• A Stack Pointer (SP) indicates the position or frame at the top of the stack.
TECHNICAL PUBLICATIONS- An up thrust for knowledge
2- 18 Overview of Language
System Sofiware PrOcessors
- area.
Stack Base (SB) It points to the first word of the stack
Top of Stack (TOS) - It points to the last entry allocated in the stack.
TOS –
TOS 700
SB
SB
RB3
Record RB
TOS
TOS
SB, RB
TOS
(c)
Fig. 2.6.5 Allocation and deallocation time actions
Review Question
Ans. Specification gap is between application domain and PL domain. The specification
:
cap is bridged by the software development team and execution gap by the designer of
the PL processor using translator or an interpreter.