CS 134b Computing Systems, Compilers, and Languages Laboratory (Winter 2001)

Prof. Hickey

Tools

Other Compiler Courses

Projects

  1. Splay tree - pratice OCaml. My solution.
    I found that different implementations of some basic operations exist.
    Splay(x,S) Reorganize S such that x is in the root or, if x is not in S, the root is either ...
    Member(x,S) Splay(x,S). If x is in S, x is now the root.
    Min(S); Max(S) Member(-Inf,S); Member(+Inf,S).
    Join(S,S') (assuming all the members of S are smaller than those of S'.) Max(S), set right(S) = S', i.e., make S' the right subtree of S, or Min(S'), set left(S') = S.
    Split(x,S,S',S'') Splay(x,S), S' = left(S)+S and S''=right(S), or, S' = left(S) and S'' = S+right(S), depending on S<=x or S>x.
    Insert(x,S) Split(x,S,S',S'') to get S' and S''. Make x the root and set left(x) = S' and right(x) = S''.
    A node is inserted as is done in a regular binary search tree, after the insertion the node is splayed to the top of the tree.
    Delete(x,S) Splay(x,S), Join(left(S), right(S))
    Find node; Find max of left subtree. It will have no right child, so make the right subtree the new right child.
    Predecessor(x,S) Splay(x,S), Max(left(S))
    Successor(x,S) Splay(x,S), Min(right(S))

    Related links:
  2. Lexing and Parsing (AST). Our solution.
    Convert the source code to AST (Abstract Syntax Tree).
  3. Semantic analysis and Type checking (IR). Our solution.
    Convert AST to IR (Intermediate Representation).
  4. FIR Generation (FIR). Our solution.
  5. Optimization & Code Generation (ASM). Our solution.