0% found this document useful (0 votes)
34 views5 pages

Compiler Construction

Compiler construction. Learning NDF DFA

Uploaded by

HOME OF TRADERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

Compiler Construction

Compiler construction. Learning NDF DFA

Uploaded by

HOME OF TRADERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
Y ABA COLLEGE OF TECHNOLOGY { SCHOOL OF TECHNOLOGY COMPUTER TECHNOLOGY DEPARTMENT - 2022/2023 SESSION FIRST SEMESTER (FULL TIME) EXAMINATION I CLASS: HND Il (Computer Science) Time Allowed: 3:90 Hours” | | Paper Code: COM 414 Title: Compiler Construction | | INSTRUCTION: There should be no jotting, writing or any inscription on the question paper, except the candidate's name and registration number where applicable. It is exam malpractice to bring phone — | into the examination venue. “ATTEMPT QUESTIONS 3,5 AND ANY OTHER THREE QUESTIONS | QUBSTION ONE ' | (@) Describe the compilation process | () Briefly describe the various types of translators | © Highlight any Five () good qualities of a compiler | | QUESTION TWO |. a) Enumerate the components that make up the syntax of a grammar b) List and describe the types of grammars ©) Given the grammar G with following production rules j S-a | aS | bS, : | Determine whether the following strings can be generated, the grammar E |. i) babaab y | i) aaabbbab : ‘ () Ina compiler, keywords of a languagje'are recognized during (A) _ parsing of the program ».;(B) the code generation (©) the lexical analysisofthe program | (D) _ data-flow analysi | (i) The lexical analysis for'a mddern computer language such as Java needs the power of | i | | ( | QUESTION THREE which one of the fSllwing machine models is necessary and sufficient sense (A); Finite stdte automata (B) Deterministic pushdown automata | | (© | Non-Détérministic pushdown automata (0) Tanne Mate | 8). How many tokens willbe generated bythe scanner fof the following statemen? @b 2 @® 1 fG.10. Onade |. Gv) Whiff Bitise‘of compiler generates stream of atoms? { posSyntax Analysis (B) Lexical Analysis (“Code Generation (D) Code Optimization | ty \Wwhith data structure in a-compiler is used for managing information about variables and j ~“ their attributes? (A) Abstract syntax tree (B) Symbol tree. | | (©) Semantic stack (D) Symbol table | | vi) Symbol table can be used for: “ { (A) Checking type compatibility a | (B) Suppressing duplication of error message (C) Storage allocation (D) Alllof these { \ (A) parsing of the program {B) the code generation | (i) Ina compiler, keywords of a language are recognized during 1 Page 1 0f 5 | [ (©) the lexical analysis of the program (D)_ data flow analysis (vii) Consider the following statements: (Q). The output of a lexical analyzer is groups of characters. (Q) Total number of tokens in printf("ir%d,4i=%x",iéei); arel. (HD _ Symbol table can be implemented by using array and hash table but not tree. Which of the above staterent(s) is/are correct? (A) Only) @) Only(jand() (©) AN(),(M1),and(l) (D) None of these (&) Consider the grammar defined by the following production rules, with two operators +and + S->T*P Fe>u| TU P->Q+P|Q / - Q-> ld | U->ld + ‘ | Which one of the following is TRUE? | (A) _ +is left associative, while «is right associative (B) + is right associative, while tis left associative eS (©) Both +and sare right associative : (D) Both + and sare left associative ‘ (x) The grammar A> AA | (A) | €is not suitable for predictive-parsing because the grammar is? (A) ambiguous (B)__left-recursive(Ch.\ riglit-recursive (D)- Aand B (xi) Whatis the output of the lexical analyser? (A) aparse tree (B) list of tokens (C)/ihtertiediate code (D) machine code }) The action of parsing the source program inte proper syntactic classes is called (A) General syntax analysis (B) Interpretation analysis (©) Syntax analysis (D) Lexical'analysis : ) A compiler which allows only the modified section of the source code to be recompiled is called (A) Subjective compiter (8) Dynamic compiler (CY Re-configurable compiler (D) Incremental compiler aco | (xiv) A top-down parser generates : | | (A) Left-most derivation in reverse (B) Left-most derivation | (C) Right-most derivation in reverse (D) Right -most derivation | (xv) The most general phase structured grammar (A) Context sensitive (B) Context free (C) Regular (D) None of these (xvi) Which of the following class of statement usually produces no executable code i when compiled? ‘ (A) Assignment statement (B) Structural statements (C) Input and output statements (D) Declaration (xvii) Interpreter is preferred over a compiler is (A) During program development phase . (B) When storage space is to be minimized Page 2 of 5 (C) When efficient use of computer resources is the consideration (D) All of these Which of the following is used for grouping of characters into tokens? (A) Scanner (B) Code generator (©) Code optimizer () Parser | (xix) _____ is considered as a sequence of characters in a token. | (A) Pattern (B) Texeme (C) Lexeme (D) Mexeme | 60) —_ 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) Modeting (B) Diversion | (C) Lexical analysis (D) All of these { & | beciell r | QUESTION FOUR | @) Describe briefly the formal definition of context free grammed | (b) Define each of the following terminologies: 2 | 1 (i) Derivation (ii) Leftmost Derivation (iii) Rightmost Derivation (iv) Parse Tree 2 , | © Explain the following types of errors in compiler. 1 @ Lexical error (i) Syntax error 5 | Gil) Semantic error (iv) Logical error e | QUESTION FIVE ( {| @ | Choose from letter options A-D, the one which bgt ‘answered questions 1 - 20 | ki | @ __Which is the correct NFA for the following mentioned expression? (ab)* | (a f | | Pot C I | ‘d) None of the mentioned } | | if | | (i) A System program that combines separately compiled modules of a program into | i | | | form suitable for execution is a) Assembler_b) Linking loader c) Cross compiler d) None of the mentioned ii) A compiler for a high-level language that runs on one machine and produces code for a | different machine is called a) Optimizing compiler b) One pass compiler ©) Cross compiler d) Multipass compiler (iv) Which of these does not belong to CFG? a) Terminal Symbol b} Non terminal Symbol c) Start symbol ) End Symbol Page 3 of rc (@) The output of lexical analyzer is _a) A set of RE) Syntax Tree ¢) Set of Tokens 4) String Character (vi) Another Name for Lexical Analyser is ____ a) Linear Phase b) Linear Analysis c) Scanner) Allof the mentioned (wil) Regular expression x/y denotes the set ___ 2) (xy! ) fy} «) tx) ) 9) (viii) The symbol table implementation is based on the property of locality of reference is 4) Linear list b) Search tree ¢) Hash Table d) Self Organization {WA bottom up parser generates _ a a) Right most derivation b) Rightmost derivation in reverse ¢) Leftmostderivation d) Leftmost derivation in reverse (09 Object program is a ____ a) Program written in machirie language by-Fregram © be tgenslated to machine language c) Translation of high-level language into:machiné language 4) None of the mentioned (xi) Which of the following pairs of regular expressions are equivalent? 2) 101)" and (10)*1. b) x (xx)" and (ex)*x c) x* and x* x) d) All of tHechehtioned (xii) The lexical analyzer takes ‘as input and produces a strearof > __as putput. 2) Source program, tokens b) Token, source program ¢) Eittieeithe two d) None of the ‘mentioned (aii) Which of the following is not feature of compiler?_a) Scan the entire program first and translate into machine code b) To remove syntax eprors_c) Slow for debugging 4) Execution time is more : ? (xiv) Which of the following is NOT the set of regularexpression R = (ab + abb)* bheb? 32) ababbbbab b) abbbab c)ababbabbbab d) abababab fv) Consider the production of the grammar SAA Aaa Ac>bb Describe the language ‘specified by the 7 production grammar. a) L= [aaaaaabb,bbaa,bbbb} b) L =.{abe ‘Byala aaab,baaa}_c) L = {aaab,baba,bbaa,bbbo} faaaa,ababbbaa,aaab} > (xvi) $-> aSa| bSb| a| b; the language generated by the above grammar is the set of 1a) All paliridromes. b) All odd Jength palindromes c) Strings ‘beginning and ending with the same symbol d) All everrfength palindromes (xvii) Match the following: Group 1 < Group 2 P, Regular expressions “1. Syntax analysis Q.Pushdownautomaté 2, Code generation R Dataflow analysis 3. Lexical analysis 5, Registérallocation _4. Code optimization a}P4,QTR2,53 b)P-3,Q1,R4S2 0) P3,Q4,R4,S-2 d)P-2,Q-1,R4,S-3 (wvilil{ Which one is a type of Lexeme___a) Identifiers._b) Constants ¢) Keywords ) All of the mentioned : (xix) When expression sum=3+2 is tokenized then what is the token category of 3 7 ') Identifier b) Assignment operator c) Integer Literal d) Addition Operator (02) A grammar for a programming language is a formal description of : ‘a)Syntax b)Semantics. c) Structure d) Library “Question SIX (a) Describe the following compiler terms: Page 4 of 5 — (i Token (i) Lexeme (iii) Pattern (iv) Recognizer (b) What are the basic steps required to design Lexical Analyzer manually? (© Given the grammar production, (1) $+ Xd | rZd, (2) Z— ea Joa, (3) X — ai; describe the backtracking behavior of a top-down parser with respect to the input string: “road” QUESTION SEVEN (a) Convert the NFA with ¢ into its equivalent DFA. | () (i) What are the five basic operations mostly performed by the synfibol+table in a compiler? (b) (il) What is a parse tree? > .QUESTION EIGHT @) Consider the Grammar, G: > TE >+TE* |e | SPT, Cw Do 4ET' fe ; F-->id] (E) : | +e denotes epsilon | | @_ Compote FIRST and fOLLOW/or each of the non-terminals of the above grammar. | (i) Construct a parsing’table-for G above (b) Explain the role ofemntic analyzer in a compiler ‘ : : | 1 Page § of 5

You might also like