Sei sulla pagina 1di 26

UNIT-1

1. Match the following : (i) Regular Grammar (ii) Context free Grammar (iii) Unrestricted Grammar (a) Pushdown automaton (b) Linear bounded automaton (c) Deterministic finite automaton

(iv) Context Sensitive Grammar(d) Turing machine A C (c) (a) (b) (d) (c) (b) (a) (d B D (c) (a) (d) (b) (c) (b) (d) (a)

Answer B 2. For which of the following application regular expressions cannot be used? A C Designing compilers Simulating sequential circuits B D Developing text editors All of these

Answer C 3. The word formal in formal languages means A B C D The symbols used have well defined meaning They are unnecessary ,in reality Only the form of the string of symbols is significant None of the above

Answer C 4. Consider the set of strings on {0,1} in which, every substring of 3 symbols has at most two zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below.

A C

A C

B D

B D

Answer D

5. FSM can recognize A C Any grammar Any unambiguous grammar B D Only CFG Only regular grammar

Answer D 6. Which of the following is the most general phase structured grammar ? A C Regular Context free B D Context-sensitive None of the above

Answer B 7. For input null ,the output produced by a Mealy machine is A C Null Depends on given machine B D Dependent on present state Cannot decide

Answer A 8. A formal grammar is a___________for rewriting strings. A C Set of rules Both A and B B D Set of functions None of the above

Answer A 9. The language accepted by finite automata is A C Context free Non regular B D Regular None of these

Answer B 10. The basic limitation of a FSM is that A B It cannot remember arbitrary large amount of information It sometimes recognizes grammar that are not regular

C D

It sometimes fails to recognize grammars that are regular All of the above

Answer A 11. A formal language theory is the discipline which studies A C Formal grammars and languages Both A and B B D Unusual grammars and languages None of the above

Answer A 12. Finite state machine___________recognize palindromes. A C Can May B D Cannot May not

Answer B 13. How many states can a process be in ? A C 2 4 B D 3 5

Answer D 14. If two finite state machines are equivalent they should have the same number of A C States States and edges B D Edges None of these

Answer D 15. Consider the regular expression (a + b) (a + b) (a + b) (n-times). The minimum number of states in finite automaton that recognizes the language represented by this regular expression contains A C n states n + 2 states B D n + 1 states 2n states

Answer B 16. The following CFG

SaB|bA, Aa|as|bAA, Bb|bs|aBB generates strings of terminals that have A B C D Odd number of as and odd number of bs Even number of as and even number of bs Equal number of as and bs Not equal number of as and bs

Answer C 17. Which of the following permanent database that has an entry for each terminal symbol ? A C Literal table Terminal table B D Identifier table Source table

Answer C 18. The classic formalization of generative grammars first proposed by A C Alexender Noam Chomsky B D Bill Gates Charles Babbage

Answer A 19. The equivalent grammar corresponding to the grammar G : SaA, ABB, BaBb| is A C SaA, ABB, BaBb Sa|aA, ABB|B, BaBb B D Sa|aA, ABB, BaBb|ab Sa|aA, ABB|B, BaBb|ab

Answer D 20. A language L is accepted by a finite automaton if and only if A C Context free Recursive B D Context sensitive Right linear

Answer D

UNIT-2
1.______obtains string of tokens from lexical analyzer? Ans: parser 2. BNF stands for____________ Ans. Backus naur form. 3.. Define syntax? Ans. It is a directed graph. Used to represent the information present in BNF. 4. Define parse tree? Ans. the hierarchicall representation of sentences of a languages. 5. Define Derivation? Ans. the process of generating sentences 6.Define Grammer? Ans.Set of rules 7.Define Ambiguous Grammer? Ans: a grammer produce 2 or more parse Trees 8.String used in the derivation are called _________ Ans:Sentential form 9.______attribute moves information up in a Parse Tree. Ans:Synthesized 10. .______attribute moves information down Parse Tree Ans.inherited

11_______describes meaning of a program? Ans:semantic 12.recursive descent parser is top down parser Ans.True 13.Build parse tree starting from root node to leaves is called_________ Ans:Top down parsing 14.Build parse tree starting from leaves to root node is called_________ Ans:Bottom up parsing 15______errors are discovered by lexical analyzer. Ans:Lex 16. Non terminal are indicated by capital letters [T/F] Ans:T 17.what are the methods to eliminate ambiguity ? Ans: Left recursive,left factoring 18.____is a process of factoring the common prefixes of a grammar rule Ans: Left factoring 19.In LL(1) parser L stands for _______ Ans: Left to right scanning 20.CFG Stands for ___________ Ans: Context Free Grammer

UNIT 3

1. Context Sensitive grammars are called as _______ Ans: Type 1 2. Context free grammars are called as _______ Ans: Type 2 3. Unrestricted grammars are called as _______ Ans: Type 0 4. Regular grammars are called as _______ Ans: Type 3 5. PDA Stands _________ Ans: Push Down Automata 6. LBA Stands ______________ Ans: Linear Bounded Automata 7. A grammar is _________ if it has more than one derivation tree. Ans: Ambiguous grammar 8. A grammar is _________ if it has one derivation tree. UnAmbiguous grammar 9. _____________ Parsers satishfy LL Grammars Ans: TOPDOWN Parsers 10. ___________ Parsers can not be used commercially Ans: Universal Parsers 11. ________________ parser is recursive descent parser that needs no back tracking Ans: predictive 12. Predictive parser as a procedure for every ________ Ans: Grammar 13. The right most derivation in reverse is obtained by ___________ Ans: Handle Pruning Ans:

14. Define left recursion? Ans: A -> A 15. __________ , ____________ are the types of parsing. Ans: Top down, Bottom up 16. SLR Stands _________ Ans: Simple LR 17. CLR Stands for __________ Ans: Cannonical LR 18. LALR Stands for ____________ Ans: LookAhead LR 19. YACC Stands for ______________ Ans: Yet Another Compiler Compiler 20. _________ , __________ are data structures of Shift Reduce Parser. Ans: Stack, Input Buffer

UNIT-4

1. What are the 3 common implementations for TAC? Ans: Quadruple, Triple, Indirect Triple 2. The translation of parse tree to intermediate form is ________ Ans: Syntax Directed Translation 3. ab * is an example of _________ Ans: Postfix notation 4. a*b is an example of _________ Ans: infix notation 5. *ab is an example of _________ Ans: prefix notation 6. the nodes of AST deals with______ entities.

Ans: Semantics 7. Tac Statements are implemented in the compiler____________ Ans: records 8. ________ are pointers to tuples Ans: Indirect triples. 9. ________ Graph identifies dependency of the attributes of parse tree Ans: Dependency Graph 10. What are the methods are used to translate the source code to intermediate code Ans: Parse tree , Bottom Up 11. In ________ the global variables are stored Ans: Data segment 12. Global and local variables are stored in _______ Ans: Symbol Table 13. ________ attribute hold the value of expression Ans: Place 14. ________ attribute hold the Sequence of three address statement Ans: Code 15. ________ attribute hold the type of result Ans: Mode 16. SDD Stands ____________ Ans: Syntax Directed Definition 17. TAC Stands for _______ Ans: Three Address Code 18. DAG Stands for ___________ Ans: Directed Acyclic Graph 19. Attribute of child depends on attribute of the parent node is called as _______ Ans: Inherited 20. Attribute of Parent depends on attribute of the Child node is called as _______ Ans: Synthesized

UNIT-5

1. _________or scanning is the process where the stream of characters making up the source program is read from left to right and grouped into tokens. A C Lexical analysis Modeling D B Diversion

None of the above

Answer A 2. Which of the following is used for grouping of characters into tokens? A C Parser Code generator B Code optimization D Lexical analyzer

Answer D 3. The lexical analyzer takes_________as input and produces a stream of_______as output. A C Source program,tokens Either A and B B D Token,source program None of the above

Answer A 4. The action of parsing the source program into proper syntactic classes is called A C Syntax analysis Interpretation analysis D B Lexical analysis

General Syntax analysis

Answer B 5. Task of the lexical analysis A B C To parse the source program into the basic elements or tokens of the language To build a literal table and an identifier table To build a uniform symbol table

All of these

Answer D 6. The output of lexical analyzer is A C A set of regular expressions Set of tokens B D Syntax tree Strings of character

Answer C 7. The output of a lexical analyzer is A C Machine code A stream of tokens B D Intermediate code A parse tree

Answer C 8. Shift reduce parsers are A C Top down parser May be top down or bottom up parser B Bottom up parser D None of the above

Answer B 9. A bottom up parser generates A C Right most derivation Left most derivation B D Right most derivation in reverse Left most derivation in reverse

Answer B 10. Which of the following is the most powerful parser? A C SLR Canonical LR B D LALR Operator precedence

Answer C 11. Which of the following parser is most powerful? A C Operator precedence LALR B D Canonical LR SLR

Answer B

12. A parser with the valid prefix property is advantageous because it A Detects error as soon as possible occur B Detects errors as and when they

C Limits the amount of erroneous output passed to the text phase these Answer C 13. A grammar that produces more than one parse tree for some sentence is called A C Ambiguous Regular B Unambiguous D None of these

All of

Answer A 14. In operator precedence parsing , precedence relations are defoned A C For all pair of non terminals To delimit the handle B D For all pair of terminals Only for a certain pair of terminals

Answer D 15. Recursive descent parsing is an example A C Top down parsing Predictive parsing B D Bottom up parsing None of the above

Answer A 16. ___________is a graph representation of a derivation. A C The parse tree The binary tree B The oct tree D None of the above

Answer A 17. LR stands for A Left to right B Left to right reduction

C Right to left reverse Answer D

Left to right and right most derivation in

18. A top down parser generates A C Right most derivation Left most derivation B D Right most derivation in reverse Left most derivation in reverse

Answer C 19. YACC builds up A C SLR parsing table LALR parsing table B D Canonical LR parsing table None of the above

Answer C 20. Any description error can be repaired by A C Insertion alone Insertion and deletion alone B D Deletion alone Replacement alone

Answer C

UNIT-6

1. Inherited attribute is a natural choice in A B C D Keeping track of variable declaration Checking for the correct use of L values and R values Both A and B None of these

Answer A 2. Syntax directed translation scheme is desirable because A C It is based on the syntax It is easy to modify B Its description is independent of any implementation D All of these

Answer C 3. Advantage of panic mode of error recovery is that A C It is simple ti implement Both A and B D B It never gets into an infinite loop

None of these

Answer D 4. An intermediate code form is A C Postfix notation Three address code B D Syntax trees All of these

Answer D 5. Three address code involves A C Exactly 3 address No unary operators B D At most most 3 address None of these

Answer D

6. Intermediate code generation phase gets input from A C Lexical analyzer Semantic analyzer D B Syntax analyzer

Error handling

Answer C 7. The graph that shows basic blocks and their successor relationship is called A C DAG Control graph B D Flow chart Hamiltonian graph

Answer B 8. Relocating bits used by relocating loader are specified by A C Relocating loader itself Assembler D B Linker

Macro processor

Answer B 9. Which of the following can be accessed by transfer vector approach of linking? A C External data segments Data located in other procedure B D External subroutines All of these

Answer B 10. Reduction in strength means A B C D Replacing run time computation by compile time computation Removing loop invariant computation Removing common sub expression Replacing a costly operation by a relatively cheaper one

Answer A 11. Scissoring enables A C A part of data to be diaplayed B Entire data to be displayed D No data to be displayed

Full data display on full area of screen

Answer A 12. Running time of a program depends on A B C D The way the registers and addressing modes are used The order in which computations are performed The usage of machine idioms All of these

Answer D 13. Which of the following does not interrupt a running process? A C A device Scheduler B D Timer Power failure

Answer D 14. A grammar is meaningless A B C D If terminal set and non terminal set are not disjoint If left hand side of a production is a single terminal If left hand side of a production has no non terminal All of these

Answer A 15. Which of the following is not an intermediate code form? A C Postfix notation Three address codes D B Syntax trees

Quadruples

Answer D 16. The optimization technique which is typically applied on loops is A C Removal of invariant computation Constant folding B D Peephole optimization All of these

Answer D

17. Whether a given pattern constitutes a token or not depends on the A C Source language Compiler B D Target language All of these

Answer C 18. The optimization which avoids test at every iteration is A C Loop unrolling Constant folding D B Loop jamming

None of these

Answer A 19. We can optimize code by A C Dead code elimination Copy intermediate loop B D Common subprograms Loop declaration

Answer A 20. An optimizer compiler A C Is optimized to occupy less space Optimizes the code B D Is optimized to take less time for execution None of these

Answer D

UNIT-7
1. Concept which can be used to identify loops is A C Dominators Depth first ordering B D Reducible graphs All of these

Answer D 2. Input to code generator A C Source code Target code B D Intermediate code All of the above

Answer B 3. Pee hole optimization A C Loop optimization Constant folding B D Local optimization Data flow analysis

Answer C 4. Code can be optimized at A C Source from user Intermediate code B D Target code All of the above

Answer A 5. Type checking is normally done during A C Lexical analysis Syntax directed translation D B Syntax analysis

Code optimization

Answer C 6. A compiler for a high level language that runs on one machine and produce code for different machine is called

A C

Optimizing compiler Cross compiler

One pass compiler D Multipass compiler

Answer C

7. Grammar of the programming is checked at ________ phase of compiler. A C semantic analysis syntax analysis B code generation D code optimization

Answer C 8. In which way(s) a macroprocessor for assembly language can be implemented ? A B C D Independent two-pass processor Independent one-pass processor Expand macrocalls and substitute arguments All of the above

Answer D 9. The linker A B C D is similar to interpreter uses source code as its input is required to create a load module none of the above

Answer C 10. Macro-processors are ______ A B C D Hardware Compiler Registers None of the above

Answer B 11. Macro in an assembly level program is _______. A B C D sub program a complete program a hardware portion relative coding

Answer A 12. In an absolute loading scheme which loader function is accomplished by assembler ? A B C D re-allocation allocation linking loading

Answer A 13. Synthesized attribute can be easily simulated by a A B C D LL grammar Ambiguous grammar LR grammar None of the above

Answer C 14. In an absolute loading scheme, which loader function is accomplished by a loader ? A B C D Re-allocation Allocation Linking Loading

Answer D

15. A compiler that runs on one machine and produces code for a different machine is called A B C D Cross compilation One pass compilation Two pass compilation None of the above

Answer A 16. Which of the following is used for grouping of characters into tokens (in a computer) A B C D A parser Code optimizer Code generator Scanner

Answer D 17. Basic blocks are constructed for _______ optimization A. Local Answer A 18. Replacement of run-time computations by compile time computations is _____ A. elimination of common sub-expressions B. constant folding C. local optimization D. algorithm optimization Answer B 19. Find odd man out? A. live variable analysis B. detection of common sub expression B. global C. loop D. data flow analysis

C. minimum distance matching D. computation of values outside the blocks Answer C

20. Optimization connected with x:x+0 is A. peephole and algebraic B. Reduction in strength and algebraic C. peephole only D. loop and peephole Answer A

UNIT-8
1. The cost of instruction MUL #1,R1 is A. 2 B. 3 C. 1 Answer A 2. An address descriptor is maintained for ________ A. Each name in block B. each symbol in the program C.each register variable Answer B 3. Identify the odd statement in the list A. A=b+c B. b[i]=a C. a=&b Answer Ds 4. The cost of the following instruction sequence is MOV b,R0 ADD c,R0 MOV R0,a A. 3 B. 2 C. 6 D. 4 Answer D 5. The names are mapped to storage in the machine in _______ A. Symbol tables B. runtime support system D. each memory variable

D. 6

D. a=b+*c

C.stack Answer B

D. extra segment

6. Each execution of the procedure is called ________ A. Control stack B. Ativiation C. Symbol D. Stack Answer B 7. The _____ is used to keep track of currently active activations A. Control stack B. Activation C. Symbol D. Stack Answer A 8. In A. B. C. D. ___ the global variables are stored Data segment Symbol tables Extra segment Main memory

Answer A 9. Global and local variables are stored in _____ A. Data segment B. Symbol tables C. Extra segment D. Main memory Answer B 10. The ____ attribute holds the value of the expression A. Place B. Code C. Symbol D. Mode Answer A 11. The ____ attribute holds the sequence of three address statements

A. B. C. D.

Place Code Symbol Mode

Answer B 12. The ________ attribute indicates the type of the result A. Place B. Code C. Symbol D. Mode Answer D 13. The translation of the parse tree to intermediate form is ______ A. Syntax directed translation B. Lexical analysis C. Syntax analysis D. Code generation Answer A 14. ab* is an example of ___ A. postfix notation B. abstract syntax tree C. Three address code D. None Answer A 15. The nodes of AST deals with _____ entities. A. Syntactic B. Semantic C. Operators D. Operands Answer B 16. ________ have pointers to triplex A. Triples B. Quadruples C. TAC D. Indirect triples

Answer D 17. Isf attributes of the child depends on the attributes of parent node then it is ____ attributes. A. TAC B. Synthesized C. Inherited D. Directed Answer C 18. Isf attributes of the parent depends on its children then it is ____ attributes. A. TAC B. Synthesized C. Inherited D. Directed Answer D 19. A CLR parser tries to eliminate A. Shift-reduce conflicts B. Reduce-reduce conflicts C. Shift-shift conflicts D. All types of conflicts Answer A 20. ______ parser is more powerful A. SLR B. CLR C. LALR D. All of the above Answer B

Potrebbero piacerti anche