SPCC Viva Questions 2

You might also like

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

lOMoARcPSD|40292606

SPCC viva question for engineering

Computer Engineering (University of Mumbai)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by abc xyz (bhalaninaman7@gmail.com)
lOMoARcPSD|40292606

SPCC Viva Answers:


Annotated parse tree
AN ANNOTATED PARSE TREE is a parse tree showing the values of the attributes
at each node. The process of computing the attribute values at the nodes is called
annotating or decorating the parse tree.

Lexical error
During the lexical analysis phase this type of error can be detected.

Lexical error is a sequence of characters that does not match the pattern of any
token. Lexical phase error is found during the execution of the program.

Imp diagram for parser

1. Macro def table (MDT)

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

2. What is literal, symbol

Symbols- A symbol has a value and a symbol type, each of which is


either specified explicitly by an assignment statement or implicitly from
context.

3. Lexical, Syntax Analysers


Lexical Analyser:
First phase of a compiler. It is also called a scanner.
Main task: read the input characters and produce as output a sequence of tokens.
Input: program as a single string of characters. Collects characters into logical
groupings and assigns internal codes to the groupings according to their structure.
Groupings: lexemes
Internal codes: tokens
Syntax Analyser:
The syntax analyzer or parser must determine the structure of the sequence of
tokens provided to it by the scanner. Check the input program to determine whether it
is syntactically correct. Produce either a complete parse tree of at least trace the
structure of the complete parse tree.
Two categories of parsers :
Top-down: produce the parse tree, beginning at the root down to the leaves.
Bottom-up: produce the parse tree, beginning at the leaves upward to the root.
4. Operator precedence Parser

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

5. What is 1 in LL1?
The number of instructions in its look ahead that are required for parsing.

6. What is LR parser
Pg 5-119 tech knowledge
A bottom up parser which parses the grammar from left to right using rightmost
derivation in reverse direction. If LR(0) then has 0 look ahead symbols

7. What is code generation

8. What is Context Free Grammar?

9. What is an assembler?

10. What is one pass and 2 pass assembler?

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

11. What is semantic analysis?


A parser constructs parse trees in the syntax analysis phase. The plain parse-tree
constructed in that phase is generally of no use for a compiler, as it does not carry
any information of how to evaluate the tree. The productions of context-free
grammar, which makes the rules of the language, do not accommodate how to
interpret them.Semantic analysis ensures that the declarations and statements of a
program are semantically correct, i.e their meaning is clear and consistent with the
way in which control structures and data types are supposed to be used. Semantic
analyzer takes the output of syntax analyzer and produces another tree.
The semantic analyzer produces an annotated syntax tree as an output.

12. Which tables are used in pass1 and pass2 of an assembler? Databases for
pass 1 and 2

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

13. How to determine if it is a LL1 grammar?

To check if a grammar is LL(1), one option is to construct the LL(1) parsing table
and check for any conflicts. These conflicts can be

FIRST/FIRST conflicts, where two different productions would have to be


predicted for a nonterminal/terminal pair.

FIRST/FOLLOW conflicts, where two different productions are predicted, one


representing that some production should be taken and expands out to a nonzero
number of symbols, and one representing that a production should be used
indicating that some nonterminal should be ultimately expanded out to the empty
string.

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

FOLLOW/FOLLOW conflicts, where two productions indicating that a nonterminal


should ultimately be expanded to the empty string conflict with one another.

14. What is the input and output of a lexical analyser?

15. Macro mnt mdt

16. Operator precedence parser


Tech knowledge pg: 5-111
- bottom up parser
- Used to evaluate expressions with multiple operators as per their precedence
- Makes use of a precedence relation table

17. Loader

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

18. Difference between parameterized macro and conditional macro

Additional Answers:

Module 1: Intro to System Software


Q) Difference between Sys Program and Sys Programming

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Difference between System and Application Software

Q) Working order of system software

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Different System Softwares


● Assembler:

It converts low level language to machine code (binary)


● Loader:

● Linker:

● Macro processor:

Functions:

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

1. Recognize macro Definitions


2. Save the definitions
3. Recognize the calls
4. Expand calls and substitute arguments
DB:
1. Macro Def Table
2. Macro Name Table
3. Arg List Array
● Compiler:

● Interpreter:

● Editor:

● Debugger:

Q) Compiler vs Interpreter

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Module 2: Assemblers

Q)Features of Assembler

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q)Different kinds of statement in assembly language

Q) what are assembler directives

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Eg: DS/DC; EQU; END; USING++; DROP

Q) What is forward reference problem

19. Pass 1 and pass 2 of assembler


