Compiler Design Interview Questions and Answers YASH PAL, 19 March 202228 May 2024 A compiler is a program that reads a program written in one language (source language) and translates it into another language (target language). mostly the compiler is used to generate machine code. and to generate the machine code we have different phases to complete. and to study these phases we have a compiler design subject. In the technical field, we always have to deal with machine code. so it’s very important to read about the compiler design process for any technical field. so here we are including basic to advanced compiler design interview questions and answers. In analyzing the compilation of the PL/I program, the term “Machine independent optimization” is associated with the recognition of basic syntactic construction through reductions. recognition of basic elements and the creation of uniform symbols. creation of more optimal matrix use of the macro processor to produce more optimal assembly code Answer – (3) creation of the more optimal matrix In analyzing the compilation of the PL/I program the description “resolving symbolic address (labels) and generating machine language” is associated with assembly and output code generation storage assignment syntax analysis Answer – (1) assembly and output In analyzing the compilation of the PL/I program the description “creation of more optimal matrix” is associated with assembly and output code generation syntax analysis machine-independent optimization Answer – (4) machine-independent optimization Which one is not true about syntax and semantic parts of a computer language The syntax is generally checked by the programmer. Semantics is the responsibility of the programmer. Semantics is checked mechanically by a computer. Both (b) and (c) above Answer – (4) Both (b) and (c) above Left factoring is the process of factoring out the common prefixed of alternates suffixes of alternates predictive parsing none of the above Answer – (4) None of the above In analyzing the compilation of the PL/I program, the term “lexical analysis” is associated with the recognition of basic syntactic constructs through reductions. recognition of basic elements and the creation of uniform symbols. creation of a more optimal matrix. use of the macro processors to produce more optimal assembly code. Answer – (2) recognition of basic elements and the creation of uniform symbols Operator-precedence parsing method is a parsing method. Which of the following statement is false about it? It is a bottom-up parsing methodIt must contain e-production.It doesn’t contain two adjacent nonterminal symbols. 1 only 2 only 3 only 1 and 3 only Answer – (2) 2 only If conversion from one type to another type is done automatically by the compiler then, it is called implicit conversion coercions both (a) and (b) none of the above Answer – (3) both (a) and (b) The term “environment” in programming language semantics is said as a function that maps a name to a value held there a function that maps a name to a storage location the function that maps a storage location to the value held there none of the above Answer – (2) a function that maps a name to a storage location A nonrelocatable program is one which cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation. consists of a program and relevant information for its relocation can itself perform the relocation of its address-sensitive portions? all of the above. Answer – (1) cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation A self-relocating program is one which cannot be made to execute in any area of storage other than the one designated for it at the time of its coding or translation. consists of a program and relevant information for its relocation. can itself perform the relocation of its address-sensitive portions all of the above Answer – (3) can itself perform the relocation of its address-sensitive portions The linker is the same as a loader is required to create a load module user source code as input is always used before programs are executed Answer – (1) is the same as a loader The translator is best described as application software a system software a hardware component all of the above Answer – (2) a system software Resolution is externally defined symbols performed by Linker Loader Compiler Assembler Answer – (1) Linker Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left-to-right order. Leftmost derivation Leftmost derivation traced out in reverse Rightmost derivation Rightmost derivation traced out in reverse Answer – (1) Leftmost derivation A simple two-pass assembler does which of the following in the first pass? It allocates space for the literal.It computes the total length of the program.It builds the symbol table for the symbols and their values.It generates code for all the loads and stores register instructions. 1 only 1 and 2 1, 2 and 3 4 only Answer – (3) 1, 2 and 3 The generation of intermediate code based on an abstract machine model is useful in compilers because it makes the implementation of lexical analysis and syntax analysis easier syntax-directed translation can be written for intermediate code generation. it enhances the portability of the front end of the compiler. it is not possible to generate code for real machines directly from high-level language programs. Answer – (2) syntax-directed translation can be written for intermediate code generation A compiler is A program that places programs into memory and prepares them for execution a program that automates the translation of assembly language into machine language a program that accepts a program written in a high-level language and produces an object program a program that appears to execute a source program as if it were machine language Answer – (3) a program that accepts a program written in a high-level language and produces an object program A loader is a program that places programs into memory and prepares them for execution a program that automates the translation of assembly language into machine language a program that accepts a program written in a high-level language and produces an object program a program that appears to execute a source program as if it were machine language Answer – (1) a program that places programs into memory and prepares them for execution Which of the following are language processors? assembler compilers interpreters all of these Answer – (1) assembler Note – More questions and answers will be added from time to time. Compiler Design Tutorials Computer Science Tutorials Interview questions answers computer scienceinterview preparation