Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

DLP VIVA Questions and Answers

1. What is Ambiguous grammar?


A CFG (Context Free Grammar) (Context free grammar is a formal grammar
which is used to generate all possible strings in a given formal language) is said to
ambiguous if there exists more than one derivation tree for the given input string i.e.,
more than one LeftMost Derivation Tree (LMDT) or RightMost Derivation Tree
(RMDT).

2. Difference between Regular expression and pattern.


Pattern matching is a type of problem where you have a pattern, and you try
to match it to a string. Regular Expressions are a way to describe a certain set of
patterns, and we can use a Regular Expression machine to solve many pattern
matching problems very quickly.

3. Difference between Error and Syntax error.


Syntax Errors occur when we violate the rules of writing the statements of the
programming language while error in general can be of different types i.e. runtime,
arithmetic, logical, etc.

4. What is pattern?
A set of strings in the input for which the same token is produced as output.
This set of strings is described by a rule called a pattern associated with the token.

5. What is linker and loader?


A linker combines one or more object files and possible some library code into
either some executable, some library or a list of error messages.
A loader reads the executable code into memory, does some address
translation and tries to run the program resulting in a running program or an error
message (or both).

6. Phase of compiler.
Lexical Analyzer, Syntax Analyzer, Semantic Analyzer, Intermediate code
generator, machine independent code optimizer, code generator and machine
dependent code optimizer.

7. Difference between parse, syntax and derivation.

8. What is LALR?
LALR parser or Look-Ahead LR parser is a simplified version of a canonical LR
parser, to parse a text according to a set of production rules specified by a formal
grammar for a computer language.

1
DLP VIVA Questions and Answers

9. What is LR in LALR?
LR means left-to-right, rightmost derivation.

10.Difference between parse and derivation tree.


They both are the same.

11.Difference between Lexemes tokens and pattern.


Tokens- Sequence of characters that have a collective meaning.
Patterns- There is a set of strings in the input for which the same token is produced as
output. This set of strings is described by a rule called a pattern associated with the
token
Lexeme- A sequence of characters in the source program that is matched by the
pattern for a token.

12.Types of intermediate code generator.


High Level Intermediate Code: High level intermediate code can be represented as
source code. To enhance performance of source code, we can easily apply code
modification. But to optimize the target machine, it is less preferred.
Low Level Intermediate Code: Low level intermediate code is close to the target
machine, which makes it suitable for register and memory allocation etc. it is used for
machine-dependent optimizations.

13.What is DAG?
The Directed Acyclic Graph (DAG) is used to represent the structure of basic
blocks, to visualize the flow of values between basic blocks, and to provide
optimization techniques in the basic block.

14.Difference between Regular expression and Context free grammar.

2
DLP VIVA Questions and Answers

15.Var1>var2, token? Lexeme? Pattern?


Token: “>”, Lexeme: “var1”,”>”,”var2”.

16.Difference between compiler and interpreter.

17.Turbo C is compiler or assembler?


Compiler

18.What is the function of a compiler?


Compiler, computer software that translates (compiles) source code written in
a high-level language (e.g., C++) into a set of machine-language instructions that can
be understood by a digital computer's CPU.

19.What is the function of an assembler?


An assembler is a program that converts the assembly language into machine
code. It takes the basic commands and operations from assembly code and converts
them into binary code that can be recognized by a specific type of processor.

20.Java contains what? (Compiler/interpreter)


Java does both compilation and interpretation, In Java, programs are not
compiled into executable files, they are compiled into bytecode, which the JVM (Java
Virtual Machine) then interprets / executes at runtime.

21.Difference between syntax and semantic.


Syntax refers to grammar, while semantics refers to meaning. Syntax is the set
of rules needed to ensure a sentence is grammatically correct, semantics is how one’s
lexicon, grammatical structure, tone, and other elements of a sentence combine to
communicate its meaning.

3
DLP VIVA Questions and Answers

22.Difference between syntax tree and parse tree.

23.What is quadruple and triples and in which phase it is used?


Quadruple: It is structure with consist of 4 fields namely op, arg1, arg2 and result. op
denotes the operator and arg1 and arg2 denotes the two operands and result is used
to store the result of the expression.
Triples: This representation doesn’t make use of extra temporary variable to
represent a single operation instead when a reference to another triple’s value is
needed, a pointer to that triple is used. So, it consist of only three fields namely op,
arg1 and arg2.
Quadruple and Triples are used in Code Optimization phase.

24.Explain token, pattern and lexemes.


Token: Token is a sequence of characters that can be treated as a single logical entity.
Typical tokens are Identifiers, keywords, operators, special symbols, and
constants.
Pattern: A set of strings in the input for which the same token is produced as output.
This set of strings is described by a rule called a pattern associated with the
token.
Lexeme: A lexeme is a sequence of characters in the source program that is matched
by the pattern for a token.

25.What is LR0 and LR1 parser?


An LR (0) parser is a shift/reduce parser that uses zero tokens of lookahead to
determine what action to take (hence the 0).
In LR (1), the parser is allowed to look at one token of lookahead when deciding
whether it should shift or reduce.

26.Code generation and optimization technique.


Loop optimization and peephole optimization.

4
DLP VIVA Questions and Answers

27.Difference between top down and bottom up parsing.

28.Difference between compiler and assembler.


The difference between compiler and assembler is that a compiler is used to
convert high-level programming language code into machine language code. On the
other hand, an assembler converts assembly level language code into machine
language code. Both these terms are relevant in context to program execution. The
compiler considers the entire code and one and converts it at the same time. Whereas,
the assembler, converts the code line by line.

29.What is shift parser?


Shift Reduce parser attempts for the construction of parse in a similar manner
as done in bottom-up parsing i.e. the parse tree is constructed from leaves (bottom)
to the root (up).

You might also like