You are on page 1of 6

Viva-Voce Questions 1. 2. 3. 4. 5. What is lexical analyzer? Which compiler is used for lexical analyzer? What is YACC?

What is the output of Lexical analyzer? What is LEX source Program?

1. What is Parsing? 2. Construct the parsing table for the given? S1 iC+SS1|a S1 eS1| C b 3. What is Token? 4. What is Jlex? 5. What is Flex?

1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 1. 2. 3. 4. 5.

What is Predictive parser? How many types of analysis can we do using Parser? What is Recursive Decent Parser? How many types of Parsers are there? What is LR Parser? What is LALR parsing? What is Shift reduced parser? What is the operations of Parser? What is the use of parsing table? What is bottom up parsing? What is Abstract Syntax tree? What are BNF Rules? What is DAG representation? How LALR(1) states are generates? In which condition the user has to supply more information to YACC? What is target code? What is machine code? What is Cross compiler? Give the example for cross compiler? What is the difference between syntax & Semantics?

1. Can you differentiate between syntax analysis and semantic analysis during compiler design? 2. In simple words, what shall be the basic difference between top-down and bottom-up parsing?

3. Can you say something about type checking and its importance? 4. What is the need for Symbol Table? 5. What is the fundamental difference between a compiler and an Interpreter? 6. Which of the two linker, loader is essential in a microcomputer? Can you justify your answer? 7. How is Code optimization done using DAG? 1. (a) What are some advantages of high level languages over assembly languages? (b) What are the major stages in the process of compilation? 2. Suppose in a programming language the word if is reserved keyword, and all other strings of alphabetic characters are identifiers. Draw a transition diagram for recognizing these two classes of words. Represent the transition diagram in the form of a transition table. 3. What does parsing mean in the context of compilers? 5. (a) What do you understand by ambiguity of a grammar? (b) Using a small example briefly explain ambiguous grammar. If the ambiguity is removed by rewriting the grammar, will the unambiguous grammar recognize exactly the same language as the ambiguous grammar? (c) What do you understand by left-recursion and left-factoring? How are they relevant in top-down parsing? 6. How does left recursion create problem in top down parsing. Explain with a small example. How would you eliminate left recursion in the grammar S -> S,i | i ? 7. (a) Briefly describe the algorithm of predictive parsing? How is the use of stack in top-down different from that in bottom-up parsing? (b) Briefly describe the method of recursive descent parsing. 9. Consider the following grammar G where E is the start symbolE -> E + T | T T -> T * F | F F -> ( E ) | id

(a) Is G un-ambiguous? Why? (b) Why is G not suitable for recursive descent parsing? Rewrite G as G' to make it suitable. (c) Compute FIRST and FOLLOW for each non-terminal of G'. (d) Construct the predictive parsing table for the grammar G'. (e) Why or why not is the grammar G' LL(1)? 10. Consider the following grammar where S is the start symbol: S -> ictSeS | ictS | a (a) Compute FIRST & FOLLOW for each non-terminal of the above grammar. (b) Construct the predictive parsing table for the grammar. (c) Is the grammar LL(1)? Why? 11. Why is it sometimes useful to use an ambiguous grammar for parsing instead of a rewriting the grammar to remove ambiguity? How is it possible to ambiguous grammar for parsing? 12. What is the difference between error detection and error recovery? Describe a simple method for error recovery for syntax errors. 13. What are some of the errors that a compiler should detect? What course of action should the compiler take when it detects an error? 14. Why is a symbol table used by a compiler? Give a possible format of a symbol table record used by a compiler and state why you would use either an array, a hash table, or any other data structure to keep these records. 15. Describe a scheme to create a symbol table for processing programs in a block-structured language in multiple passes. 16. Explain the Role of the Lexical Analyzer? 17. What is compiler? Explain the Phase of the Compiler. 18. Explain the Different Cousins of the compilers. 19. Write the Lexical Analyzer for 1. Key Words(if, Then, Begin, End, else) 2. Relational Operators 3. Identifiers and Numbers(Integer and Float) 20. Construct the sets of LR(0) and the SLR parsing table for the grammar

F -> id ( P ); P -> P & id | id 21. Write the C program statement to define the data structures for storing a grammar given in BNF, and to represent LR(0) items. 22. Consider the following grammar where S is the start symbol: S -> ictSeS | ictS | a (a) Compute FOLLOW for each non-terminal of the above grammar. (b) Construct the canonical collection of LR(0) items for the grammar. (c) Is the grammar SLR(1)? Why? 23. What are shift-reduce and reduce-reduce conflicts? 24. Construct the set of LR(0) items for the grammar given below and construct the SLR parsing table for it. Is the grammar LR(0) ? T -> B | { L } L -> T L | B B -> a | b (b) Depict the parsing action (stack content, remaining input, action) sequence of the above parser for the input string - { a { b a } } 25. Consider the grammarS -> i c t { S } e S | i c t S | a = a P a P -> + | * (a) List all the LR(0) item sets for the grammar. (b) Construct the SLR(1) parsing table. (c) Is the grammar SLR(1)? Is the grammar unambiguous? 26. (a) How is canonical LR parsing different from LALR parsing? (b) What is yacc? 27. How is canonical LR parsing method different from SLR parsing? What would you say about their respective language recognition power? 28. What does the UNIX utility YACC do ? What is the essential part (that must be present) in the input to YACC? 29. What do you understand by ambiguity of a grammar? 30. Why is it sometimes useful to use an ambiguous grammar for parsing instead of a rewriting the grammar to remove ambiguity? How is it possible to ambiguous grammar for parsing?

31. What is the difference between error detection and error recovery? Describe a simple method for error recovery for syntax errors. 32. What are some of the errors that a compiler should detect? What course of action should the compiler take when it detects an error? 33. (a) Present a suitable format for Intermediate Code that may be generated by a compiler. Using that format express the following source code segment in the intermediate code form x = a + 30 * 6; y = square( x ); (b) Briefly describe the different types of storage requirements of a program and how a compiler may handle each of these requirements. 34. Write the outline of the semantic actions for translation that may be associated with the production for the common if-construct S -> iCtSeS Why may we rewrite the production to incorporate the semantic actions? 35. What is syntax directed translation? (b) Using a simple example, show the need for back patching during intermediate code generation by syntax directed translation. 37. (a) What does a compiler do to facilitate linking? (b) Why do programming languages provide the macro feature despite the procedure call mechanism ? What do you understand by conditional expansion during macro processing? 38. Why is a symbol table used by a compiler ? Give a possible format of a symbol table record used by a compiler and state why you would use either an array, a hash table, or any other data structure to keep these records. 39. Describe a scheme to create a symbol table for processing programs in a block-structured language in multiple passes.

40. In a block-structured language, when there are multiple symbols with the same string, how can hashing be used to locate the appropriate symbol table record for a particular symbol? Describe using block diagram. 41. (a) What is an activation record and why is it used ? Why are activation records maintained in a stack ? (b) What does an activation record contain? What kind of program data is allocated in an activation record? Why is indirection used for some data objects in the activation record? + 42. Why is code optimization done by compilers but not by assemblers ? 43. What are some of the optimisations that can be performed by a compiler ? Which kind of optimisation is more effective inside loops space optimisation or time optimisation ? Why (b) What is a Directed Acyclic Graph and what are its uses? 45. (a) What do the register descriptor contain? How are these useful in code generation? (b) Give an example to show how reordering of intermediate code statements can improve code generation.

You might also like