.

Wednesday, December 19, 2018

'Compiler\r'

'ALLAMA IQBAL OPEN UNIVERSITY, capital of Pakistan (Department of Computer Science) WARNING 1. piracy OR HIRING OF touch modality WRITER(S) FOR SOLVING THE date(S) pull up stakes DEBAR THE STUDENT FROM select OF DEGREE/CERTIFICATE, IF FOUND AT ANY STAGE. 2. SUBMITTING ASSIGNMENT(S) BORROWED OR STOLEN FROM OTHER(S) AS ONE’S OWN WILL BE PENALIZED AS DEFINED IN â€Å"AIOU PLAGIARISM POLICY”. Course: Compiler Construction (3468)Semester: Autumn, 2012 train: BS (CS)Total Marks: one C ASSIGNMENT no. 1 nonee: All questions carry agree marks. Q. 1(a)Define Compiler, exploitation a diagram describes the three phases of depth psychology of source program. (b) beg off all(a) the phases of Compiler. c)Consider the sideline grammar. S ? > XaYb X ? > bXc | b Y ? > dYa | d Find the start sets for each non-terminal of the given grammar. Q. 2(a)Explain the error detection and insurance coverage mechanisms. (b)Write the intermediate representation reckon of the by-line scene: = initial + rate * 60 Q. 3(a)Convert the adjacent NFA into analogous DFA using subset edifice Algorithm. [pic] Note: designate all necessary steps that are involved in subset construction algorithm. (b) Convert the Following fastness grammatical construction into NFA using Thompson’s construction. a ((b|b*c)d)* |d*a Q. 4(a)Given the chase grammar. G > EE > T + E | T T > F * T | F F > a i) Is this grammar ambiguous? Explain! ii) Draw all parse trees for sentence â€Å"a+a*a+a”. (b) Consider the following grammar. S> A A> A+A | B++ B > y Draw parse tree for the scuttlebutt â€Å"y+++y++” Q. 5(a)Explain the affair of the lexical analyser and Parser in detail. (b)Differentiate between Top-down parsing and Bottom-up parsing. ASSIGNMENT No. 2 Total Marks: 100 Note: All questions carry equal marks. Q. 1(a)Rewrite the following SDT: A A {a} B | A B {b} | 0 B -> B {c} A | B A {d} | 1 so that the underlying grammar becomes non-left-recursive. Here, a, 6, c, and d are actions, and 0 and 1 are terminals. b)This grammar generates binary numbers racket with a â€Å"decimal” point: S-* L . L | L L-+LBB B -> 0 | 1 excogitate an L- arrogated SDD to compute S. val, the decimal-number cherish of an input arrange. For example, the translation of string 101. 101 should be the decimal number 5. 625. Q. 2(a)Translate the following expressions using the goto-avoiding translation scheme. i)if (a==b kk c==d |I e==f) x == 1; ii)if (a==b II c==d || e==f) x == 1; iii)if (a==b && c==d kk e==f) x == 1; (b)Construct the DAG and identify the value numbers for the sub expressions of the following expressions, assuming + associates from the left. ) a + b+ (a + b). ii) a + b + a + b. iii) a + a + ((fl + a + a + (a + a + a + a )). Q. 3(a)Explain the following i)Back Patching ii)Procedure Calls (b)Generate code for the following three-address statements, assuming all variables are stored in retentiveness locations. i) x = 1 ii) x = a iii) x = a + 1 iv) x = a + b v) The two statements x = b * c y = a + x Q. 4(a)The programming language C does not have a Boolean type. Show how a C compiler might hand over if-statement into three-address code. (b)Construct the DAG for the staple fiber block d = b * c e = a + b b = b * c a = e †d Q. (a)Generate code for the following three-address statements assuming a and b are arrays whose elements are 4-byte values. i)The four-statement sequence x = a [ i] y = b [ j] a [ i ] = y b [ j ] = x ii) The three-statement sequence x = a [ i] y = b [ i] z = x * y iii) The three-statement sequence x = a [ i] y = b[x] a [ i ] = y (b)Suppose a basic block is formed from the C assignment statements x = a + b + c + d + e + f; y = a + c + e; i) Give the three-address statements (only one addition per statement) for this block. ii) Use the associative and commutative laws to modify the block to use the fewest(prenominal) possible number of 468 Compiler ConstructionCredit Hours: 3(3, 0) Recommended Book: Compliers; Principles, Techniques, and Tools by Alfred V. Aho, Ravi Sethi, Jerrey D. Ullman Course Outlines: Unit No. 1 foot to Compiling Compliers, analysis of the source program, the phases of a complier, cousins of the compiler, the group of phases, complier-construction tools Unit No. 2 A plain One-pass Compiler Overview, syntax definition, syntax-directed translation, parsing, a translator for elementary-minded expressions, lexical analysis, incorporating a symbol table, abstract cumulation machines, putting the techniques together Unit No. Lexical and Syntax Analysis Lexical analysis (the role of the lexical analyser, input buffering, specification of tokens, recognition of tokens, a language for specifying lexical analyzers, finite automata, from a regular expression to an NFA, design of a lexical analyzer generator, optimization of DFA-based pattern matchers), syntax analysis (the role of the parser, context-free grammars, writing a grammar, t op-down parsing, bottom-up parsing, operator-precedence parsing, LR parsers, using ambiguous grammars, parser generators) Unit No. 4 Syntax-Directed TranslationSyntax-directed definitions, construction of syntax trees, bottom-up evaluation of s-attributed definitions, l-attributed definitions, top-down translation, bottom-up evaluation of inherited attributes, recursive evaluators, topographic point for attribute values at compile time, assigning space at complier-construction time, analysis of syntax-directed definitions Unit No. 5 Type Checking Type systems, Specification of a simple type checker, Equivalence of type expressions, Type conversions, Overloading of functions and operators, polymorphous functions, an algorithm for unification Unit No. medium encipher Generation Intermediate Languages, Declarations, Assignment statements, Boolean expressions, Case statements, Back Patching, Procedure calls Unit No. 7 Code Generations Issues in the design of a code generator, The tar get machine, Run-time storage management, Basic blocks and operate graphs, Next-use information, A simple code generator, Register parcelling and assignment, The dag representation of basic blocks, Peephole optimization, Generating code from dags, Dynamic programming code-generation algorithm, Code-generator generators Unit No. Code Optimization Introduction, The principal sources of optimization, Optimization of basic blocks, Loops in flow graphs, Introduction to global data-flow analysis, Iterative issue of data-flow equations, Code-improving transformations, Dealing with aliases, Data-flow analysis of structured flow graphs, economic data-flow algorithms, A tool for data-flow analysis, Estimation of types, Symbolic debugging of optimized code Unit No. Writing a Complier prep a compiler, Approaches to compiler development, The compiler-development environment, Testing and maintenance, A air at Some Compilers, EQN, a preprocessor for typesetting mathematics, Compilers for Pas cal, The C compilers, The Fortran H compilers, The Bliss/11 compiler, Modula-2 optimizing compiler\r\n'

No comments:

Post a Comment