The compiler is responsible for translating the code written in one language to another language without changing the meaning of the program. Moreover, it makes the target code optimized and efficient in terms of time and space. The principles of compiler design provide an in-depth view of the translation and the optimization process.
Question 1: In how many types, parsing can be categorized?
A) 2
B) 3
C) 5
D) None of these
Answer: 2
Explanation: Following are two types of parsing:
top-down parsing: starting from the highest level of the parse tree in this, we work down the parse tree.
bottom-up parsing: in this, we build the parse tree from leaves to root.
Question 2: Town down parser generates which derivation?
A) Left-most derivation in reverse
B) Left-most derivation
C) Right-most derivation
D) Right-most derivation in reverse
Answer: Left-most derivation
Explanation: Left-most derivation can be found by applying production to the leftmost variable in every step.
Question 3: Bottom up parser generates which derivation?
A) Left-most derivation in reverse
B) Left-most derivation
C) Right-most derivation
D) Right-most derivation in reverse
Answer: Right-most derivation in reverse
Explanation: Bottom-up parsing starts from the leaf nodes of the tree and works in the upward direction till it reaches the root node.
Question 4: Lexical syntax is defined by which of the following grammars?
A) Context-free Grammar
B) Lexical Grammar
C) Regular Grammar
D) None of these
Answer: Lexical Grammar
Explanation: Lexical Gammar can be defined as formal grammar that defines the syntax of tokens.
Question 5: Two adjacent non-terminals are not present in which grammar?
A) Regular grammar
B) Irregular grammar
C) Operator
D) None of these
Answer: Operator
Explanation: Operator grammar does not contain two adjacent non-terminals on the right side of the production.mathematical operators are defined by the grammar.
Question 6: Which of the following type of errors can be detected by the compiler?
A) Grammatical errors
B) Logical errors
C) Both of these
D) None of these
Answer: Grammatical errors
Explanation: Compiler is a type of computer program and it can detect the grammatical errors, not the logical errors.
Question 7: Select the compiler that runs on one machine and can generate the code for multiple machines.
A) Optimizing compiler
B) Multipass compiler
C) Cross compiler
D) None of these
Answer: Cross compiler
Explanation: Cross compiler runs on one machine and can generate the code for multiple machines.
Question 8: GETREG() function can be invoked by which of the following algorithm?
A) Code optimization algorithm
B) Code generation algorithm
C) Code motion algorithm
D) None of these
Answer: Code generation algorithm
Explanation: Code generation algorithm invokes the GETREG() function in order to check the location where the result should be stored and the status of available registers.
Question 9: Multiple loops can be merged into the single one by using which of the following method?
A) Loop fusion or jamming
B) Loop rolling
C) Constant Folding
D) None of these
Answer: Loop fusion or jamming
Explanation: Loop fusion can be defined as the technique that merges multiple bodies of loops into a single body. It reduce the runtime performance of the program.
Question 10: Which of the following technique is used in order to reduce the multiple jumps?
A) Code optimization technique
B) Peephole optimization technique
C) Latter optimization technique
D) None of these
Answer: Peephole optimization technique
Explanation: Peephole optimization technique is used in order to reduce the memory footprint and size of the code.Moreover, it also enhances the program performance.