SPCC viva question for engineering PDF

Title SPCC viva question for engineering
Author Kanchan Choudhary
Course Computer Engineering
Institution University of Mumbai
Pages 36
File Size 3.7 MB
File Type PDF
Total Downloads 172
Total Views 298

Summary

SPCC Viva Answers:Annotated parse treeAN ANNOTATED PARSE TREE is a parse tree showing the values of the attributesat each node. The process of computing the attribute values at the nodes is calledannotating or decorating the parse tree.Lexical errorDuring the lexical analysis phase this type of erro...


Description

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)

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

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?

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

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.

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

18. Difference between parameterized macro and conditional macro

Additional Answers: Module 1: Intro to System Software Q) Difference between Sys Program and Sys Programming

Q) Difference between System and Application Software

Q) Working order of system software

Q) Different System Softwares ● Assembler:

It converts low level language to machine code (binary)

● Loader:

● Linker:

● Macro processor:

Functions:

1. 2. 3. 4. DB: 1. 2. 3.

Recognize macro Definitions Save the definitions Recognize the calls Expand calls and substitute arguments Macro Def Table Macro Name Table Arg List Array

● Compiler:

● Interpreter:

● Editor:

● Debugger:

Q) Compiler vs Interpreter

Module 2: Assemblers

Q)Features of Assembler

Q)Different kinds of statement in assembly language

Q) what are assembler directives

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

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

Q) What are the different memory formats ?

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

● 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

Q) Explain Nested Macros

Q) Explain conditional Macros

Q) Explain Recursive Macros

Q) Implementation of Macro

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

● 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

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

● 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

Module 5: Compilers Q) What is a compiler

Q) Features of Compiler

Q) Requirements of compiler

Q) Types of Compiler

Q) Phases of Compiler

Q) Explain phases of Compilers

Q) Basic Def (lexeme token)

Q) Explain Lex and Yacc

Q) Distinguish btw Syntax tree and parser tree

21. Left recursion and left factoring

Q) Leftmost and Rightmost derivaation

Q) Top Down vs Bottom Up Parser

Q) Recursive Descent Parser

Q) Predictive Parser

Q) LL Parser

Q) LL1 grammar

Q) Shift Reduce Parser

Q) LL vs LR Parser

22. Why is LL grammar called LL1

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?

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

29. Code optimization technique any 1 (peephole)

What do you mean by code optimization?...


Similar Free PDFs