The CFG for Domain Relational Calculus (DRC) queries is given below:

Query ::= LBRACE VarList BAR Formula RBRACE
VarList ::= NAME | VarList COMMA NAME
Formula ::= AtomicFormula |
            Formula AND Formula |
            Formula OR Formula |
            NOT LPAREN Formula RPAREN |
            LPAREN EXISTS VarList RPAREN LPAREN Formula RPAREN |
            LPAREN FORALL VarList RPAREN LPAREN Formula RPAREN |
            LPAREN Formula RPAREN
AtomicFormula ::= 
            NAME LPAREN ArgList RPAREN |
            Arg COMPARISON Arg
ArgList ::= Arg | ArgList COMMA Arg
Arg ::= NAME | STRING | INTEGER | DECIMAL

Note: COMPARISON will be one of <, <=, >, >=, <>, =

DRCNode
-------
  String nodeType; // "query", "exists", "forall", "and", "or", "not", 
                    // "comparision", "predicate"
  DRCNode parent; // parent pointer
  int childPositionInParent; // what child is the node of its parent?
  Vector children; // pointers to DRCNodes - child nodes in AST
                   // Make sure element 0 and 1 are set for all nodes
  String predicateName;
  Vector argList;// used with predicate node
  Vector varlist; // used with query, Exists , forall

  Vector leftOperand; // used with comp
  leftOperandType; // num, str, var - used with comp
  Vector operator; // used with comp
  Vector rightOperand; // used with comp
  Vector rightOperandType; // num, str, var - used with comp

// The following are required only in Phase 2 and/or Phase 3
  Vector freeVariables;
  HashMap freeVariableTypes; // indexed by variable name 
                   // possible values: "INTEGER", "DECIMAL" or "VARCHAR"
  HashMap isFreeVariableLimited; // indexed by variable name
  boolean closedDRC; // is the DRC sub-expression at this node closed?
  int nodeNumber; // a unique node number - useful in naming temporary
                 // relations for sub-expressions - tempN