0

Compiler Design

Description: practice questions.
Number of Questions: 15
Created by:
Tags: compiler Compiler Design Parser Run Time Environment Syntax Directed Translation Computer Science & Information Technology - CS
Attempted 0/15 Correct 0 Score 0

Which of the following is a similarity between macro processor and compiler pre-processor?

  1. Functionally, both are same.

  2. Both are used to preprocesse the assembler directives.

  3. Both are used to preprocess the compiler directives.

  4. Both provide subroutine facility to language processor.

  5. Both are different, they do not have any similarity.


Correct Option: A
Explanation:

Both processes are performed before the actual conversion of source program is done. Macro processor puts the actual assembly code in place of Macro symbol, wherever these are used or defined. Compiler pre processor preprocesses the header files and other predefined terms.

Both compiler and assembler are similar in atleast one function. Which of the following options correctly indicates the similarity?

  1. Both converts high level language file in to object file.

  2. Both uses pre-processors before processing main program of the source program.

  3. Both converts the source program into machine language program.

  4. Both uses symbol table in second pass to convert the source into machine language.

  5. Both option 3 and option 4 are correct.


Correct Option: E
Explanation:

Yes, both option 3 and 4 are correct.

Cross compiler generates code for which of the following targets?

  1. The target machine on which it is being executed.

  2. The target machine other than the machine on which it is being executed.

  3. By default, the target is server machine of the node on which it is being executed.

  4. Cross compiler does not generate machine code.

  5. Both 2 and 3


Correct Option: B
Explanation:

Cross compiler generates code for some other target machine defined by user. It can be some other processor or microcontrller or micro processors etc.

Which of the following options explains the attributes of a token in compiler design?

  1. Concrete manifestation of a token in the text

  2. Key words

  3. White spaces

  4. Value of an integer token defines value of identifier M

  5. Delimiter


Correct Option: D
Explanation:

Attributes define the token by its value.

Display char is an identifier for a compiler of a given language and it recognize it as token. The NFA will find it as which of the following?

  1. Token

  2. Token recognizer

  3. Expression recognizer

  4. State

  5. None of the above


Correct Option: B
Explanation:

NFA will yield it as token recognizer.

Which of the following analysers of compiler uses parse tree of a source program?

  1. Lexical

  2. Syntax

  3. Code generator

  4. Boot strap loader

  5. Intermediate code generator


Correct Option: B
Explanation:

It uses the parse tree to find out syntax validity of the statement.

During compilation of the C statement for(i=1;i<10;i++) The compiler converts it as detailed below: for-------keyword,
i----identifier ,
1 & 10 ---------constants or literals,
( =,<,++)------operator. Above conversion is a valid conversion. The compiler does it during which of the following analysis phases?

  1. Semantic analysis

  2. Syntax analysis

  3. Optimization analysis

  4. Lexical analysis

  5. Code generation


Correct Option: D
Explanation:

This is the first analysis done by compiler. The source code is scaned statement by statement and tokens are framed as shown in question and put into symbol table etc.

Which of the following is a necessary condition for a single pass compiler?

  1. It generates symbol table and generates code afterwards.

  2. It allows labels, which can be defined after it is used.

  3. It does not allow defining a function after it has been called in the program.

  4. It allows a forward definition of a symbol or identifier.

  5. None of the above


Correct Option: C
Explanation:

All the functions has to be defined before they are used or called.

In a perfectly designed compiler and perfectly coded program, a system error, i.e. memory insufficiency occurs while executing a recursive function call and execution of the program is terminated. What is the reason behind the occurence of this error?

  1. Compiler

  2. Program, since queue entries are overflowed

  3. Stack overflow

  4. Number of stacks assigned to this program crossed the maximum limit assigned to compiler

  5. Symbol table over flow


Correct Option: D
Explanation:

Every call to a recursive program creates a local stack of desired length. But if recursive function calls itself with in the function then another stack is crated for second call and this goes on as long as the recursive function call itself without completing it self. In the given prohram , the condition to close the recursion is not set and so the function is called endlessly. This situation has caused the error of insufficient memory, since no more space is available for new stack.

Which of the following correctly defines the difference between finite automation and non-determistic finite automation?

  1. Q is finite and non-empty set of states in FA and empty set of states in NFA.

  2. δ is from Q X ∑ to 2φ in NFA and Q X ∑ to Q in FA.

  3. ∑ is a finite non empty set of inputs in FA but it is empty set of input in NFA.

  4. q0 is initial state in FA and final state in NFA.

  5. None of the above


Correct Option: B
Explanation:

Yes, this is the currect difference in FA and NFA.

A grammar, which does not have any left or right rule can be recognized as which of the following?

  1. Context sensitive grammar

  2. Context content grammar

  3. Context free grammar

  4. Context derived grammar

  5. None of the above


Correct Option: C
Explanation:

Context free grammer can define a language with out left or right rule.

Operator precedence, SLR, CLR, LALR, Shift reduce

The above given parsers are

  1. top down parsers

  2. bottom up parsers

  3. centre break parsers

  4. recursive distance parsers

  5. not parsers, but grammars


Correct Option: B
Explanation:

All of these are bottom up parsers as in all of these, the parse tree is constructed from the terminal to the root of the parse tree.  

Back tracking is required in which of the following parsing techniques?

  1. Bottom up

  2. Operator precedence

  3. Top down

  4. Top up

  5. Shift reduce


Correct Option: C
Explanation:

Back tracking is required to find nearest root in top down parsing.

Given a statement : w = abbcde In which of the following parsers is the right most derivative in reverse technique applied?

  1. Bottom up

  2. Top down

  3. Centre break

  4. Recursive descent parser

  5. None of the above


Correct Option: A
Explanation:

Bottom up parsers applies the technique of right most in reverse parsing.

Which of the following types of intermediate codes is used in a single pass compiler?

  1. Postfix notations

  2. Syntax tree

  3. Quadrupples

  4. Intermediate code is not generated at all

  5. Tripples


Correct Option: D
Explanation:

Single pass compiler does not generate intermediate code , since equivalent code is generated as and when the statement is scanned.

- Hide questions