Compiler Design Interview Questions
- Dhirendra Nisad
- 31st Dec, 2020
- 986 Followers
Latest Interview Questions
Pratice HR Questions
Compiler Design Interview Questions
1) What is compiler?
A compiler is a software program that transforms high-level source code that is written by a developer in a high-level programming language into a low-level object code (binary code) in machine language, which can be understood by the processor. The process of converting high-level programming into machine language is known as compilation.
2) What is symbol table in compilar?
Symbol Table is an important data structure created and maintained by the compiler in order to keep track of semantics of variables i.e. it stores information about the scope and binding information about names, information about instances of various entities such as variable and function names, classes, objects, etc.
3) What are various phases of compilar?
The various phases of a compiler are:
- Lexical analysis
- Syntax analysis
- Semantic analysis
- Intermediate code generator
- Code optimizer
- Code generator
4) What is a parser?
A parser is a software component that takes input data (frequently text) and builds a data structure – often some kind of parse tree, abstract syntax tree or other hierarchical structure, giving a structural representation of the input while checking for correct syntax.
5) List some applications of compilers?
Below is the list of the basic applications of Compilers
- It helps full implementation Of High-Level Programming Languages
- Support optimization for Computer Architecture Parallelism
- Design of New Memory Hierarchies of Machines
- Widely used for Translating Programs
- Used with other Software Productivity Tools
6) What is ambigous grammer?
An ambiguous grammar is a context-free grammar for which there exists a string that can have more than one leftmost derivation or parse tree.
7) What is LR parser?
The LR parser is a non-recursive, shift-reduce, bottom-up parser. It uses a wide class of context-free grammar which makes it the most efficient syntax analysis technique. LR parsers are also known as LR(k) parsers, where L stands for left-to-right scanning of the input stream; R stands for the construction of right-most derivation in reverse, and k denotes the number of lookahead symbols to make decisions.
8) List different types of compilars?
A Compiler is used as an interface between human understandable language and machine-understandable language by transforming the former to the later.
Different types of compilers are
- Native code compiler: The compiler used to compile a source code for the same type of platform only. The output generated by this type of compiler can only be run on the same type of computer system and Os that the compiler itself runs on.
- Cross compiler: The compiler used to compile a source code for different kinds of platforms. Used in making software for embedded systems that can be used on multiple platforms.
- Source to source compiler: the compiler that takes high-level language code as input and outputs source code of another high- level language only. Unlike other compilers that convert high-level language into low-level machine language, it can take up a code written in Pascal and can transform it into a C-conversion of one high-level language into another high-level language having the same type of abstraction. Thus, it is also known as a transpiler.
- One pass compiler: It is a type of compiler that compiles the whole process in only one-pass.
- Threaded code compiler: The compiler which simply replaces a string with an appropriate binary code.
- Incremental compiler: The compiler which compiles only the changed lines from the source code and updates the object code.
- Source compiler: The compiler converts the source code high-level language code into assembly language only.
9) What is bootstrapping in compilar designing?
Bootstrapping is a process in which simple language is used to translate a more complicated program which in turn may handle the more complicated programs. This complicated program can further handle even more complicated programs and so on.
10) What is Yacc?
YACC stands for Yet Another Compiler Compiler.
It is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a Look Ahead Left-to-Right parser generator, generating a LALR parser based on a formal grammar, written in a notation similar to Backus–Naur Form. Yacc is supplied as a standard utility on BSD and AT&T Unix.
11) What is dag in compiler design?
Directed Acyclic Graph (DAG) is a tool that depicts the structure of basic blocks, helps to see the flow of values flowing among the basic blocks, and offers optimization too. DAG provides easy transformation on basic blocks. DAG can be understood here: Leaf nodes represent identifiers, names or constants.
12) List some Semantic Errors?
A semantic error is an error that occurs when a statement is syntactically valid but does not do what the programmer intended.Below are the list of some Semantic Errors
- Incompatible types of operands
- Undeclared variable
- Not matching of an actual argument with formal argument
13) What Is Code Motion?
Code motion is a technique used to decrease the amount of code in the loop. This transformation takes a statement or expression which can be moved outside the loop body without affecting the semantics of the program.
Most Popular Interview Questions
Latest MCQ Tests
Related Interview Questions