0

Online Test 1 - Compiler | Computer Science(CS)

Description: GATE Exam online test 1 Compiler Design | Computer Science(CS)
Number of Questions: 18
Created by:
Tags: GATE CS Compiler Design
Attempted 0/18 Correct 0 Score 0

Remove the left recursion from the following grammar. $E \rightarrow Ea|Eb|a|b$

  1. $E \rightarrow aE'|bE';E'\rightarrow aE'|bE'|\epsilon$

  2. $E \rightarrow aE'|bE'|\epsilon;E'\rightarrow aE'|bE'$

  3. $E \rightarrow aE'|bE'|\epsilon;E'\rightarrow aE'|bE'|\epsilon$

  4. None of these


Correct Option: A

A bottom up parser generates

  1. right most derivation

  2. right most derivation in reverse

  3. left most derivation

  4. left most derivation in reverse


Correct Option: B

When a computer is first turned ON and restarted, a special type of absolute loader is executed called

  1. compile and go loader

  2. boot loader

  3. boot strap loader

  4. relating loader


Correct Option: C

Which of the following statement(s) is/are true?

S1 : Right recursion is needed for termination in predictive parsers. S2 : Left recursion require more stack space than right. S3 : Left recursion works fine in bottom up parsers.

  1. $S_1 and\ S_2$

  2. $S_1 and\ S_3$

  3. $S_2 and\ S_3$

  4. $S_1,S_2\ and\ S_3$


Correct Option: B

Consider the following grammar: S$\rightarrow$SS S$\rightarrow$0 S$\rightarrow$$\epsilon$ Which of the following is true related to the given grammar? (i) It is ambiguous. (ii) It is left recursive. (iii) It is LL(1). (iv) It accepts 0+.

  1. iii only

  2. iii & iv

  3. I & ii

  4. i, ii & iv


Correct Option: C
Explanation:

The grammar is not LL(1) because the grammar is ambiguous and left recursive. The regular expression for the language accepted by grammar is 0+.

The language recognized by the following finite automation is

  1. aabb* + bab*

  2. (aab) (empty + (bab))

  3. (aa + empty) (b + ba) (bab)*

  4. (aab + ba) (bab)*


Correct Option: D
Explanation:

Start A to accept $\epsilon$ $r_1 = (aan + ba)$ $\epsilon$ to C & D $r_2 = (bab)^$ $r = r_1r_2 = (aab + ba)(bab)^$

A simple two-pass assembler does which of the following the first pass?

  1. It allocates space for the literals.

  2. It computes the total length of the program.

  3. It builds the symbol table for the symbols and their value.

  4. All of these


Correct Option: D

The front end of toy compiler performs to (i) determine validate of a source statement from the viewpoint of the analysis (ii) determine the content of a source statement (iii) construct a suitable representation of the source statement for use by subsequent analysis function or by the synthesis phase of the language processor

  1. (i), (iii)

  2. (ii), (iii)

  3. (i), (ii)

  4. (i), (ii), (iii)


Correct Option: D

Dynamic linking can cause security concern because

  1. security is dynamic

  2. path for searching dynamic libraries is not known till runtime

  3. linking is insecure

  4. cryptographic procedures are not available for dynamic linking


Correct Option: B
Explanation:

Static Linking and Static Libraries is the result of the linker making copy of all used library functions to the executable file. Static Linking creates larger binary files, and need more space on disk and main memory. Examples of static libraries (libraries which are statically linked) are, .a files in Linux and .lib files in Windows. Dynamic linking and Dynamic Libraries Dynamic Linking doesn’t require the code to be copied, it is done by just placing name of the library in the binary file. The actual linking happens when the program is run, when both the binary file and the library are in memory. Examples of Dynamic libraries (libraries which are linked at run-time) are, .so in Linux and .dll in Windows. In Dynamic Linking,the path for searching dynamic libraries is not known till runtime

The top down parsing method is also called

  1. recursive descent parsing

  2. shift reduce parsing

  3. operator precedence parsing

  4. none of the above


Correct Option: A

Which of the below is operator precedence?

  1. $\epsilon + \epsilon + \dfrac{T}{T}$

  2. $\epsilon \rightarrow \epsilon + \epsilon $

  3. $\epsilon \rightarrow T $ $T\rightarrow T + \dfrac{T}{\epsilon}$

  4. $\epsilon \rightarrow \epsilon + \dfrac{T}{T}$ $\epsilon \rightarrow \dfrac{e}{id}$ $\epsilon \rightarrow \epsilon + \dfrac{T}{T}$


Correct Option: D

A top down parser generator is

  1. right most derivation

  2. left most derivation

  3. right most derivation in reverse

  4. left most derivation in reverse


Correct Option: B

The output of lexical analyzer is

  1. machine code

  2. intermediate code

  3. a stream of tokens

  4. a parse tree


Correct Option: C
Explanation:

 The output of lexical analyzer is a stream of tokens.

Handle pruning is the technique used to obtain

  1. canonical derivation sequence

  2. canonical reduction sequence

  3. both (1) and (2) above

  4. none of the above


Correct Option: B

The language L = {ak bk |k$\ge$1} is

  1. type 3 grammar

  2. type 1 grammar

  3. type 2 grammar

  4. type 0 grammar


Correct Option: B

Which of the following is the most powerful parsing method?

  1. LL

  2. Canonical LR

  3. SLR

  4. LALR


Correct Option: B

The expression (a*b)C op….. (where ‘OP’ is one of ‘t’, ‘’ and ‘$\uparrow$’ is exponentiation) can be evaluated on a CPU with a single register without storing the value of (a*b) if

  1. ‘OP’ is ‘t’ or ‘*’

  2. ‘OP’ is ‘$\uparrow$’ or ‘t’

  3. ‘OP’ is ‘$\uparrow$’ or ‘*’

  4. not possible to evaluate without storing


Correct Option: A

Type 0 grammar is

  1. a phase structure grammar

  2. no restriction in this grammar

  3. both (1) and (2) above

  4. none of the above


Correct Option: C
- Hide questions