Theory (CSc 473): Automata, Grammars, and Lanuaes. Let D = fwjw contains an equal number of occurrences of the substrins 0 and 0 Thus 0 2 D because 0

Size: px
Start display at page:

Download "Theory (CSc 473): Automata, Grammars, and Lanuaes. Let D = fwjw contains an equal number of occurrences of the substrins 0 and 0 Thus 0 2 D because 0"

Transcription

1 Masters Examination Department of Computer Science October 3, 998 Instructions This examination consists of nine problems. The questions are in three areas:. Theory and Alorithms: CSc 473, 545, and 573; 2. Systems and Architecture: CSc 452, 552, and 576; and 3. Lanuaes and Compilin: CSc 453, 520, and 553. You are to answer any two questions from each area(note: if more than two questions are attempted in any area, the lowest two of their scores will be used). You have three hours to complete the examination. Books or notes are not permitted durin the exam. At the end of the examination, submit just your six solutions. Do not include scrap paper. Write your answers on the tablet paper provided separately. Start the answer to each question on a separate sheet of paper. On each pae that you hand in, write the problem number in the upper left corner and the last four diits of your social security number in the upper riht corner. Hand in your solutions in the envelope provided. Results will be posted usin the four-diit numbers. Some problems will ask you to write an alorithm or a proram. Unless directed otherwise, use an informal pseudo-code. That is, use a lanuae with syntax and semantics similar to that of C or Pascal. You may invent informal constructs to help you present your solutions, provided that the meanin of such constructs is clear and they do not make the problem trivial. For example, when describin code that iterates over the elements of a set, you miht find it helpful to use a construct such as for c 2 S do Stmt where S is a set. SOLUTIONS

2 Theory (CSc 473): Automata, Grammars, and Lanuaes. Let D = fwjw contains an equal number of occurrences of the substrins 0 and 0 Thus 0 2 D because 0 contains a sinle 0 and a sinle 0, but00 62 D because 00 contains two 0s and one 0. Show thatd is a reular lanuae. 2. Let E = fwjw contains an equal number of occurrences of the substrins 0 and Thus E, but E. Show thate is not a reular lanuae. You may use the fact that f0 n n jn 0 is not a reular lanuae.. S is the start state. ffφ 0 n ffφ A ffφ 0??? - Cn B 0-0 ρ S n 6 n D ff0 ο? 0- - nf ΩΨ ΩΨ 0 ΩΨ 2. Proof by contradiction. If E is reular then so is E f0 Λ Λ = f0 n n jn 0.

3 2 Theory 2 (CSc 545): Desin and Analysis of Alorithms A rooted tree is a directed raph G that contains a vertex r (its root) suchthatevery other vertex in G can be reached from r by a unique path. Write an alorithm to determine whether a directed raph, iven as an adjacency list, is in fact a rooted tree, and if so, to find the root. What is the asymptotic runnin time of your alorithm? To receive full credit, your alorithm should take O(n) time, where n is the number of vertices in G.. DFS(G) 2. for each u 2 V 3. DFSfrom(u) 4. DFSfrom(u) 5. if u is unvisited 6. mark u visited 7. for each (u; v) 2 E 8. DFSfrom(v). If the number of edes in the raph G is not n, output Not Rooted Tree". 2. Perform Depth First Search (DFS) on G. DFS produces a sequence of DFS trees, T ;T 2 ;:::;T k, that partition the vertices of G. (Each call to DFSfrom at line 3 visits some (possibly empty) set of vertices in DFS fashion formin a tree. T i is the ith non-empty tree thus created.) Let r i be the root of tree T i then T i consists of all vertices reachable from r i that are not in T [ T 2 [ [T i. 3. Mark all vertices unvisited. 4. Perform DFSfrom(r k ). 5. If the resultin tree contains all vertices in G then output Rooted Tree with root r k ", else output Not Rooted Tree". Runnin Time DFS takes time O(n + m) (m is the numberofedes)ifg is represented as an adjacency list. Thus the alorithm, which performs DFS twice, takes time O(n + m). Since the alorithm checks that m = n before performin DFS, the runnin time is O(n). 2

4 3 Theory 3 (CSc 573): Theory of Computation Let R = fhmi jm is a Turin Machine and L(M) is a reular lanuae: The notation hmi denotes the encodin of the machine M as a strin. The notation L(M) denotes the set of strins accepted by the machine M. Show that R is an undecidable lanuae (i.e. membership in R is undecidable). You may assume that all strins are over the alphabet f0;. You may use the fact that A = fhm;wi jm is a Turin Machine and M accepts w is an undecidable lanuae. You may also use the fact that f0 n n jn 0 is not a reular lanuae. Hint: Use a proof by contradiction. Assume that R is decidable by some Turin Machine S and describe how touses to build a machine that decides A. (From: Introduction to the Theory of Computation by Michael Sipser) Let S be a TM that decides R, and construct a TM T to decide A. Then T works in the followin manner. T = On input hm;wi, where M is a TM and w is a strin:. Construct the followin TM M 2. M 2 = On input x: (a) If x has the form 0 n n, accept. (b) If x does not have this form, run M on input w and accept if M accepts w." 2. Run S on input hm 2 i. 3. If S accepts, accept; ifs rejects, reject." M 2 accepts the nonreular lanuae f0 n n if M does not accept w (so T rejects hm;wi), and accepts the reular lanuae f0; Λ if M accepts w (so T accepts hm;wi). An equally ood answer would be to use Rice's Theorem. 3

