CSc 4340/6340, Introduction to Compilers
Fall 2009
PROJECT - Phase II

Phase II: (Due: October 25, 2009 (Sunday)

Perform the following Semantic Checks on the DRC expression tree:

Before these checks are made, it will be a good idea if you perform the following transformations to the DRC Expression tree:

Phase 2 Notes

  1. Parent Pointer in DRCNode: Adding a "parent" pointer to DRCNode is useful in several Phase 2 functions: e.g. Demorgan and double not transformations. In addition, an integer field, called childPositionInParent, will also be useful. This will be set to i, where the DRCNode is the ith child of its parent.
  2. Please implement: compressTree, removeDoubleNots and applyDeMorgan methods to transform the binary tree produced by the parser.
  3. The following three variables will be extremely useful in the DRCNode data structure:
    Vector freeVariables; // will record the free variables for the node.
    HashMap freeVariableType; // will record the data type of the free
                              // variable (indexed by variable name).
    HashMap isFreeVariableLimited; // will record "yes" if free variable
                                   // is Limited, "no" otherwise 
    
    The following describes how the above 3 variables are computed for each node type (in an inductive manner):

Semantic Checks

  1. Predicate Check: Make sure all predicate names used in query correspond to database tables. Also make sure that arities of predicate names match number of columns in database table.
  2. Type Check: Type check all variables at each node (types are obtained from constants in query as well as data types in database.
  3. Safety Check: query variables on lhs of | must match free variables on rhs. free variables in all disjuncts of or-nodes must match. All free variables in and-nodes must be limited. parent of not-node MUST be and-node parent of comparison node MUST be and-node.

Misc

[raj@tinman phase1]$ java DRC db