Purpose of Language Processors
Purpose of Language Processors
Bridging
Semantic gap
Translation
of language
Error detection
and reporting
1
1. Bridge Gap between Application domain and execution domain
The gaps b/w both the domains are bridged by introducing a new domain PL
Domain. By introducing this new domain the software designer need to take care of
only bridging specification gap i.e. gap b/w Application domain and PL Domain, while
the translator takes care of execution gap.[1]
Analysis phase:
The analysis part breaks up the source code and imposes into a grammatical
structure. This structure is then used to create an intermediate representation(IR).
It also collects information like labels from source code and stores in a symbol table.
Synthesis phase:
This pahse constructs object code from IR and symbol table.Its objectives include:
2
Phases of an LP [2]
Lexical Analyser:
They read the stream of characters from source and groups them into meaningful
sequences called lexemes of the form
<token-name, attrib-value>
3
Syntax Analysis
Semantic Analysis
They perform type-checking and check for semantic consistency of source with the
language definition.
Intermediate code:
The intermediate code is taken as input and converted to target code. Prior to this
conversion these codes are optimized by machine-independent routines and thereby
increase its efficiency.
If target is an executable then efficient allocation of registers and memory location for
variable are selected.
One probable solution is to report errors after pass 1 rather than pass 2, but errors
like references to undefined variables only can be found at 2nd pass only.
It is inevitable to report errors only after pass 2 and to overcome the former issue
compilers print both target code and error description against the source itself. This
makes debugging easier.[3]
4
Q. Differentiate between one pass and two pass assemblers.
Introduction
Assemblers are language processors which are used to convert assembly level
languages into low-level machine level languages.
Functions of assemblers:
Analysis phase:
The analysis part breaks up the source code and imposes into a grammatical
structure. This structure is then used to create an intermediate representation(IR).
It allso collects information like labels from source code and stores in a symbol table.
Synthesis phase:
This pahse constructs object code from IR and symbol table.Its objectives include:
Design of Assembler:
The design of an assembler can be achieved in either
o Multi-Pass translation
2 pass translation.
o Single pass translation
5
Two-pass translation:
Pass 1:
Pass2:
6
No need for an intermediate code to An intermediate code is generated
be generated. after pass 1 to be passes to pass 2
All the tables should be available in Optab (Table containing mnemonics
memory during the translation process and op-codes) is needed only dring
and hence more memory intensive 1st pass and hence can be eliminated
in second pass
Generally all areas are defined before Though forward referencing is much
they are used and backpatching is left widely used forward references in
only for forward jumping. symbol definition are not allowed.
It is possible for data for data items, Eg: jack EQU jill
though inconvenient
is not allowed.
The object code is generated in The object code is written out and a
memory but is not written out implicitly loader is needed.
and hence no loader is needed
Emphasize more on processing power Used in areas where there is
and requires more memory. So used limitation of available memory is
where memory consumption is of no there
serious concern
.
Bibliography
Systems programming and operating systems – D M Dhamdhere. [1],[3]
Submitted by:
Amrith Krishna,
Roll No:5,
CSE-A,
FISAT