Download - Compiler Objective

Transcript

UNIT-11. Match the following :(i) Regular Grammar (a) Pushdown automaton(ii) Context free Grammar (b) Linear bounded automaton(iii) Unrestricted Grammar (c) Deterministic finite automaton(iv) Context Sensitive Grammar(d) Turing machineA(c) (a) (b) (d)B(c) (a) (d) (b)C(c) (b) (a) (dD(c) (b) (d) (a)Answer B2. For which of the following application regular expressions cannot be used?ADesigning compilersBDeveloping text editorsCSimulating sequential circuitsDAll of theseAnswer C3. The word formal in formal languages meansAThe symbols used have well defined meaningBThey are unnecessary ,in realityCOnly the form of the string of symbols is significantDNone of the aboveAnswer C4. 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.

AABBCCDDAnswer D

5. FSM can recognizeAAny grammarBOnly CFGCAny unambiguous grammarDOnly regular grammarAnswer D6. Which of the following is the most general phase structured grammar ?ARegularBContext-sensitiveCContext freeDNone of the aboveAnswer B7. For input null ,the output produced by a Mealy machine isANullBDependent on present stateCDepends on given machineDCannot decideAnswer A8. A formal grammar is a___________for rewriting strings.ASet of rulesBSet of functionsCBoth A and BDNone of the aboveAnswer A9. The language accepted by finite automata isAContext freeBRegularCNon regularDNone of theseAnswer B10. The basic limitation of a FSM is thatAIt cannot remember arbitrary large amount of informationBIt sometimes recognizes grammar that are not regularCIt sometimes fails to recognize grammars that are regularDAll of the aboveAnswer A11. A formal language theory is the discipline which studiesAFormal grammars and languagesBUnusual grammars and languagesCBoth A and BDNone of the aboveAnswer A12. Finite state machine___________recognize palindromes.ACanBCannotCMayDMay notAnswer B13. How many states can a process be in ?A2B3C4D5Answer D14. If two finite state machines are equivalent they should have the same number ofAStatesBEdgesCStates and edgesDNone of theseAnswer D15. 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 containsAn statesBn + 1 statesCn + 2 statesD2n statesAnswer B16. The following CFGSaB|bA, Aa|as|bAA, Bb|bs|aBBgenerates strings of terminals that haveAOdd number of as and odd number of bsBEven number of as and even number of bsCEqual number of as and bsDNot equal number of as and bsAnswer C17. Which of the following permanent database that has an entry for each terminal symbol ?ALiteral tableBIdentifier tableCTerminal tableDSource tableAnswer C18. The classic formalization of generative grammars first proposed byAAlexenderBBill GatesCNoam ChomskyDCharles BabbageAnswer A19. The equivalent grammar corresponding to the grammar G : SaA, ABB, BaBb| isASaA, ABB, BaBbBSa|aA, ABB, BaBb|abCSa|aA, ABB|B, BaBbDSa|aA, ABB|B, BaBb|abAnswer D20. A language L is accepted by a finite automaton if and only ifAContext freeBContext sensitiveCRecursiveDRight linearAnswer D

UNIT-21.______obtains string of tokens from lexical analyzer?Ans: parser2. 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 sentences6.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 form9.______attribute moves information up in a Parse Tree. Ans:Synthesized 10. .______attribute moves information down Parse Tree Ans.inherited11_______describes meaning of a program? Ans:semantic12.recursive descent parser is top down parser Ans.True 13.Build parse tree starting from root node to leaves is called_________Ans:Top down parsing14.Build parse tree starting from leaves to root node is called_________Ans:Bottom up parsing15______errors are discovered by lexical analyzer.Ans:Lex16. Non terminal are indicated by capital letters [T/F]Ans:T17.what are the methods to eliminate ambiguity ?Ans: Left recursive,left factoring18.____is a process of factoring the common prefixes of a grammar ruleAns: Left factoring19.In LL(1) parser L stands for _______Ans: Left to right scanning20.CFG Stands for ___________Ans: Context Free Grammer

UNIT 3

1. Context Sensitive grammars are called as _______Ans: Type 12. Context free grammars are called as _______Ans: Type 23. Unrestricted grammars are called as _______Ans: Type 04. Regular grammars are called as _______Ans: Type 35. PDA Stands _________Ans: Push Down Automata6. LBA Stands ______________Ans: Linear Bounded Automata7. A grammar is _________ if it has more than one derivation tree.Ans: Ambiguous grammar8. A grammar is _________ if it has one derivation tree.Ans: UnAmbiguous grammar9. _____________ Parsers satishfy LL GrammarsAns: TOPDOWN Parsers10. ___________ Parsers can not be used commerciallyAns: Universal Parsers11. ________________ parser is recursive descent parser that needs no back trackingAns: predictive12. Predictive parser as a procedure for every ________Ans: Grammar13. The right most derivation in reverse is obtained by ___________Ans: Handle Pruning14. Define left recursion?Ans: A -> A 15. __________ , ____________ are the types of parsing.Ans: Top down, Bottom up16. SLR Stands _________Ans: Simple LR17. CLR Stands for __________Ans: Cannonical LR18. LALR Stands for ____________Ans: LookAhead LR19. YACC Stands for ______________Ans: Yet Another Compiler Compiler20. _________ , __________ 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 Triple2. The translation of parse tree to intermediate form is ________Ans: Syntax Directed Translation3. ab * is an example of _________Ans: Postfix notation4. a*b is an example of _________Ans: infix notation5. *ab is an example of _________Ans: prefix notation6. the nodes of AST deals with______ entities. Ans: Semantics7. Tac Statements are implemented in the compiler____________ Ans: records8. ________ are pointers to tuplesAns: Indirect triples.9. ________ Graph identifies dependency of the attributes of parse treeAns: Dependency Graph10. What are the methods are used to translate the source code to intermediate codeAns: Parse tree , Bottom Up11. In ________ the global variables are storedAns: Data segment12. Global and local variables are stored in _______ Ans: Symbol Table13. ________ attribute hold the value of expressionAns: Place14. ________ attribute hold the Sequence of three address statementAns: Code15. ________ attribute hold the type of resultAns: Mode16. SDD Stands ____________Ans: Syntax Directed Definition17. TAC Stands for _______Ans: Three Address Code18. DAG Stands for ___________Ans: Directed Acyclic Graph19. Attribute of child depends on attribute of the parent node is called as _______Ans: Inherited20. 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.ALexical analysisBDiversionCModelingDNone of the aboveAnswer A2. Which of the following is used for grouping of characters into tokens?AParserBCode optimizationCCode generatorDLexical analyzerAnswer D3. The lexical analyzer takes_________as input and produces a stream of_______as output.ASource program,tokensBToken,source programCEither A and BDNone of the aboveAnswer A4. The action of parsing the source program into proper syntactic classes is calledASyntax analysisBLexical analysisCInterpretation analysisDGeneral Syntax analysisAnswer B5. Task of the lexical analysisATo parse the source program into the basic elements or tokens of the languageBTo build a literal table and an identifier tableCTo build a uniform symbol tableDAll of theseAnswer D6. The output of lexical analyzer isAA set of regular expressionsBSyntax treeCSet of tokensDStrings of characterAnswer C7. The output of a lexical analyzer isAMachine codeBIntermediate codeCA stream of tokensDA parse treeAnswer C8. Shift reduce parsers areATop down parserBBottom up parserCMay be top down or bottom up parserDNone of the aboveAnswer B9. A bottom up parser generatesARight most derivationBRight most derivation in reverseCLeft most derivationDLeft most derivation in reverseAnswer B10. Which of the following is the most powerful parser?ASLRBLALRCCanonical LRDOperator precedenceAnswer C11. Which of the following parser is most powerful?AOperator precedenceBCanonical LRCLALRDSLRAnswer B

12. A parser with the valid prefix property is advantageous because itADetects error as soon as possibleBDetects errors as and when they occurCLimits the amount of erroneous output passed to the text phaseDAll of theseAnswer C13. A grammar that produces more than one parse tree for some sentence is calledAAmbiguousBUnambiguousCRegularDNone of theseAnswer A14. In operator precedence parsing , precedence relations are defonedAFor all pair of non terminalsBFor all pair of terminalsCTo delimit the handleDOnly for a certain pair of terminalsAnswer D15. Recursive descent parsing is an exampleATop down parsingBBottom up parsingCPredictive parsingDNone of the aboveAnswer A16. ___________is a graph representation of a derivation.AThe parse treeBThe oct treeCThe binary treeDNone of the aboveAnswer A17. LR stands forALeft to rightBLeft to right reductionCRight to leftDLeft to right and right most derivation in reverseAnswer D

18. A top down parser generatesARight most derivationBRight most derivation in reverseCLeft most derivationDLeft most derivation in reverseAnswer C19. YACC builds upASLR parsing tableBCanonical LR parsing tableCLALR parsing tableDNone of the aboveAnswer C20. Any description error can be repaired byAInsertion aloneBDeletion aloneCInsertion and deletion aloneDReplacement aloneAnswer C

UNIT-6

1. Inherited attribute is a natural choice inAKeeping track of variable declarationBChecking for the correct use of L values and R valuesCBoth A and BDNone of theseAnswer A2. Syntax directed translation scheme is desirable becauseAIt is based on the syntax BIts description is independent of any implementationCIt is easy to modify DAll of theseAnswer C3. Advantage of panic mode of error recovery is thatAIt is simple ti implementBIt never gets into an infinite loopCBoth A and BDNone of theseAnswer D4. An intermediate code form isAPostfix notationBSyntax treesCThree address codeDAll of theseAnswer D5. Three address code involvesAExactly 3 addressBAt most most 3 addressCNo unary operatorsDNone of theseAnswer D6. Intermediate code generation phase gets input fromALexical analyzerBSyntax analyzerCSemantic analyzerDError handlingAnswer C7. The graph that shows basic blocks and their successor relationship is calledADAGBFlow chartCControl graphDHamiltonian graphAnswer B8. Relocating bits used by relocating loader are specified byARelocating loader itselfBLinkerCAssemblerDMacro processorAnswer B9. Which of the following can be accessed by transfer vector approach of linking?AExternal data segmentsBExternal subroutinesCData located in other procedureDAll of theseAnswer B10. Reduction in strength meansAReplacing run time computation by compile time computationBRemoving loop invariant computationCRemoving common sub expressionDReplacing a costly operation by a relatively cheaper oneAnswer A11. Scissoring enablesAA part of data to be diaplayedBEntire data to be displayedCFull data display on full area of screenDNo data to be displayedAnswer A12. Running time of a program depends onAThe way the registers and addressing modes are usedBThe order in which computations are performedCThe usage of machine idiomsDAll of theseAnswer D13. Which of the following does not interrupt a running process?AA deviceBTimerCSchedulerDPower failureAnswer D14. A grammar is meaninglessAIf terminal set and non terminal set are not disjointBIf left hand side of a production is a single terminalCIf left hand side of a production has no non terminalDAll of theseAnswer A15. Which of the following is not an intermediate code form?APostfix notationBSyntax treesCThree address codesDQuadruplesAnswer D16. The optimization technique which is typically applied on loops isARemoval of invariant computationBPeephole optimizationCConstant foldingDAll of theseAnswer D17. Whether a given pattern constitutes a token or not depends on theASource languageBTarget languageCCompilerDAll of theseAnswer C18. The optimization which avoids test at every iteration isALoop unrollingBLoop jammingCConstant foldingDNone of theseAnswer A19. We can optimize code byADead code eliminationBCommon subprogramsCCopy intermediate loopDLoop declarationAnswer A20. An optimizer compilerAIs optimized to occupy less spaceBIs optimized to take less time for executionCOptimizes the codeDNone of theseAnswer D

UNIT-7

1. Concept which can be used to identify loops isADominatorsBReducible graphsCDepth first orderingDAll of theseAnswer D2. Input to code generatorASource codeBIntermediate codeCTarget codeDAll of the aboveAnswer B3. Pee hole optimizationALoop optimizationBLocal optimizationCConstant foldingDData flow analysisAnswer C4. Code can be optimized atASource from userBTarget codeCIntermediate codeDAll of the aboveAnswer A5. Type checking is normally done duringALexical analysisBSyntax analysisCSyntax directed translationDCode optimizationAnswer C6. A compiler for a high level language that runs on one machine and produce code for different machine is calledAOptimizing compilerBOne pass compilerCCross compilerDMultipass compilerAnswer C

7. Grammar of the programming is checked at ________ phase of compiler.Asemantic analysisBcode generationCsyntax analysisDcode optimizationAnswer C8. In which way(s) a macroprocessor for assembly language can be implemented ?AIndependent two-pass processorBIndependent one-pass processorCExpand macrocalls and substitute argumentsDAll of the aboveAnswer D9. The linkerAis similar to interpreterBuses source code as its inputCis required to create a load moduleDnone of the aboveAnswer C10. Macro-processors are ______AHardwareBCompilerCRegistersDNone of the aboveAnswer B11. Macro in an assembly level program is _______.Asub programBa complete programCa hardware portionDrelative codingAnswer A12. In an absolute loading scheme which loader function is accomplished by assembler ?Are-allocationBallocationClinkingDloadingAnswer A13. Synthesized attribute can be easily simulated by aALL grammarBAmbiguous grammarCLR grammarDNone of the aboveAnswer C14. In an absolute loading scheme, which loader function is accomplished by a loader ?ARe-allocationBAllocationCLinkingDLoadingAnswer D15. A compiler that runs on one machine and produces code for a different machine is calledACross compilationBOne pass compilationCTwo pass compilationDNone of the aboveAnswer A16. Which of the following is used for grouping of characters into tokens (in a computer)AA parserBCode optimizerCCode generatorDScannerAnswer D17. Basic blocks are constructed for _______ optimizationA. LocalB. globalC. loopD. data flow analysisAnswer A18. Replacement of run-time computations by compile time computations is _____ A. elimination of common sub-expressions B. constant folding C. local optimization D. algorithm optimizationAnswer B19. Find odd man out?A. live variable analysisB. detection of common sub expressionC. minimum distance matching D. computation of values outside the blocksAnswer C20. Optimization connected with x:x+0 is A. peephole and algebraicB. Reduction in strength and algebraicC. peephole onlyD. loop and peepholeAnswer A

UNIT-8

1. The cost of instruction MUL #1,R1 isA. 2B. 3C. 1D. 6Answer A2. An address descriptor is maintained for ________A. Each name in blockB. each symbol in the programC.each register variableD. each memory variable Answer B3. Identify the odd statement in the listA. A=b+cB. b[i]=aC. a=&bD. a=b+*cAnswer Ds4. The cost of the following instruction sequence isMOV b,R0ADD c,R0MOV R0,aA. 3B. 2C. 6D. 4Answer D5. The names are mapped to storage in the machine in _______A. Symbol tablesB. runtime support systemC.stackD. extra segmentAnswer B6. Each execution of the procedure is called ________A. Control stackB. AtiviationC. SymbolD. StackAnswer B7. The _____ is used to keep track of currently active activationsA. Control stackB. ActivationC. SymbolD. StackAnswer A8. In ___ the global variables are storedA. Data segmentB. Symbol tablesC. Extra segmentD. Main memoryAnswer A9. Global and local variables are stored in _____A. Data segmentB. Symbol tablesC. Extra segmentD. Main memoryAnswer B10. The ____ attribute holds the value of the expressionA. PlaceB. CodeC. SymbolD. ModeAnswer A11. The ____ attribute holds the sequence of three address statementsA. PlaceB. CodeC. SymbolD. ModeAnswer B12. The ________ attribute indicates the type of the resultA. PlaceB. CodeC. SymbolD. ModeAnswer D13. The translation of the parse tree to intermediate form is ______A. Syntax directed translationB. Lexical analysisC. Syntax analysisD. Code generationAnswer A14. ab* is an example of ___A. postfix notationB. abstract syntax treeC. Three address codeD. NoneAnswer A15. The nodes of AST deals with _____ entities.A. SyntacticB. SemanticC. OperatorsD. OperandsAnswer B16. ________ have pointers to triplexA. TriplesB. QuadruplesC. TACD. Indirect triplesAnswer D17. Isf attributes of the child depends on the attributes of parent node then it is ____ attributes.A. TACB. SynthesizedC. InheritedD. DirectedAnswer C18. Isf attributes of the parent depends on its children then it is ____ attributes.A. TACB. SynthesizedC. InheritedD. DirectedAnswer D19. A CLR parser tries to eliminateA. Shift-reduce conflictsB. Reduce-reduce conflictsC. Shift-shift conflictsD. All types of conflictsAnswer A20. ______ parser is more powerfulA. SLRB. CLRC. LALRD. All of the aboveAnswer B

I


Top Related