CS 526 Program Translation and Compiler Construction

Quick Facts

Times: Monday and Wednesday: 15:55 - 17:15
Location: Technology Hall N155
Instructor: Delbert R. Hart
Office: Technology Hall N345
Phone: (256) 824-5160
email: dhart@cs.uah.edu
Required textbook:
Title Modern Compiler Design
Author D. Grune, H. Bal, C. Jacobs, K. Langendoen
Publisher John Wiley & Sons
ISBN 0471976970

Recommended textbook:
Title lex and yacc
Author John Levine, Tony Mason, and Doug Brown
Publisher O'Reilly
ISBN 1-56592-000-7

Final Exam: Mon Dec 10 15:00-17:30

Basic Information

syllabus ps
syllabus pdf
project ps
project pdf

Exams

Test 1 ps
Test 1 pdf

Test 2 ps
Test 2 pdf

Test 3 ps
Test 3 pdf

Test 4 ps
Test 4 pdf

Resources

Local CVS information here
Perl 6 (There is a table of contents on this page to the earlier parts of the discussion.)
Elf File Format

Homework

  1. August 30, 2001
    From the text book questions: 1.4, 1.6, 1.13, 1.14, 1.16, 2.4, 2.5,
    2.7, 2.22
    
    
  2. September 24, 2001
    From the book in Chapter 2:
    2.8, 2.11, 2.12, 2.31c, and 2.49
    
    For the grammar:
    S -> T a
    T -> S a | {}
    S -> B C
    B -> c C
    B -> c D
    C -> t x
    D -> t y
    D -> {}
    
    Compute the First/Follow sets
    Fix the grammar so that it is LL (1) and is as semantically close as possible
    Compute the First/Follow sets
    
    For the original grammar is it possible to construct an LR(0), SLR, LR(1) parser?
    
    If not modify it as little as possible so that it is.
    
    Draw the first few automata states for each of these parsers.
    
    
  3. practice grammars
    Grammar 1:
    S -> B | xa B
    B -> xa
    
    Grammar 2:
    S -> A | B | C
    A -> xxy
    B -> xy
    C -> Cx | x
    
    
    Grammar 3: (this one I modeled after arguing children (or adults). The Ds and Rs represent `are too's, the Bs and Cs represent `are not's, the Is and Js represent `I know you are, but what am I?'s. The only part that doesn't correspond to the example is the empty string, but I wanted the grammar to terminate.)
    
    S -> C | R | I
    C -> R n
    R -> D a
    D -> B n | I n
    B -> D a | I a
    I -> J i | empty
    J -> J i | C | D
    
  4. October 2, 2001
    As to question 2.31c, the answer is that a non-predictive recursive
    descent parser can't correctly parse it.  The reason is that when
    it starts matching right parentheses it doesn't know if the S went
    to one or if S became the empty string.
    
    A followup question is how much look-ahead would a parser need to have 
    to solve this problem?  Can this be handled by an LR parser?  If so
    how much look-ahead would it need?
    
    Be familiar with the terms in 3.1, 3.13, 3.16, and think about 3.25.
    
    Write an attribute grammar using only synthesized attributes for a
    grammar that describes integer math expressions.  Include attributes
    that you think a real compiler would find useful.
    
    Try to write one using only inherited attributes.  Are you able to
    provide the same functionality?
    
    Identify which attributes are more natural as inherited and synthesized.
    
  5. October 23, 2001
    Think about 4.1 and 4.4.
    
    Do 4.3, 4.7, 4.26, 4.29, 4.30, and 4.36.
    
    Modify the graph in 4.26 by adding nodes f, g, h, and i and edges (e, f),
    (c, f), (b, g), (a, g), (f, h), (g, h), and (a, i)
    
    Sketch out an example execution that would generate graphs corresponding to
    both the original 4.26 and the modified 4.26.
    
    Identify another resource that you could use graph-coloring to manage.
    (Hint: think about what other resources might be available in a
    microprocessor and think about reordering instructions that do not have
    dependencies.)
    
    Identify a replacement pattern that would be useful.  What are the minimum
    and maximum window sizes for which it is effective?
    
    How could you apply memoization to cloning/specialization?
    
    What are threaded code and partial evaluation?
    
    
  6. November 12, 2001
    From the book: 5.8, 5.9, think about 5.12, and 5.13.
     
    Review the pros and cons of garbage collection in general.
    Try working through examples of reference counting, mark and
    sweep and two-space copying.
     
    Compare reference counting to two-space copying?  When might
    one be more appropriate than another?
     
    How can cycles be handled in reference counting?
    
  7. November 26, 2001 (a)
    From the book 6.3, 6.8, 6.9, 6.12, 6.17, 6.19, 6.24, 6.26, and 6.31
    
    Compare stack-based activation records to heap-based activation
    records.
    
    What is the relationship between coercion and conversion?
    
    Describe an activation record.
    
    What are the different ways to implement a case statement?
    
    
  8. November 26, 2001 (b)
    
    From the book 7.1, 7.2, 7.10, 7.14, 7.16, 9.1, 9.3, 9.6, 9.9, and 9.13
    
    Discuss how the following affect compilation: polymorphic typing,
    referential transparency, higher-order functions, and lazy evaluation.
    
    What are curried functions?  How are they represented at run time?
    
    Write a function that takes three arguements and show how it would be
    evaluated at run time.
    
    How are the terms parallel, distributed, and concurrent related?
    
    What is a strength of each of the concurrency models discussed in
    class?
    
    Demonstrate the equivalence of shared variables and message passing.
    
    
    
    

Information is subject to change.
dhart@cs.uah.edu
Last modified: Wed Nov 7 13:17:37 CST 2001