5 4 Systems (CSc 452): Principles of Operatin Systems Two types of processes, red and blue, share a resource. Any number of red processes and any number of blue processes many share the resource at the same time, but two processes of different colors are never allowed to share the resource. Also, red processes have priority over blue processes, if a red processes wants to use the resource, no new blue processes should be allowed to access it before the red one. Implement this system usin the followin messae-passin primitives: ffl The blockin function recv(p, &ms), which can be used to receive a messae from an explicitly-named process p. ffl The blockin function recv_any(&p, &ms), which can receive a messae from any process. sender's name is returned in &p.) ffl The non-blockin function send(p,ms), which can be used to send a messae to a named process p. Send queues messaes and those queues are of potentially unbounded lenth. ffl There are no shared data structures; this is a pure messae passin system. Show the code for a sample blue process and fill in the places marked `<your...>' in the server below. The server coordinates the red and blue processes. SERVER = f <your declarations and initializations> while () f recv_any(&p, &ms); switch (ms) f case "start blue": <your code> case "start red": <your code> case "end blue": <your code> case "end red": <your code> (The Blue = f send(server, "start-blue"); recv(server, ms); (Use shared resource here); send(server, "end-blue"); Server = f int red count, blue count = 0; queue red q, blue q = empty; while () f recv any(&p, &ms); switch (ms) f case "start blue": if ((red count == 0) && q empty(red q)) f send(p, "ok"); blue count++; 4

6 else f enqueue(p, blue queue); break; case "start red": if (blue count == 0) f send(p, "ok"); red count++; else f enqueue(p, red queue); break; case "end blue": assert(blue count > 0); blue count--; if ((blue count == 0) &&!q empty(red q)) f for (p = dequeue(red q);!q empty(red q); p = dequeue(red q))f send (p, "ok"); red count++; break; case "end red": assert(red count > 0); red count--; if ((red count == 0) &&!q empty(blue q)) f for (p = dequeue(blue q);!q empty(blue q); p = dequeue(blue q))f send (p, "ok"); blue count++; break; 5

7 5 Systems 2 (CSc 552): Advanced Operatin Systems Distributed shared memory systems (DSMs) and distributed file systems (DFSs) both need to manae distributed caches of shared data. In particular, DSMs cache paes" of shared memory, while DFSs cache files (or pieces of files).. Both DSMs and DFSs use some protocol to coordinate read and write sharin amon the private caches." Describe one such protocol used by DSMs. Use a diaram to aid your description. 2. In file systems, read and writes are done by systems calls and thus are very explicit. In a DSM, the reads and writes are to proram data structures and thus are not the results of explicit calls to the system. Describe two ways in which a DSM miht learn about reads and writes to shared memory. 3. The way in which DSMs and DFSs are used is quite different. This difference leads to some desin decisions bein suitable for one system, but not for another. Give an example of a DFS that handles the manaement of shared data in a way thatwould not be suitable for DSMs. Why is it unsuitable?. Any protocol needs to force exclusive write access and allow shared read access. There are lots of possibilities, but an invalidate protocol is probably the easiest to write down. Each cache line has three possible states, invalid, readable, writable. The diaram should be a FSM with the followin transitions. State invalid : read reads current version of the line (possibly from a cache that has it for write) and transitions to readable; write reads current version of the line, sends invalidate to other caches, transitions to writable; invalidate does nothin; remote reads do nothin. State readable : read does nothin; write already has current version, but must send invalidate and transition to writable; invalidate transitions to invalid; remote reads do nothin. State writable : read does nothin; write does nothin; invalidate must propaate the chaned version to wherever its oin to be read from and then transition to invalid; remote read must propaate the possible chaned version to wherever its oin to be read from and then transition to readable. 2. Two approaches are code instrumentation and VM faultin. In code instrumentation, the code run by the user makes explicit calls to the DSM code when it needs to work with shared data. Those calls miht be added by the prorammer, or by some software that instruments the code behind the prorammers back. With VM faultin, the VM protection is set on paes to force detection of reads and writes. 3. When a file is opened for writin in the Sprite file system, all cachin for that file is disabled and operations must o throuh to the server. Since DSMs need to support fine-rained reads and writes, thus would work very poorly for them. 6

8 6 Systems 3 (CSc 576): Computer Architecture Consider an implementation of the DLX in which the results of a load are not available for use until the third cycle after the load. Furthermore, there are now complex branches that can test for equality and inequality of the values in two reisters (BRE Ra, Rb, loc and BRNE Ra, Rb, loc), not just a reister aainst zero. All branches have one delay slot after the branch and no further branch penalty. Consider the followin loop, which is the (real) inner loop of a hih performance copyin arbae collector. It copies data whose lenth in words is found in R, from the address found in R2 to the address found in R3. You may assume that there is never a possibility that the ranes overlap. LOOP: LW Rtmp, 0(R2) SW Rtmp, 0(R3) ADD R2, R2, # ADD R3, R3, # SUB R, R, # BRNZ R LOOP ADD R0, R0, R0 ; no-op. This loop has a bu in it. What is the bu? How would you fix it? 2. Schedule this loop (i.e., reorder the instructions subject to the constraint that the result computed is uaranteed to be the same as before) so that it executes in as few cycles as possible. Do not eliminate or chane any instructions except to fix any bu(s) you have identified; if you did not find the bu, you may schedule the loop as it appears. Explain why your loop cannot be made any faster. 3. Unroll the loop and schedule it so that the unrolled loop is twice as fast as the current (unscheduled) loop. You may assume no stalls due to cache misses. You may use new temporary reisters, and only the contents of memory need to be the same as for the current loop. You should only write the loop body; you may assume that whatever preamble and/or postamble that is needed to make your loop correct (for example for loops not a multiple of your unrollin) is present. Explain how many times you unrolled and why your loop is twice as fast. Better scores will be iven for usin fewer temp reisters and for unrollin fewer times.. The bu is that it deals with the DLX as if it is word addressed. The #s on the ADDs need to be #4s. 2. LOOP: LW Rtmp, 0(R2) ADD R2, R2, #4 SUB R, R, # SW Rtmp, 0(R3) BRNZ R, LOOP ADD R3, R#, #4 The load stall and the branch delay has been scheduled and there are no more stalls, so it can't be made any faster. 3. SHL R, R, #2 ADD R, R2, R LOOP: LW Rtmp, 0(R2) LW Rtmp2, 4(R2) LW Rtmp3, 8(R2) SW Rtmp, 0(R3) SW Rtmp2, 4(R3) SW Rtmp3, 8(R3) ADD R2, R2, 2 BRNE R, R2, LOOP ADD R3, R3, #2 7

9 The loop has been unrolled three times. This has no stalls and copies a word every 3 instructions, while the oriinal does it every 6. 8

10 7 Lanuaes (CSc 453): Compilers and System Software For each of the statements below, indicate in the space provided the alternative that most accurately completes the statement. Note: Each correct answer is worth point, but each incorrect answer will incur a penalty of point (i.e., count as a score of ). You may wish to take this into account if you are not sure of an answer and want to make a uess.. For a C compiler, the most important requirement for fast compilation speeds is: (a) ood hash functions for fast symbol table lookups; (b) careful I/O buffer manaement and efficient lexical analysis; (c) ood reister allocation. 2. When writin a compiler desined primarily for novice users in an introductory course such as CSc 27, the most important objective should be to: (a) ensure that the enerated code is optimized as much as possible, since novice users can't be relied on to write efficient code; (b) carry out ood dataflow analysis; (c) implement ood error detection, reportin and recovery. 3. LL() parsers are able to handle (a) left-recursive rammars; (b) riht-recursive rammars; (c) both (a) and (b); (d) neither (a) nor (b). 4. LR() parsers are able to handle (a) left-recursive rammars; (b) riht-recursive rammars; (c) both (a) and (b); (d) neither (a) nor (b). 5. An attribute X at a node n in a parse tree is synthesized if (a) the value of X at n is computed at n or one of its descendants; (b) the value of X at n is computed at an ancestor of n or one of its siblins; (c) both (a) and (b); (d) neither (a) nor (b). 6. A rammar G is said to be ambiuous if 9

11 (a) a strin in the lanuae of G has more than one leftmost derivation; (b) it ives rise to a shift/reduce or reduce/reduce conflict within yacc; (c) it cannot be parsed usin a recursive descent parser; (d) all of the above. 7. To implement function calls correctly in a lanuae like C, it is necessary to (a) always pass all aruments and return values on the runtime stack; (b) always pass all aruments and return values in reisters; (c) pass aruments and return values usin any combination of reisters and memory, provided that the caller and the callee aree on where the appropriate values are to be found; (d) none of the above. 8. A C compiler usually carries out dataflow analysis in order to (a) verify that variables are used with types that are consistent with their declarations; (b) ather information for parsin; (c) ather information for code optimization; (d) determine how lare the symbol table ouht to be. 9. In the context of type checkin: (a) two types that are structurally equivalent must be name equivalent; (b) two types that are name equivalent must be structurally equivalent; (c) both (a) and (b); (d) neither (a) nor (b). 0. The followin shows (the structure of) an abstract syntax tree for an expression. We want to label each node with the minimum number of reisters needed to evaluate the subtree rooted at that node without havin to store any intermediate results into memory (this information may then be used, for example, to determine a ood evaluation order for the various subexpressions). The labelled tree that correctly completes the labellin for the tree shown above is: (a) (b) (c) 0

12 . b. 2. c. 3. b. 4. c. 5. a. 6. a. 7. c. 8. c. 9. b. 0. a.

13 8 Lanuaes 2 (CSc 520): Principles of Prorammin Lanuaes Consider a variable x that is a reference parameter to a procedure p: x is referenced n times within the body of p. Suppose that p is such that it can be uaranteed that x can always be passed either by reference or by value-result without affectin the result of the proram. Let the cost of a direct memory reference be C dir, and the cost of an indirect memory reference be C ind (typically, C ind C dir ). You may make the followin assumptions: (a) Scalar aruments (inteers, pointers) can be passed by value in reisters. areates (arrays, records) have to be copied into the callee's stack frame. (b) An address can be computed into a reister without any references to memory. To be passed by value, (c) Copyin a value from one memory location to another requires two direct memory references (a load and a store). (d) Variables local to a procedure may be accessed directly. An element of an array that is local to a procedure can be accessed with a sinle direct memory reference. Answer the followin questions: (i) Suppose that x is an inteer variable. For what values of n is it more efficient topassx by value-result than by reference? (ii) Suppose that x is an array of M inteers. value-result than by reference? For what values of n is it more efficient to pass x by (i) Passin x by value-result involves 2 direct memory references for copyin x: once at entry to p, and once at exit. After this, each reference to the parameter within p is to a local that can be accessed directly. Thus, there are n + 2 direct references in this case, and the cost is (n +2) C dir. If x is passed by reference, no memory references are necessary to compute the address of x into a reister, but the n references to x within the procedure have to access it indirectly. The cost in this case is n C ind. If passin by value-result is to be more efficient, we want (n +2) C dir <n C ind ) ( + 2 n ) <C ind=c dir ) 2 n < (C ind C dir )=C dir ) n>2c dir =(C ind C dir ). (ii) In this case, passin by value-result involves copyin M inteers at entry and at exit: this involves 2M copy operations, each of which incurs two memory references, for a total of 4M direct memory references. After this, any element of the array can be accessed in one direct memory reference, so the total cost is (4M + n) C dir. In passin by reference, there is no initial cost for computin the address of the array into a reister, but then accessin any element takes an indirect reference, as before. Thus the cost in this case is n C ind. If passin by value-result is to be more efficient, then we should have (4M + n) C dir <n C ind ) + 4M n <C ind=c dir ) 4M n < (C ind C dir )=C dir ) n>4mc dir =(C ind C dir ) 2

14 9 Lanuaes 3 (CSc 553): Principles of Compilation Suppose we want to write a proram that will display HTML documents in a browser window: amon the thins we need to do for this is to insert line-breaks (i.e., end the current line and start a new line) at the appropriate places, dependin on the width of the window. In turn, this requires that we be able to determine how wide a iven piece of text is. This question focuses on the problem of determinin the width of text. The rammar we consider is the followin (for simplicity, we'll inore such subtleties as spacin between adjacent letters, proper" display of multiple whitespace characters, etc.): the set of nonterminals is fdocument, Text, Word, the set of terminals is f<b>, </b>, <i>, </i>, Char, the start symbol is Document, and the productions are Document! Text Text! Word j Word Text j <b> Text </b> j <i> Text </i> Word! Char j Char Word Assume the followin:. We have three kinds of fonts: normal, bold, and italic. Initially, text is displayed in normal font; any text within <b> </b> is displayed in bold font, while text within <i> </i> is displayed in italic font. In case of nested <b> </b> and <i> </i> font specifiers, only the mostly deeply nested specifier is considered at each point. 2. The terminal Char has an associated synthesized attribute lexeme that specifies the actual character encountered. The value of this attribute is determined by the lexical analyzer. 3. The width of a character depends on the font bein used (e.., bold characters are somewhat wider than normal ones). You are iven a function chwidth(fnt, chr) that, iven a font fnt and character chr, returns an inteer ivin the width of that letter in that font. For each production of the rammar, specify semantic rules to compute attribute values for the various nonterminals of the rammar so as to determine the width of any strin derived from Text. Specify, for each attribute of each nonterminal, whether it is inherited or synthesized. The nonterminal Document does not have any associated attributes. The nonterminals Text and Word each have an inherited attribute font and a synthesized attribute width. These are determined usin the followin semantic rules: Document! Text Text! Word Text! Word Text Text! <b> Text </b> Text! <i> Text </i> Word! Char Word! Char Word ftext.font = normal; fword.font = Text.font; Text.width = Word.width fword.font = Text.font; Text.font = Text.font; Text:width = Word:width + Text :width ftext.font = bold; Text:width = Text :width ftext.font = italic; Text:width = Text :width f Word.width = chwidth(word.font, Char.lexeme) fword :font = Word:font; Word.width = chwidth(word.font, Char.lexeme) +Word :width 3

1 Theory 1 (CSc 473): Automata, Grammars, and Lanuaes For any strin w = w 1 w 2 :::w n, define w R to be the reversal of w: w R = w n w n 1 :::w 1. Su

1 Theory 1 (CSc 473): Automata, Grammars, and Lanuaes For any strin w = w 1 w 2 :::w n, define w R to be the reversal of w: w R = w n w n 1 :::w 1. Su Masters Examination Department of Computer Science March 27, 1999 Instructions This examination consists of nine problems. The questions are in three areas: 1. Theory and Alorithms: CSc 473, 545, and 573;

More information

Status. We ll do code generation first... Outline

Status. We ll do code generation first... Outline Status Run-time Environments Lecture 11 We have covered the ront-end phases Lexical analysis Parsin Semantic analysis Next are the back-end phases Optimization Code eneration We ll do code eneration irst...

More information

A SUIF Interface Module for Eli. W. M. Waite. University of Colorado

A SUIF Interface Module for Eli. W. M. Waite. University of Colorado A SUIF Interace Module or Eli W. M. Waite Department o Electrical and Computer Enineerin University o Colorado William.Waite@Colorado.edu 1 What is Eli? Eli [2] is a domain-specic prorammin environment

More information

Chapter 4. Coding systems. 4.1 Binary codes Gray (reflected binary) code

Chapter 4. Coding systems. 4.1 Binary codes Gray (reflected binary) code Chapter 4 Codin systems Codin systems define how information is mapped to numbers. Different codin systems try to store/transmit information more efficiently [Sec. 4.], or protect it from damae while it

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design i About the Tutorial A compiler translates the codes written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

JAVA XML PARSING SPECIFICATION

JAVA XML PARSING SPECIFICATION JAVA XML PARSING SPECIFICATION Joona Palaste Abstract: XML is a mark-up lanuae, or more precisely, a definition of mark-up lanuaes which allows information of arbitrary kind to be accurately and hierarchically

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

2 CHAPTR 1. BOTTOM UP PARSING 1. S ::= 4. T ::= T* F 2. ::= +T 5. j F 3. j T 6. F ::= 7. j Fiure 1.1: Our Sample Grammar for Bottom Up Parsin Our beli

2 CHAPTR 1. BOTTOM UP PARSING 1. S ::= 4. T ::= T* F 2. ::= +T 5. j F 3. j T 6. F ::= 7. j Fiure 1.1: Our Sample Grammar for Bottom Up Parsin Our beli Chapter 1 Bottom Up Parsin The key diæculty with top-down parsin is the requirement that the rammar satisfy the LL1 property. You will recall that this entailed knowin, when you are facin the token that

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Elkhound: A Fast, Practical GLR Parser Generator Scott McPeak University of California, Berkeley smcpeak@cs.berkeley.edu Report No. UCB/CSD--4 December 00 Computer Science Division (EECS) University of

More information

Graduate Examination. Department of Computer Science The University of Arizona Spring March 5, Instructions

Graduate Examination. Department of Computer Science The University of Arizona Spring March 5, Instructions Graduate Examination Department of Computer Science The University of Arizona Spring 2004 March 5, 2004 Instructions This examination consists of ten problems. The questions are in three areas: 1. Theory:

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4303 April 9, 2010 14.00-15.30 This exam (6 pages) consists of 52 True/False

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

CSE Qualifying Exam, Spring February 2, 2008

CSE Qualifying Exam, Spring February 2, 2008 CSE Qualifying Exam, Spring 2008 February 2, 2008 Architecture 1. You are building a system around a processor with in-order execution that runs at 1.1 GHz and has a CPI of 0.7 excluding memory accesses.

More information

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler. More detailed overview of compiler front end Structure of a compiler Today we ll take a quick look at typical parts of a compiler. This is to give a feeling for the overall structure. source program lexical

More information

A Simple Syntax-Directed Translator

A Simple Syntax-Directed Translator Chapter 2 A Simple Syntax-Directed Translator 1-1 Introduction The analysis phase of a compiler breaks up a source program into constituent pieces and produces an internal representation for it, called

More information

Imitation: An Alternative to Generalization in Programming by Demonstration Systems

Imitation: An Alternative to Generalization in Programming by Demonstration Systems Imitation: An Alternative to Generalization in Prorammin by Demonstration Systems Technical Report UW-CSE-98-08-06 Amir Michail University of Washinton amir@cs.washinton.edu http://www.cs.washinton.edu/homes/amir/opsis.html

More information

2068 (I) Attempt all questions.

2068 (I) Attempt all questions. 2068 (I) 1. What do you mean by compiler? How source program analyzed? Explain in brief. 2. Discuss the role of symbol table in compiler design. 3. Convert the regular expression 0 + (1 + 0)* 00 first

More information

Fall 2016 CSE Qualifying Exam CSCE 531, Compilers

Fall 2016 CSE Qualifying Exam CSCE 531, Compilers Fall 2016 CSE Qualifying Exam CSCE 531, Compilers 1. LR-Parsing (a) Give definitions of FIRST( ) and FOLLOW(X). (b) Consider the following augmented grammar G with start symbol S 0 : S 0! S S! V = E S!

More information

CSCE 531, Spring 2015 Final Exam Answer Key

CSCE 531, Spring 2015 Final Exam Answer Key CSCE 531, Spring 2015 Final Exam Answer Key 1. (40 points total) Consider the following grammar with start symbol S : S S S asb S T T T a T cs T ɛ (a) (10 points) Find FIRST(S), FIRST(T ), FOLLOW(S), and

More information

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail. Code No: R05320502 Set No. 1 1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail. 2. Construct predictive parsing

More information

CS 164 Handout 16. Final Examination. There are nine questions on the exam, some in multiple parts. You have 3 hours to work on the

CS 164 Handout 16. Final Examination. There are nine questions on the exam, some in multiple parts. You have 3 hours to work on the Final Examination Please read all instructions (including these) carefully. Please print your name at the bottom of each page on the exam. There are nine questions on the exam, some in multiple parts.

More information

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points.

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points. Midterm Examination Please read all instructions (including these) carefully. Please print your name at the bottom of each page on the exam. There are seven questions on the exam, each worth between 10

More information

main Entry main main pow Entry pow pow

main Entry main main pow Entry pow pow Interprocedural Path Prolin David Melski and Thomas Reps Computer Sciences Department, University of Wisconsin, 20 West Dayton Street, Madison, WI, 53706, USA, fmelski, reps@cs.wisc.edu Abstract. In path

More information

2.2 Syntax Definition

2.2 Syntax Definition 42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions

More information

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1 Table of Contents About the Authors... iii Introduction... xvii Chapter 1: System Software... 1 1.1 Concept of System Software... 2 Types of Software Programs... 2 Software Programs and the Computing Machine...

More information

Appendix Set Notation and Concepts

Appendix Set Notation and Concepts Appendix Set Notation and Concepts In mathematics you don t understand things. You just get used to them. John von Neumann (1903 1957) This appendix is primarily a brief run-through of basic concepts from

More information

VIVA QUESTIONS WITH ANSWERS

VIVA QUESTIONS WITH ANSWERS VIVA QUESTIONS WITH ANSWERS 1. What is a compiler? A compiler is a program that reads a program written in one language the source language and translates it into an equivalent program in another language-the

More information

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2 6.045J/18.400J: Automata, omputability and omplexity March 21, 2007 Practice Quiz 2 Prof. Nancy Lynch Elena Grigorescu Please write your name in the upper corner of each page. INFORMATION ABOUT QUIZ 2:

More information

The SpecC Methodoloy Technical Report ICS December 29, 1999 Daniel D. Gajski Jianwen Zhu Rainer Doemer Andreas Gerstlauer Shuqin Zhao Department

The SpecC Methodoloy Technical Report ICS December 29, 1999 Daniel D. Gajski Jianwen Zhu Rainer Doemer Andreas Gerstlauer Shuqin Zhao Department The SpecC Methodoloy Technical Report ICS-99-56 December 29, 1999 Daniel D. Gajski Jianwen Zhu Rainer Doemer Andreas Gerstlauer Shuqin Zhao Department of Information and Computer Science University of

More information

MIDTERM EXAM (Solutions)

MIDTERM EXAM (Solutions) MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and

More information

CSE 12 Abstract Syntax Trees

CSE 12 Abstract Syntax Trees CSE 12 Abstract Syntax Trees Compilers and Interpreters Parse Trees and Abstract Syntax Trees (AST's) Creating and Evaluating AST's The Table ADT and Symbol Tables 16 Using Algorithms and Data Structures

More information

Qualifying Exam in Programming Languages and Compilers

Qualifying Exam in Programming Languages and Compilers Qualifying Exam in Programming Languages and Compilers University of Wisconsin Fall 1991 Instructions This exam contains nine questions, divided into two parts. All students taking the exam should answer

More information

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token. Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 6 Decaf Language Definition Wednesday, September 4 The project for the 12-unit flavor

More information

Principles of Programming Languages [PLP-2015] Detailed Syllabus

Principles of Programming Languages [PLP-2015] Detailed Syllabus Principles of Programming Languages [PLP-2015] Detailed Syllabus This document lists the topics presented along the course. The PDF slides published on the course web page (http://www.di.unipi.it/~andrea/didattica/plp-15/)

More information

Efficient and Provably Secure Ciphers for Storage Device Block Level Encryption

Efficient and Provably Secure Ciphers for Storage Device Block Level Encryption Efficient and Provably Secure Ciphers for Storae Device Block evel Encryption Yulian Zhen SIS Department, UNC Charlotte yzhen@uncc.edu Yone Wan SIS Department, UNC Charlotte yonwan@uncc.edu ABSTACT Block

More information

COP4020 Spring 2011 Midterm Exam

COP4020 Spring 2011 Midterm Exam COP4020 Spring 2011 Midterm Exam Name: (Please print Put the answers on these sheets. Use additional sheets when necessary or write on the back. Show how you derived your answer (this is required for full

More information

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised: EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing Görel Hedin Revised: 2017-09-04 This lecture Regular expressions Context-free grammar Attribute grammar

More information

Fall 2015 CSE Qualifying Exam Core Subjects

Fall 2015 CSE Qualifying Exam Core Subjects Fall 2015 CSE Qualifying Exam Core Subjects September 26, 2015 Architecture 1. Assuming the classical 5-stage pipeline with no forwarding except through the registers and all operations execute in one

More information

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Spring 2010 7-10p, Wednesday, May 12 Name: NetID: Lab Section

More information

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token. Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 7 Espresso Language Definition Wednesday, September 4 The project for the 18-unit

More information

Chapter 4. Lexical and Syntax Analysis. Topics. Compilation. Language Implementation. Issues in Lexical and Syntax Analysis.

Chapter 4. Lexical and Syntax Analysis. Topics. Compilation. Language Implementation. Issues in Lexical and Syntax Analysis. Topics Chapter 4 Lexical and Syntax Analysis Introduction Lexical Analysis Syntax Analysis Recursive -Descent Parsing Bottom-Up parsing 2 Language Implementation Compilation There are three possible approaches

More information

Single-pass Static Semantic Check for Efficient Translation in YAPL

Single-pass Static Semantic Check for Efficient Translation in YAPL Single-pass Static Semantic Check for Efficient Translation in YAPL Zafiris Karaiskos, Panajotis Katsaros and Constantine Lazos Department of Informatics, Aristotle University Thessaloniki, 54124, Greece

More information

CSCE 531 Spring 2009 Final Exam

CSCE 531 Spring 2009 Final Exam CSCE 531 Spring 2009 Final Exam Do all problems. Write your solutions on the paper provided. This test is open book, open notes, but no electronic devices. For your own sake, please read all problems before

More information

A programming language requires two major definitions A simple one pass compiler

A programming language requires two major definitions A simple one pass compiler A programming language requires two major definitions A simple one pass compiler [Syntax: what the language looks like A context-free grammar written in BNF (Backus-Naur Form) usually suffices. [Semantics:

More information

COMPILER DESIGN. For COMPUTER SCIENCE

COMPILER DESIGN. For COMPUTER SCIENCE COMPILER DESIGN For COMPUTER SCIENCE . COMPILER DESIGN SYLLABUS Lexical analysis, parsing, syntax-directed translation. Runtime environments. Intermediate code generation. ANALYSIS OF GATE PAPERS Exam

More information

QUESTIONS RELATED TO UNIT I, II And III

QUESTIONS RELATED TO UNIT I, II And III QUESTIONS RELATED TO UNIT I, II And III UNIT I 1. Define the role of input buffer in lexical analysis 2. Write regular expression to generate identifiers give examples. 3. Define the elements of production.

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2009 P. N. Hilfinger CS 164: Final Examination (corrected) Name: Login: You have

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

Midterm Exam. CSCI 3136: Principles of Programming Languages. February 20, Group 2

Midterm Exam. CSCI 3136: Principles of Programming Languages. February 20, Group 2 Banner number: Name: Midterm Exam CSCI 336: Principles of Programming Languages February 2, 23 Group Group 2 Group 3 Question. Question 2. Question 3. Question.2 Question 2.2 Question 3.2 Question.3 Question

More information

PSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design

PSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design PSD3A Principles of Compiler Design Unit : I-V 1 UNIT I - SYLLABUS Compiler Assembler Language Processing System Phases of Compiler Lexical Analyser Finite Automata NFA DFA Compiler Tools 2 Compiler -

More information

Compiler Design Aug 1996

Compiler Design Aug 1996 Aug 1996 Part A 1 a) What are the different phases of a compiler? Explain briefly with the help of a neat diagram. b) For the following Pascal keywords write the state diagram and also write program segments

More information

CS 406/534 Compiler Construction Putting It All Together

CS 406/534 Compiler Construction Putting It All Together CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy

More information

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program.

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program. COMPILER DESIGN 1. What is a compiler? A compiler is a program that reads a program written in one language the source language and translates it into an equivalent program in another language-the target

More information

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College Laura Toma Algorithms (csci2200), Bowdoin College Undirected graphs Concepts: connectivity, connected components paths (undirected) cycles Basic problems, given undirected graph G: is G connected how many

More information

SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A

SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A 1. What is a compiler? (A.U Nov/Dec 2007) A compiler is a program that reads a program written in one language

More information

CS606- compiler instruction Solved MCQS From Midterm Papers

CS606- compiler instruction Solved MCQS From Midterm Papers CS606- compiler instruction Solved MCQS From Midterm Papers March 06,2014 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 Final Term MCQ s and Quizzes CS606- compiler instruction If X is a

More information

CSE 431S Final Review. Washington University Spring 2013

CSE 431S Final Review. Washington University Spring 2013 CSE 431S Final Review Washington University Spring 2013 What You Should Know The six stages of a compiler and what each stage does. The input to and output of each compilation stage (especially the back-end).

More information

Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120

Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120 CSC 326, Midterm October 25, 2004 Name: Student ID: Signature: You have 75 minutes to write the 8 questions on this examination. A total of 120 marks is available. Justify all of your answers You may use

More information

CSE 413 Final Exam Spring 2011 Sample Solution. Strings of alternating 0 s and 1 s that begin and end with the same character, either 0 or 1.

CSE 413 Final Exam Spring 2011 Sample Solution. Strings of alternating 0 s and 1 s that begin and end with the same character, either 0 or 1. Question 1. (10 points) Regular expressions I. Describe the set of strings generated by each of the following regular expressions. For full credit, give a description of the sets like all sets of strings

More information

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer: Theoretical Part Chapter one:- - What are the Phases of compiler? Six phases Scanner Parser Semantic Analyzer Source code optimizer Code generator Target Code Optimizer Three auxiliary components Literal

More information

CS143 Handout 20 Summer 2012 July 18 th, 2012 Practice CS143 Midterm Exam. (signed)

CS143 Handout 20 Summer 2012 July 18 th, 2012 Practice CS143 Midterm Exam. (signed) CS143 Handout 20 Summer 2012 July 18 th, 2012 Practice CS143 Midterm Exam This midterm exam is open-book, open-note, open-computer, but closed-network. This means that if you want to have your laptop with

More information

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 1 Not all languages are regular So what happens to the languages which are not regular? Can we still come up with a language recognizer?

More information

Defining Languages GMU

Defining Languages GMU Defining Languages CS463 @ GMU How do we discuss languages? We might focus on these qualities: readability: how well does a language explicitly and clearly describe its purpose? writability: how expressive

More information

CSCI Compiler Design

CSCI Compiler Design CSCI 565 - Compiler Design Spring 2015 Midterm Exam March 04, 2015 at 8:00 AM in class (RTH 217) Duration: 2h 30 min. Please label all pages you turn in with your name and student number. Name: Number:

More information

Time : 1 Hour Max Marks : 30

Time : 1 Hour Max Marks : 30 Total No. of Questions : 6 P4890 B.E/ Insem.- 74 B.E ( Computer Engg) PRINCIPLES OF MODERN COMPILER DESIGN (2012 Pattern) (Semester I) Time : 1 Hour Max Marks : 30 Q.1 a) Explain need of symbol table with

More information

Chapter 3: Syntax and Semantics. Syntax and Semantics. Syntax Definitions. Matt Evett Dept. Computer Science Eastern Michigan University 1999

Chapter 3: Syntax and Semantics. Syntax and Semantics. Syntax Definitions. Matt Evett Dept. Computer Science Eastern Michigan University 1999 Chapter 3: Syntax and Semantics Matt Evett Dept. Computer Science Eastern Michigan University 1999 Syntax and Semantics Syntax - the form or structure of the expressions, statements, and program units

More information

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units Syntax - the form or structure of the expressions, statements, and program units Semantics - the meaning of the expressions, statements, and program units Who must use language definitions? 1. Other language

More information

Lecture 8: C language

Lecture 8: C language Lecture 8: C lanuae History of C Structure of a C proram C data types Variable declaration and scope C operators Loops and iterations Pointers Structures in C C and assembly lanuae Microprocessor-based

More information

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 20 Intermediate code generation Part-4 Run-time environments

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

Fall 2009 CSE Qualifying Exam Core Subjects. September 19, 2009

Fall 2009 CSE Qualifying Exam Core Subjects. September 19, 2009 Fall 2009 CSE Qualifying Exam Core Subjects September 19, 2009 1 Architecture 1. It s 1997 and you re a graduate student at Stanford named Larry Page. You re trying to build a new Internet search engine

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 January 19, 2006 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

Supporting Persistent Object Systems in a Single Address Space 1

Supporting Persistent Object Systems in a Single Address Space 1 Supportin Persistent Object Systems in a Sinle Address Space 1 Kevin Elphinstone, Stephen Russell, Gernot Heiser 2 School of Computer Science & Enineerin, The University of New South Wales, Sydney 2052,

More information

Shifting up Java RMI from P2P to Multi-Point

Shifting up Java RMI from P2P to Multi-Point Walter Cazzola, Massimo Ancona, Fabio Canepa, Massimo Mancini, and Vanja Siccardi. Shiftin Up Java RMI from P2P to Multi-Point. Technical Report DISI-TR-01-13, DISI, Università deli Studi di Genova, December

More information

East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005

East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005 Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005 Section

More information

CAM Part II: Intersections

CAM Part II: Intersections CAM Part II: Intersections In the previous part, we looked at the computations of derivatives of B-Splines and NURBS. The first derivatives are of interest, since they are used in computin the tanents

More information

Grammars and Parsing, second week

Grammars and Parsing, second week Grammars and Parsing, second week Hayo Thielecke 17-18 October 2005 This is the material from the slides in a more printer-friendly layout. Contents 1 Overview 1 2 Recursive methods from grammar rules

More information

Question Bank. 10CS63:Compiler Design

Question Bank. 10CS63:Compiler Design Question Bank 10CS63:Compiler Design 1.Determine whether the following regular expressions define the same language? (ab)* and a*b* 2.List the properties of an operator grammar 3. Is macro processing a

More information

CSc 520 final exam Wednesday 13 December 2000 TIME = 2 hours

CSc 520 final exam Wednesday 13 December 2000 TIME = 2 hours NAME s GRADE Prob 1 2 3 4 5 I II III Σ Max 12 12 12 12 12 26 26 26 100(+... ) Score CSc 520 exam Wednesday 13 December 2000 TIME = 2 hours Write all answers ON THIS EXAMINATION, and submit it IN THE ENVELOPE

More information

Context-free grammars

Context-free grammars Context-free grammars Section 4.2 Formal way of specifying rules about the structure/syntax of a program terminals - tokens non-terminals - represent higher-level structures of a program start symbol,

More information

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the

More information

CSC 467 Lecture 13-14: Semantic Analysis

CSC 467 Lecture 13-14: Semantic Analysis CSC 467 Lecture 13-14: Semantic Analysis Recall Parsing is to translate token stream to parse tree Today How to build trees: syntax direction translation How to add information to trees: semantic analysis

More information

A new generation of tools for SGML

A new generation of tools for SGML Article A new generation of tools for SGML R. W. Matzen Oklahoma State University Department of Computer Science EMAIL rmatzen@acm.org Exceptions are used in many standard DTDs, including HTML, because

More information

CSE 401/M501 18au Midterm Exam 11/2/18. Name ID #

CSE 401/M501 18au Midterm Exam 11/2/18. Name ID # Name ID # There are 7 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed books, closed notes,

More information

Spring 2013 CSE Qualifying Exam Core Subjects. March 23, 2013

Spring 2013 CSE Qualifying Exam Core Subjects. March 23, 2013 Spring 2013 CSE Qualifying Exam Core Subjects March 23, 2013 1 Architecture 1. ROB trace - single issue (a) Non-pipelined functional units Assume the following: Nine ROB slots. 1 integer Execution unit,

More information

10/4/18. Lexical and Syntactic Analysis. Lexical and Syntax Analysis. Tokenizing Source. Scanner. Reasons to Separate Lexical and Syntactic Analysis

10/4/18. Lexical and Syntactic Analysis. Lexical and Syntax Analysis. Tokenizing Source. Scanner. Reasons to Separate Lexical and Syntactic Analysis Lexical and Syntactic Analysis Lexical and Syntax Analysis In Text: Chapter 4 Two steps to discover the syntactic structure of a program Lexical analysis (Scanner): to read the input characters and output

More information

Using LDAP Directory Caches. Olga Kapitskaia. AT&T Labs{Research. on sample queries from a directory enabled application

Using LDAP Directory Caches. Olga Kapitskaia. AT&T Labs{Research. on sample queries from a directory enabled application Usin LDAP Directory Caches Sophie Cluet INRIA Rocquencourt Sophie.Cluet@inria.fr Ola Kapitskaia AT&T Labs{Research ola@research.att.com Divesh Srivastava AT&T Labs{Research divesh@research.att.com 1 Introduction

More information

Chapter 3. Describing Syntax and Semantics

Chapter 3. Describing Syntax and Semantics Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

More information

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 STUDENT ID: INSTRUCTIONS Please write your student ID on this page. Do not write it or your name

More information

Syntax-Directed Translation

Syntax-Directed Translation Syntax-Directed Translation ALSU Textbook Chapter 5.1 5.4, 4.8, 4.9 Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 What is syntax-directed translation? Definition: The compilation

More information

UNIT I INTRODUCTION TO COMPILER 1. What is a Complier? A Complier is a program that reads a program written in one language-the source language-and translates it in to an equivalent program in another

More information

Chapter 3 Lexical Analysis

Chapter 3 Lexical Analysis Chapter 3 Lexical Analysis Outline Role of lexical analyzer Specification of tokens Recognition of tokens Lexical analyzer generator Finite automata Design of lexical analyzer generator The role of lexical

More information

Compiler Construction: Parsing

Compiler Construction: Parsing Compiler Construction: Parsing Mandar Mitra Indian Statistical Institute M. Mitra (ISI) Parsing 1 / 33 Context-free grammars. Reference: Section 4.2 Formal way of specifying rules about the structure/syntax

More information

Lexical and Syntax Analysis

Lexical and Syntax Analysis Lexical and Syntax Analysis In Text: Chapter 4 N. Meng, F. Poursardar Lexical and Syntactic Analysis Two steps to discover the syntactic structure of a program Lexical analysis (Scanner): to read the input

More information

Parsing III. CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones

Parsing III. CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones Parsing III (Top-down parsing: recursive descent & LL(1) ) (Bottom-up parsing) CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper,

More information

CS 6353 Compiler Construction Project Assignments

CS 6353 Compiler Construction Project Assignments CS 6353 Compiler Construction Project Assignments In this project, you need to implement a compiler for a language defined in this handout. The programming language you need to use is C or C++ (and the

More information

CSc 453 Lexical Analysis (Scanning)

CSc 453 Lexical Analysis (Scanning) CSc 453 Lexical Analysis (Scanning) Saumya Debray The University of Arizona Tucson Overview source program lexical analyzer (scanner) tokens syntax analyzer (parser) symbol table manager Main task: to

More information

Weeks 6&7: Procedures and Parameter Passing

Weeks 6&7: Procedures and Parameter Passing CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45

More information