1st pass: scans code; creates literal and symbol table (LT & ST) and updates
MOT and POT
2nd pass creates Base Table; removes forward ref prob; converts code to
machine understandable code

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Format of Databases (MOT, POT, ST, LT)

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) What are the different memory formats ?

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

RS: Register and Storage Operations


SI: Storage and Immediate Operations
SS: Storage and Storage Operations

Q) Explain One pass assembler and problems faced, solution

● Forward Reference Table


● Cross Reference Table
● ST
● MOT
● Segment and Stored Segment Table

Module 3: Macros and Macro Processor


Q) Explain/Define macros and state their adv
Macro is a block of code which has been given a name; whenever it is
invoked, it is replaced by interpreter/compiler by contents of macro

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

● Freq use reduces programmer induced errors


● Makes code more readable
● Reduces chances of errors when dealing with repetitive code

Q) Functions of Macros

Q) Syntax of Macros

Q) Explain Parameterized Macros

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Explain Nested Macros

Q) Explain conditional Macros

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Explain Recursive Macros

Q) Implementation of Macro

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Data structures of Macro

Q) Difference between Macro and Functions:


● Macros avoid function call overhead and thus are faster
● Macro replaces short hand text with longer def and thus code
grows in length, function/procedures do not grow in length
even if called multiple times
● Macros can be only be used in a program they are defined
after the definition whereas subroutine can be called in same
program as well as other prog

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

● Macros can take max 9 parameters, subroutine can take any


no of params
● Macros expanded at compile time and functions expanded at
execution time
● Macros do not have a return type but function has a return
type(no return type for subroutine)
● Macro checks for no of arguments and not the type so it can
be used for multiple data types; functions check for both type
and no of params

Module 4: Linkers and Loaders


20. What is linking
It takes object modules from assembler as input and forms an executable file
as output for the loader. Two types- static and dynamic

● Loader: It is a program which accepts various object program


decks and prepares them for execution by placing them into the
main memory
● Linker: It is a program which takes collection of object modules
and combines them into a single executable program

Q) Difference between loaders and linkers

Q) Function of Loaders

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Types of Linking (Static and Dynamic)

Q) Types of Loaders

● Compile and Go: It is the loader where the assembler


compiles the program and then loads them into memory
○ Simple to implement but causes wastage of memory,
retranslates users program every time it is executed

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

● Absolute: It is a single pass loader which performs no linking


or relocation and checks for:
○ Header Record: To verify correct programs has loaded
○ Text Record: To move code to indicated memory
address
○ End Record: To jump to specific address
Bootstrap loader is part of absolute loader: stored in
non volatile memory and activates complex program
like loading OS from boot partition
● Relocating: It avoids reassembling of all subroutines when
there is change in any one subroutine. Eg: Binary Symbolic
Subroutine
● Direct Linking Loader: Most popular; makes use of 4 records;
uses 2 pass system
○ ExternalSymbolDirectives: contains info about all
symbols in prg
○ Test Records(TXT): contains info about actual object
code
○ Relocation and Linkage Directory : used to store
location and address of programs
● Dynamic Loading Loader: prevents loading of all subroutines
simultaneously into core and only loads segments which are
currently req. Thus it loads the system dynamically whenever
req.
● Dynamic Linking Loader: It retrieves the addresses of
functions and variables, executes them or use them and then
unloads it from memory
Q) Dynamic Loading vs Dynamic Linking

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Module 5: Compilers
Q) What is a compiler

Q) Features of Compiler

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Requirements of compiler

Q) Types of Compiler

Q) Phases of Compiler

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Explain phases of Compilers

Q) Basic Def (lexeme token)

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Explain Lex and Yacc

Q) Distinguish btw Syntax tree and parser tree

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

21. Left recursion and left factoring

Q) Leftmost and Rightmost derivaation

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Top Down vs Bottom Up Parser

Q) Recursive Descent Parser

Q) Predictive Parser

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) LL Parser

Q) LL1 grammar

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Q) Shift Reduce Parser

Q) LL vs LR Parser

22. Why is LL grammar called LL1

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

Ans. L -> Left to Right


L -> Leftmost Derivation
1 -> One input symbol used as a look-ahead symbol to determine parser
action
23. What is L attribute (from L and S attribute wala concept)
Sdt - syntax directed translation

24. What is LR parser?

25. What do you mean by SLR parser?

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

26. What is operator precedence parser?

Q) synthesized attr

27. Does code optimization or code generation come first?


Optimization? yes

28. Name some code optimisation techniques

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

29. Code optimization technique any 1 (peephole)

Downloaded by abc xyz (bhalaninaman7@gmail.com)


lOMoARcPSD|40292606

What do you mean by code optimization?

Downloaded by abc xyz (bhalaninaman7@gmail.com)

You might also like