Blogger Widgets

Total Page visits

Thursday, August 15, 2013

Principles of Compiler Design two mark question and answers



What are the Error-recovery actions in a lexical analyzer?

1. Deleting an extraneous character
2. Inserting a missing character
3. Replacing an incorrect character by a correct character
4. Transposing two adjacent characters            


What is a sentinel? What is its usage?

A Sentinel is a special character that cannot be part of the source program. Normally we use ‘eof’ as the sentinel. This is used for speeding-up the lexical analyzer.

What is the need for separating the analysis phase into lexical analysis and parsing?     
(Or) What are the issues of lexical analyzer?

Simpler design is perhaps the most important consideration. The separation of lexical analysis from syntax analysis often allows us to simplify one or the other of these phases.

Compiler efficiency is improved.
Compiler portability is enhanced. 

What is Lexical Analysis?

The first phase of compiler is Lexical Analysis. This is also known as linear analysis in which the stream of characters making up the source program is read from left-to-right and grouped into tokens that are sequences of characters having a collective meaning.


What are the Error-recovery actions in a lexical analyzer?

1. Deleting an extraneous character
2. Inserting a missing character
3. Replacing an incorrect character by a correct character
4. Transposing two adjacent characters


What is recognizer?

Recognizers are machines. These are the machines which accept the strings belonging to certain language. If the valid strings of such language are accepted by the machine then it is said that the corresponding language is accepted by that machine, otherwise it is rejected. 

What are the cousins of compiler?

The following are the cousins of compilers
i. Preprocessors
ii. Assemblers
iii. Loaders
iv. Link editors. 

What are the main two parts of compilation? What are they performing?
The two main parts are 


Analysis part breaks up the source program into constituent pieces and creates   an intermediate representation of the source program. 

Synthesis part constructs the desired target program from the intermediate representation

State some compiler construction tools?

i. Parse generator
ii. Scanner generators
iii. Syntax-directed translation engines
iv. Automatic code generator
v. Data flow engines.

What is a Symbol table?

A Symbol table is a data structure containing a record for each identifier, with    fields for the attributes of the identifier. The data structure allows us to find the record for each identifier quickly and to store or retrieve data from that record quickly.
 

No comments: