diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index ac4f527..e85b56b 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -1,8 +1,8 @@
 options {
 
-	  
+
        STATIC = false;
-	
+
 }
 
 
@@ -36,6 +36,7 @@
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
 import edu.uci.ics.asterix.aql.expression.visitor.AQLPrintVisitor;
 import edu.uci.ics.asterix.aql.expression.UnaryExpr.Sign;
+import edu.uci.ics.asterix.aql.expression.TypeExpression.TypeExprKind;
 import edu.uci.ics.asterix.aql.base.Statement.Kind;
 import edu.uci.ics.asterix.aql.context.Scope;
 import edu.uci.ics.asterix.aql.context.RootScopeFactory;
@@ -70,49 +71,49 @@
     private static final String DATETIME_BETWEEN_YEARS_HINT = "datetime-between-years";
     private static final String DATE_BETWEEN_YEARS_HINT = "date-between-years";
     private static final String DATETIME_ADD_RAND_HOURS_HINT = "datetime-add-rand-hours";
-    private static final String AUTO_HINT = "auto";   
-        
-    private static final String GEN_FIELDS_HINT = "gen-fields";   
-    
+    private static final String AUTO_HINT = "auto";
+
+    private static final String GEN_FIELDS_HINT = "gen-fields";
+
     // data generator hints
     private static final String DGEN_HINT = "dgen";
-    
+
     private static class IndexParams {
       public IndexType type;
       public int gramLength;
-      
+
       public IndexParams(IndexType type, int gramLength) {
         this.type = type;
         this.gramLength = gramLength;
       }
-    };  
-   
+    };
+
     private static class FunctionName {
-	   public String dataverse = null;
-	   public String library = null;
-	   public String function = null;
-	}
+       public String dataverse = null;
+       public String library = null;
+       public String function = null;
+    }
 
     private static String getHint(Token t) {
         if (t.specialToken == null) {
             return null;
-        }       
+        }
         String s = t.specialToken.image;
         int n = s.length();
         if (n < 2) {
             return null;
-        }  
+        }
         return s.substring(1).trim();
     }
-    
+
     private static IRecordFieldDataGen parseFieldDataGen(String hint) throws ParseException {
       IRecordFieldDataGen rfdg = null;
       String splits[] = hint.split(" +");
-      if (splits[0].equals(VAL_FILE_HINT)) { 
+      if (splits[0].equals(VAL_FILE_HINT)) {
         File[] valFiles = new File[splits.length - 1];
         for (int k=1; k<splits.length; k++) {
           valFiles[k-1] = new File(splits[k]);
-        } 
+        }
         rfdg = new FieldValFileDataGen(valFiles);
       } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) {
         rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]);
@@ -133,7 +134,7 @@
         } else {
           throw new ParseException("Unknown type for interval data gen: " + splits[1]);
         }
-        rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]); 
+        rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]);
       } else if (splits[0].equals(INSERT_RAND_INT_HINT)) {
         rfdg = new InsertRandIntDataGen(splits[1], splits[2]);
       } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) {
@@ -189,7 +190,7 @@
   )*
   <EOF>
   {
-    return decls;  
+    return decls;
   }
 }
 
@@ -208,7 +209,7 @@
     | stmt = SetStatement()
     | stmt = InsertStatement()
     | stmt = DeleteStatement()
-    | stmt = UpdateStatement()       
+    | stmt = UpdateStatement()
     | stmt = FeedStatement()
     | stmt = CompactStatement()
     | stmt = Query()
@@ -245,16 +246,16 @@
       hint = getHint(token);
       if (hint != null && hint.startsWith(DGEN_HINT)) {
         dgen = true;
-      }                  
+      }
     }
     stmt = TypeSpecification(hint, dgen)
     | stmt = NodegroupSpecification()
-    | stmt = DatasetSpecification()    
+    | stmt = DatasetSpecification()
     | stmt = IndexSpecification()
     | stmt = DataverseSpecification()
     | stmt = FunctionSpecification()
     | stmt = FeedSpecification()
-  )        
+  )
   {
     return stmt;
   }
@@ -272,14 +273,14 @@
     {
       long numValues = -1;
       String filename = null;
-      if (dgen) {       
+      if (dgen) {
         String splits[] = hint.split(" +");
         if (splits.length != 3) {
           throw new ParseException("Expecting /*+ dgen <filename> <numberOfItems> */");
-        } 
+        }
         filename = splits[1];
         numValues = Long.parseLong(splits[2]);
-      }  
+      }
       TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues);
       return new TypeDecl(nameComponents.first, nameComponents.second, typeExpr, tddg, ifNotExists);
     }
@@ -312,7 +313,7 @@
 
 DatasetDecl DatasetSpecification() throws ParseException:
 {
-  Pair<Identifier,Identifier> nameComponents = null;  
+  Pair<Identifier,Identifier> nameComponents = null;
   boolean ifNotExists = false;
   String typeName = null;
   String adapterName = null;
@@ -321,7 +322,7 @@
   FunctionSignature appliedFunction = null;
   List<String> primaryKeyFields = null;
   String nodeGroupName = null;
-  Map<String,String> hints = new HashMap<String,String>();  
+  Map<String,String> hints = new HashMap<String,String>();
   DatasetDecl dsetDecl = null;
   boolean autogenerated = false;
   String compactionPolicy = null;
@@ -350,13 +351,13 @@
                                    DatasetType.EXTERNAL,
                                    edd,
                                    ifNotExists);
-      } 
+      }
 
     | ("internal")? <DATASET> nameComponents = QualifiedName()
     <LEFTPAREN> typeName = Identifier() <RIGHTPAREN>
     ifNotExists = IfNotExists()
-    primaryKeyFields = PrimaryKey() 
-    ("autogenerated" { autogenerated = true; } )? 
+    primaryKeyFields = PrimaryKey()
+    ("autogenerated" { autogenerated = true; } )?
     ("on" nodeGroupName = Identifier() )?
     ( "hints" hints = Properties() )?
     ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
@@ -391,12 +392,12 @@
   String datasetName = null;
 }
 {
-	"refresh external" <DATASET> nameComponents = QualifiedName()
-	{
-	redss.setDataverseName(nameComponents.first);
-	redss.setDatasetName(nameComponents.second);
-	return redss;
-	}
+    "refresh external" <DATASET> nameComponents = QualifiedName()
+    {
+    redss.setDataverseName(nameComponents.first);
+    redss.setDatasetName(nameComponents.second);
+    return redss;
+    }
 }
 
 RunStatement RunStatement() throws ParseException:
@@ -414,7 +415,7 @@
     }
   )*<RIGHTPAREN>
   <FROM> <DATASET> nameComponentsFrom  = QualifiedName()
-  "to" <DATASET> nameComponentsTo  = QualifiedName() 
+  "to" <DATASET> nameComponentsTo  = QualifiedName()
     {
       return new RunStatement(system, parameters, nameComponentsFrom.first, nameComponentsFrom.second, nameComponentsTo.first, nameComponentsTo.second);
     }
@@ -432,7 +433,7 @@
 {
   "index" indexName = Identifier()
   ifNotExists = IfNotExists()
-  "on" nameComponents = QualifiedName()    
+  "on" nameComponents = QualifiedName()
   <LEFTPAREN> ( fieldExpr = Identifier()
     {
       cis.addFieldExpr(fieldExpr);
@@ -462,7 +463,7 @@
 {
   compactionPolicy = Identifier()
     {
-	  return compactionPolicy;
+      return compactionPolicy;
     }
 }
 
@@ -473,7 +474,7 @@
 {
   filterField = Identifier()
     {
-	  return filterField;
+      return filterField;
     }
 }
 
@@ -486,7 +487,7 @@
   ("btree"
     {
       type = IndexType.BTREE;
-    }         
+    }
   | "rtree"
     {
       type = IndexType.RTREE;
@@ -532,7 +533,7 @@
   Token beginPos;
   Token endPos;
   FunctionName fctName = null;
-  
+
   createNewScope();
 }
 {
@@ -542,7 +543,7 @@
   <LEFTBRACE>
   {
      beginPos = token;
-  } 
+  }
   functionBodyExpr = Expression() <RIGHTBRACE>
     {
       endPos = token;
@@ -557,7 +558,7 @@
 
 CreateFeedStatement FeedSpecification() throws ParseException:
 {
-  Pair<Identifier,Identifier> nameComponents = null;  
+  Pair<Identifier,Identifier> nameComponents = null;
   boolean ifNotExists = false;
   String adapterName = null;
   Map<String,String> properties = null;
@@ -573,8 +574,8 @@
       {
         cfs = new CreateFeedStatement(nameComponents.first,
                                    nameComponents.second, adapterName, properties, appliedFunction, ifNotExists);
-      } 
-      
+      }
+
   )
     {
       return cfs;
@@ -641,12 +642,12 @@
   String policy = null;
 }
 {
-   "using" "policy" policy = Identifier() 
+   "using" "policy" policy = Identifier()
    {
      return policy;
    }
-   
-}   
+
+}
 
 FunctionSignature FunctionSignature() throws ParseException:
 {
@@ -654,15 +655,15 @@
   int arity = 0;
 }
 {
-  fctName = FunctionName() "@" <INTEGER_LITERAL> 
-    {  
+  fctName = FunctionName() "@" <INTEGER_LITERAL>
+    {
       arity = new Integer(token.image);
       if (arity < 0 && arity != FunctionIdentifier.VARARGS) {
         throw new ParseException(" invalid arity:" + arity);
       }
 
       // TODO use fctName.library
-      String fqFunctionName = fctName.library == null ? fctName.function : fctName.library + "#" + fctName.function;      
+      String fqFunctionName = fctName.library == null ? fctName.function : fctName.library + "#" + fctName.function;
       return new FunctionSignature(fctName.dataverse, fqFunctionName, arity);
     }
 }
@@ -726,10 +727,10 @@
     | "feed" pairId = QualifiedName() ifExists = IfExists()
       {
         stmt = new FeedDropStatement(pairId.first, pairId.second, ifExists);
-      }  
+      }
   )
   {
-    return stmt;  
+    return stmt;
   }
 }
 
@@ -767,14 +768,14 @@
   // This is related to the new metadata lock management
   setDataverses(new ArrayList<String>());
   setDatasets(new ArrayList<String>());
-  
+
 }
 {
   "delete" var = Variable()
     {
       getCurrentScope().addNewVarSymbolToScope(var.getVar());
     }
-  <FROM> <DATASET> nameComponents  = QualifiedName() 
+  <FROM> <DATASET> nameComponents  = QualifiedName()
   (<WHERE> condition = Expression())?
     {
       // First we get the dataverses and datasets that we want to lock
@@ -783,8 +784,8 @@
       // we remove the pointer to the dataverses and datasets
       setDataverses(null);
       setDatasets(null);
-      return new DeleteStatement(var, nameComponents.first, nameComponents.second, 
-      	condition, getVarCounter(), dataverses, datasets);
+      return new DeleteStatement(var, nameComponents.first, nameComponents.second,
+          condition, getVarCounter(), dataverses, datasets);
     }
 }
 
@@ -798,7 +799,7 @@
 }
 {
   "update" vars = Variable() <IN> target = Expression()
-  <WHERE> condition = Expression() 
+  <WHERE> condition = Expression()
   <LEFTPAREN> (uc = UpdateClause()
     {
       ucs.add(uc);
@@ -816,7 +817,7 @@
 UpdateClause UpdateClause() throws ParseException:
 {
   Expression target = null;
-  Expression value = null ;	
+  Expression value = null ;
   InsertStatement is = null;
   DeleteStatement ds = null;
   UpdateStatement us = null;
@@ -825,13 +826,13 @@
   UpdateClause elsebranch = null;
 }
 {
-   "set" target = Expression() <ASSIGN> value = Expression() 
+   "set" target = Expression() <ASSIGN> value = Expression()
    | is = InsertStatement()
    | ds = DeleteStatement()
    | us = UpdateStatement()
    | <IF> <LEFTPAREN> condition = Expression() <RIGHTPAREN>
      <THEN> ifbranch = UpdateClause()
-     [LOOKAHEAD(1) <ELSE> elsebranch = UpdateClause()] 
+     [LOOKAHEAD(1) <ELSE> elsebranch = UpdateClause()]
      {
        return new UpdateClause(target, value, is, ds, us, condition, ifbranch, elsebranch);
      }
@@ -860,8 +861,8 @@
 {
   "write" "output" "to" nodeName = Identifier() <COLON> fileName = StringLiteral()
     ( "using" writerClass = StringLiteral() )?
-    {                  
-      return new WriteStatement(new Identifier(nodeName), fileName, writerClass);         
+    {
+      return new WriteStatement(new Identifier(nodeName), fileName, writerClass);
     }
 }
 
@@ -881,14 +882,14 @@
       datasetName = nameComponents.second;
     }
   "using" adapterName = AdapterName() properties = Configuration()
-  ("pre-sorted" 
+  ("pre-sorted"
     {
       alreadySorted = true;
     }
   )?
     {
       return new LoadStatement(dataverseName, datasetName, adapterName, properties, alreadySorted);
-    }   
+    }
 }
 
 
@@ -899,7 +900,7 @@
 {
   adapterName = Identifier()
     {
-	  return adapterName;
+      return adapterName;
     }
 }
 
@@ -911,10 +912,10 @@
 {
   "compact" <DATASET> nameComponents = QualifiedName()
     {
-	  stmt = new CompactStatement(nameComponents.first, nameComponents.second);
+      stmt = new CompactStatement(nameComponents.first, nameComponents.second);
     }
     {
-	  return stmt;  
+      return stmt;
     }
 }
 
@@ -922,14 +923,14 @@
 {
   Pair<Identifier,Identifier> feedNameComponents = null;
   Pair<Identifier,Identifier> datasetNameComponents = null;
-  
+
   Map<String,String> configuration = null;
   Statement stmt = null;
   String policy = null;
 }
 {
   (
-    "connect" "feed" feedNameComponents = QualifiedName() "to" <DATASET> datasetNameComponents = QualifiedName() (policy = GetPolicy())? 
+    "connect" "feed" feedNameComponents = QualifiedName() "to" <DATASET> datasetNameComponents = QualifiedName() (policy = GetPolicy())?
       {
         stmt = new ConnectFeedStatement(feedNameComponents, datasetNameComponents, policy, getVarCounter());
       }
@@ -945,8 +946,8 @@
 
 Map<String,String> Configuration()  throws ParseException :
 {
-	Map<String,String> configuration = new LinkedHashMap<String,String>();
-	Pair<String, String> keyValuePair = null;
+    Map<String,String> configuration = new LinkedHashMap<String,String>();
+    Pair<String, String> keyValuePair = null;
 }
 {
   <LEFTPAREN> ( keyValuePair = KeyValuePair()
@@ -972,7 +973,7 @@
   <LEFTPAREN> key = StringLiteral() <EQ> value = StringLiteral() <RIGHTPAREN>
     {
       return new Pair<String, String>(key, value);
-    }  
+    }
 }
 
 Map<String,String> Properties() throws ParseException:
@@ -985,7 +986,7 @@
     {
       properties.put(property.first, property.second);
     }
-  ( <COMMA> property = Property() 
+  ( <COMMA> property = Property()
     {
       properties.put(property.first, property.second);
     }
@@ -1006,13 +1007,13 @@
       try {
         value = "" + Long.valueOf(token.image);
       } catch (NumberFormatException nfe) {
-        throw new ParseException("inapproriate value: " + token.image); 
+        throw new ParseException("inapproriate value: " + token.image);
       }
     }
   )
     {
       return new Pair<String, String>(key.toUpperCase(), value);
-    }  
+    }
 }
 
 TypeExpression TypeExpr() throws ParseException:
@@ -1024,8 +1025,8 @@
       typeExpr = RecordTypeDef()
     | typeExpr = TypeReference()
     | typeExpr = OrderedListTypeDef()
-    | typeExpr = UnorderedListTypeDef()  
-  )  
+    | typeExpr = UnorderedListTypeDef()
+  )
   {
     return typeExpr;
   }
@@ -1034,15 +1035,15 @@
 RecordTypeDefinition RecordTypeDef() throws ParseException:
 {
   RecordTypeDefinition recType = new RecordTypeDefinition();
-  RecordTypeDefinition.RecordKind recordKind = null; 
+  RecordTypeDefinition.RecordKind recordKind = null;
 }
 {
-  ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; } 
+  ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; }
     | "open" { recordKind = RecordTypeDefinition.RecordKind.OPEN; } )?
    <LEFTBRACE>
     {
       String hint = getHint(token);
-      if (hint != null) { 
+      if (hint != null) {
         String splits[] = hint.split(" +");
         if (splits[0].equals(GEN_FIELDS_HINT)) {
           if (splits.length != 5) {
@@ -1050,18 +1051,18 @@
           }
           if (!splits[1].equals("int")) {
             throw new ParseException("The only supported type for gen-fields is int.");
-          } 
-          UndeclaredFieldsDataGen ufdg = new UndeclaredFieldsDataGen(UndeclaredFieldsDataGen.Type.INT, 
+          }
+          UndeclaredFieldsDataGen ufdg = new UndeclaredFieldsDataGen(UndeclaredFieldsDataGen.Type.INT,
              Integer.parseInt(splits[2]), Integer.parseInt(splits[3]), splits[4]);
-          recType.setUndeclaredFieldsDataGen(ufdg);   
+          recType.setUndeclaredFieldsDataGen(ufdg);
         }
-      }  
-      
+      }
+
     }
-		( 
-		  RecordField(recType)
-		  ( <COMMA>  RecordField(recType) )*
-		)?
+        (
+          RecordField(recType)
+          ( <COMMA>  RecordField(recType) )*
+        )?
    <RIGHTBRACE>
    {
       if (recordKind == null) {
@@ -1069,13 +1070,13 @@
       }
       recType.setRecordKind(recordKind);
       return recType;
-   } 
+   }
 }
 
 void RecordField(RecordTypeDefinition recType) throws ParseException:
 {
   String fieldName;
-  TypeExpression type = null; 
+  TypeExpression type = null;
   boolean nullable = false;
 }
 {
@@ -1087,7 +1088,7 @@
   <COLON> type =  TypeExpr() (<QUES> { nullable = true; } )?
     {
       recType.addField(fieldName, type, nullable, rfdg);
-    }   
+    }
 }
 
 TypeReferenceExpression TypeReference() throws ParseException:
@@ -1097,12 +1098,16 @@
 {
  id = Identifier()
    {
+     if (id.equalsIgnoreCase("int")) {
+        id = "int64";
+     }
+
      return new TypeReferenceExpression(new Identifier(id));
    }
 }
 
 OrderedListTypeDefinition OrderedListTypeDef() throws ParseException:
-{  
+{
   TypeExpression type = null;
 }
 {
@@ -1116,7 +1121,7 @@
 
 
 UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException:
-{  
+{
   TypeExpression type = null;
 }
 {
@@ -1145,25 +1150,29 @@
       FunctionName result = new FunctionName();
       if (second == null) {
         result.dataverse = defaultDataverse;
-        result.library   = null;
-        result.function  = first;
+        result.library = null;
+        result.function = first;
       } else if (third == null) {
         if (secondAfterDot) {
           result.dataverse = first;
           result.library   = null;
-          result.function  = second;
+          result.function = second;
         } else {
           result.dataverse = defaultDataverse;
           result.library   = first;
-          result.function  = second;
+          result.function = second;
         }
       } else {
         result.dataverse = first;
         result.library   = second;
         result.function  = third;
       }
+
+      if (result.function.equalsIgnoreCase("int")) {
+            result.function = "int64";
+      }
       return result;
-    }  
+    }
 }
 
 
@@ -1193,7 +1202,7 @@
   | lit = StringLiteral()
     {
       return lit;
-    } 
+    }
 }
 
 String StringLiteral() throws ParseException:
@@ -1224,9 +1233,9 @@
       id2 = new Identifier(second);
     }
     return new Pair<Identifier,Identifier>(id1, id2);
-  }  
-}  
-  
+  }
+}
+
 Triple<Identifier,Identifier,Identifier> DoubleQualifiedName() throws ParseException:
 {
   String first = null;
@@ -1248,8 +1257,8 @@
       id3 = new Identifier(third);
     }
     return new Triple<Identifier,Identifier,Identifier>(id1, id2, id3);
-  }  
-}  
+  }
+}
 
 FunctionDecl FunctionDeclaration() throws ParseException:
 {
@@ -1292,7 +1301,7 @@
       setDatasets(null);
       return query;
     }
-     
+
 }
 
 
@@ -1304,18 +1313,18 @@
 }
 {
 (
-  
+
 //OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression
     expr = OperatorExpr()
     | expr = IfThenElse()
     | expr = FLWOGR()
     | expr = QuantifiedExpression()
-   
+
 
 )
-	{
-	  return (exprP==null) ? expr : exprP;
-	}
+    {
+      return (exprP==null) ? expr : exprP;
+    }
 }
 
 
@@ -1326,29 +1335,29 @@
   Expression operand = null;
 }
 {
-	operand = AndExpr()
-	(
-	
-	  <OR>
-  	{
-  	  if (op == null) {
-  	    op = new OperatorExpr();
-  	    op.addOperand(operand);
-	    op.setCurrentop(true);  	      	     
-  	  }  
+    operand = AndExpr()
+    (
+
+      <OR>
+      {
+        if (op == null) {
+          op = new OperatorExpr();
+          op.addOperand(operand);
+        op.setCurrentop(true);
+        }
       op.addOperator(token.image);
-	}
+    }
 
-	operand = AndExpr()
-	{
-	  op.addOperand(operand);
-	}
+    operand = AndExpr()
+    {
+      op.addOperand(operand);
+    }
 
-	)*
-	
-	{
-	  return op==null? operand: op;
-	}
+    )*
+
+    {
+      return op==null? operand: op;
+    }
 }
 
 Expression AndExpr()throws ParseException:
@@ -1357,29 +1366,29 @@
   Expression operand = null;
 }
 {
-	operand = RelExpr()
-	(
-	
-	  <AND>
-  	{
-  	  if (op == null) {
-  	    op = new OperatorExpr();
-  	    op.addOperand(operand);
-	    op.setCurrentop(true);  	      	     
-  	  }  
+    operand = RelExpr()
+    (
+
+      <AND>
+      {
+        if (op == null) {
+          op = new OperatorExpr();
+          op.addOperand(operand);
+        op.setCurrentop(true);
+        }
       op.addOperator(token.image);
-	}
+    }
 
-	operand = RelExpr()
-	{
-	  op.addOperand(operand);
-	}
+    operand = RelExpr()
+    {
+      op.addOperand(operand);
+    }
 
-	)*
-	
-	{
-	  return op==null? operand: op;
-	}
+    )*
+
+    {
+      return op==null? operand: op;
+    }
 }
 
 
@@ -1393,83 +1402,83 @@
 }
 {
     operand = AddExpr()
-    { 
-      if (operand instanceof VariableExpr) {        
-        String hint = getHint(token);        
+    {
+      if (operand instanceof VariableExpr) {
+        String hint = getHint(token);
         if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
           broadcast = true;
         }
       }
-    } 
+    }
 
     (
       LOOKAHEAD(2)( <LT> | <GT> | <LE> | <GE> | <EQ> | <NE> |<SIMILAR>)
-  	  {
-  	    String mhint = getHint(token);
-  	    if (mhint != null) {
-  	      if (mhint.equals(INDEXED_NESTED_LOOP_JOIN_HINT)) {
+        {
+          String mhint = getHint(token);
+          if (mhint != null) {
+            if (mhint.equals(INDEXED_NESTED_LOOP_JOIN_HINT)) {
             annotation = IndexedNLJoinExpressionAnnotation.INSTANCE;
           } else if (mhint.equals(SKIP_SECONDARY_INDEX_SEARCH_HINT)) {
             annotation = SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE;
           }
         }
-  	    if (op == null) {
-  	      op = new OperatorExpr();
-  	      op.addOperand(operand, broadcast);
+          if (op == null) {
+            op = new OperatorExpr();
+            op.addOperand(operand, broadcast);
           op.setCurrentop(true);
           broadcast = false;
-  	    }
+          }
         op.addOperator(token.image);
-	  }
-	  
- 	  operand = AddExpr()
-	  {
-         broadcast = false;	     
+      }
+
+       operand = AddExpr()
+      {
+         broadcast = false;
          if (operand instanceof VariableExpr) {
-           String hint = getHint(token);        
+           String hint = getHint(token);
            if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
              broadcast = true;
            }
          }
          op.addOperand(operand, broadcast);
-      } 
+      }
     )?
- 	
- 	{
- 	  if (annotation != null) {
- 	    op.addHint(annotation);
- 	  }
- 	  return op==null? operand: op;
- 	}
+
+     {
+       if (annotation != null) {
+         op.addHint(annotation);
+       }
+       return op==null? operand: op;
+     }
 }
 
 Expression AddExpr()throws ParseException:
 {
   OperatorExpr op = null;
-  Expression operand = null;  
+  Expression operand = null;
 }
 {
-	operand = MultExpr()
+    operand = MultExpr()
 
-	( (<PLUS> | <MINUS>)
-  	{
-  	  if (op == null) {
-  	    op = new OperatorExpr();
-        op.addOperand(operand);  	    
-        op.setCurrentop(true);        
-  	  }
-	  ((OperatorExpr)op).addOperator(token.image);
-	}
+    ( (<PLUS> | <MINUS>)
+      {
+        if (op == null) {
+          op = new OperatorExpr();
+        op.addOperand(operand);
+        op.setCurrentop(true);
+        }
+      ((OperatorExpr)op).addOperator(token.image);
+    }
 
-	operand = MultExpr()
-	{
-	  op.addOperand(operand);
-	}
-	)*
-	
-	{
- 	  return op==null? operand: op;
- 	}
+    operand = MultExpr()
+    {
+      op.addOperand(operand);
+    }
+    )*
+
+    {
+       return op==null? operand: op;
+     }
 }
 
 Expression MultExpr()throws ParseException:
@@ -1478,26 +1487,26 @@
   Expression operand = null;
 }
 {
-	operand = UnionExpr()
+    operand = UnionExpr()
 
-	(( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV>)
-  	{
-  	  if (op == null) {
-  	    op = new OperatorExpr();
+    (( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV>)
+      {
+        if (op == null) {
+          op = new OperatorExpr();
         op.addOperand(operand);
-        op.setCurrentop(true);          	    
-  	  }
-	  op.addOperator(token.image);
-	}
-	operand = UnionExpr()
-	{
-	   op.addOperand(operand);
-	}
-	)*
-	
- 	{
- 	  return op==null?operand:op;
- 	}	
+        op.setCurrentop(true);
+        }
+      op.addOperator(token.image);
+    }
+    operand = UnionExpr()
+    {
+       op.addOperand(operand);
+    }
+    )*
+
+     {
+       return op==null?operand:op;
+     }
 }
 
 Expression UnionExpr() throws ParseException:
@@ -1507,14 +1516,14 @@
     Expression operand2 = null;
 }
 {
-   operand1 = UnaryExpr() 
-   (<UNION> 
+   operand1 = UnaryExpr()
+   (<UNION>
        (operand2 = UnaryExpr()) {
           if (union == null) {
              union = new UnionExpr();
-             union.addExpr(operand1); 
+             union.addExpr(operand1);
           }
-          union.addExpr(operand2);   
+          union.addExpr(operand2);
        } )*
    {
      return (union == null)? operand1: union;
@@ -1523,32 +1532,32 @@
 
 Expression UnaryExpr() throws ParseException:
 {
-	Expression uexpr = null;
-	Expression expr = null;
+    Expression uexpr = null;
+    Expression expr = null;
 }
 {
-	( (<PLUS> | <MINUS>) 
-	{
-	  	uexpr = new UnaryExpr();
-		if("+".equals(token.image))
-			((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
-		else if("-".equals(token.image))
-			((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
-		else 
-			throw new ParseException();
-	}
-	)?
-	
-	expr = ValueExpr()
-	{
-		if(uexpr!=null){
-			((UnaryExpr)uexpr).setExpr(expr);
-			return uexpr;
-		}
-		else{
-			return expr;
-		}
-	}
+    ( (<PLUS> | <MINUS>)
+    {
+          uexpr = new UnaryExpr();
+        if("+".equals(token.image))
+            ((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
+        else if("-".equals(token.image))
+            ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
+        else
+            throw new ParseException();
+    }
+    )?
+
+    expr = ValueExpr()
+    {
+        if(uexpr!=null){
+            ((UnaryExpr)uexpr).setExpr(expr);
+            return uexpr;
+        }
+        else{
+            return expr;
+        }
+    }
 }
 
 Expression ValueExpr()throws ParseException:
@@ -1560,8 +1569,8 @@
 }
 {
   expr = PrimaryExpr() ( ident = Field()
-	{
-	  fa = (fa == null ? new FieldAccessor(expr, ident) 
+    {
+      fa = (fa == null ? new FieldAccessor(expr, ident)
                        : new FieldAccessor(fa, ident));
     }
   | indexExpr = Index()
@@ -1588,29 +1597,29 @@
 
 Expression Index() throws ParseException:
 {
-	Expression expr = null;
+    Expression expr = null;
 }
 {
   <LEFTBRACKET> ( expr = Expression()
-	{
-		if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION)
-		{
-			Literal lit = ((LiteralExpr)expr).getValue();
-			if(lit.getLiteralType() != Literal.Type.INTEGER &&
-			   lit.getLiteralType() != Literal.Type.LONG) {
-				throw new ParseException("Index should be an INTEGER");				
+    {
+        if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION)
+        {
+            Literal lit = ((LiteralExpr)expr).getValue();
+            if(lit.getLiteralType() != Literal.Type.INTEGER &&
+               lit.getLiteralType() != Literal.Type.LONG) {
+                throw new ParseException("Index should be an INTEGER");
             }
-		}
-	}
+        }
+    }
 
-  	| <QUES> // ANY
- 	 
-  	)
+      | <QUES> // ANY
+
+      )
 
    <RIGHTBRACKET>
-	{
-	  return expr;
-	}
+    {
+      return expr;
+    }
 }
 
 
@@ -1619,11 +1628,11 @@
   Expression expr = null;
 }
 {
-  ( LOOKAHEAD(2) 
+  ( LOOKAHEAD(2)
     expr = FunctionCallExpr()
   | expr = Literal()
   | expr = DatasetAccessExpression()
-  | expr = VariableRef() 
+  | expr = VariableRef()
     {
       if(((VariableExpr)expr).getIsNewVar() == true)
         throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar());
@@ -1649,11 +1658,7 @@
     }
   | <INTEGER_LITERAL>
     {
-      try {
-        lit.setValue(new IntegerLiteral(new Integer(token.image)));
-      } catch(NumberFormatException ex) {
-        lit.setValue(new LongIntegerLiteral(new Long(token.image)));
-      }
+      lit.setValue(new LongIntegerLiteral(new Long(token.image)));
     }
   | <FLOAT_LITERAL>
     {
@@ -1670,7 +1675,7 @@
   | <TRUE>
     {
       lit.setValue(TrueLiteral.INSTANCE);
-    }      
+    }
   | <FALSE>
     {
       lit.setValue(FalseLiteral.INSTANCE);
@@ -1684,24 +1689,24 @@
 
 VariableExpr VariableRef() throws ParseException:
 {
-	VariableExpr varExp = new VariableExpr();
-	VarIdentifier var = new VarIdentifier();
+    VariableExpr varExp = new VariableExpr();
+    VarIdentifier var = new VarIdentifier();
 }
 {
   <VARIABLE>
     {
-     String varName = token.image; 
+     String varName = token.image;
      Identifier ident = lookupSymbol(varName);
      if (isInForbiddenScopes(varName)) {
        throw new ParseException("Inside limit clauses, it is disallowed to reference a variable having the same name as any variable bound in the same scope as the limit clause.");
      }
      if(ident != null) { // exist such ident
        varExp.setIsNewVar(false);
-       varExp.setVar((VarIdentifier)ident);       
+       varExp.setVar((VarIdentifier)ident);
      } else {
-       varExp.setVar(var);     
+       varExp.setVar(var);
      }
-     var.setValue(varName);        
+     var.setValue(varName);
      return varExp;
     }
 }
@@ -1709,8 +1714,8 @@
 
 VariableExpr Variable() throws ParseException:
 {
-	VariableExpr varExp = new VariableExpr();
-	VarIdentifier var = new VarIdentifier();
+    VariableExpr varExp = new VariableExpr();
+    VarIdentifier var = new VarIdentifier();
 }
 {
   <VARIABLE>
@@ -1718,22 +1723,22 @@
      Identifier ident = lookupSymbol(token.image);
      if(ident != null) { // exist such ident
        varExp.setIsNewVar(false);
-     }  
-     varExp.setVar(var);     
-     var.setValue(token.image);        
+     }
+     varExp.setVar(var);
+     var.setValue(token.image);
      return varExp;
     }
 }
 
 Expression ListConstructor() throws ParseException:
 {
-	Expression expr = null;
+    Expression expr = null;
 }
 {
     (
-    	expr = OrderedListConstructor() | expr = UnorderedListConstructor()
+        expr = OrderedListConstructor() | expr = UnorderedListConstructor()
     )
-    
+
     {
       return expr;
     }
@@ -1742,55 +1747,55 @@
 
 ListConstructor OrderedListConstructor() throws ParseException:
 {
-  	ListConstructor expr = new ListConstructor();
-  	Expression tmp = null;
-  	List<Expression> exprList = new ArrayList<Expression>();
-  	expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
+      ListConstructor expr = new ListConstructor();
+      Expression tmp = null;
+      List<Expression> exprList = new ArrayList<Expression>();
+      expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
 }
 {
 
-    <LEFTBRACKET> 
-	    ( tmp = Expression()
-			{
-			  exprList.add(tmp);
-			}
-		
-		    (<COMMA> tmp = Expression() { exprList.add(tmp);  })*
-	    )? 
-    
+    <LEFTBRACKET>
+        ( tmp = Expression()
+            {
+              exprList.add(tmp);
+            }
+
+            (<COMMA> tmp = Expression() { exprList.add(tmp);  })*
+        )?
+
     <RIGHTBRACKET>
 
     {
       expr.setExprList(exprList);
       return expr;
-    }    
+    }
 }
 
 ListConstructor UnorderedListConstructor() throws ParseException:
 {
-  	ListConstructor expr = new ListConstructor();
-  	Expression tmp = null;
-  	List<Expression> exprList = new ArrayList<Expression>();
-  	expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
+      ListConstructor expr = new ListConstructor();
+      Expression tmp = null;
+      List<Expression> exprList = new ArrayList<Expression>();
+      expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
 }
 {
 
     <LEFTDBLBRACE> ( tmp = Expression()
-	{
-	  exprList.add(tmp);
-	}
+    {
+      exprList.add(tmp);
+    }
     (<COMMA> tmp = Expression() { exprList.add(tmp);  })*)? <RIGHTDBLBRACE>
     {
       expr.setExprList(exprList);
       return expr;
-    }    
+    }
 }
 
 RecordConstructor RecordConstructor() throws ParseException:
 {
-  	RecordConstructor expr = new RecordConstructor();
-  	FieldBinding tmp = null;
-  	List<FieldBinding> fbList = new ArrayList<FieldBinding>();
+      RecordConstructor expr = new RecordConstructor();
+      FieldBinding tmp = null;
+      List<FieldBinding> fbList = new ArrayList<FieldBinding>();
 }
 {
     <LEFTBRACE> (tmp = FieldBinding()
@@ -1801,13 +1806,13 @@
     {
       expr.setFbList(fbList);
       return expr;
-    }       
+    }
 }
 
 FieldBinding FieldBinding() throws ParseException:
 {
-	FieldBinding fb = new FieldBinding();
-	Expression left, right;
+    FieldBinding fb = new FieldBinding();
+    Expression left, right;
 }
 {
     left = Expression() <COLON> right = Expression()
@@ -1828,7 +1833,7 @@
   FunctionName funcName = null;
   String hint = null;
 }
-{  
+{
   funcName = FunctionName()
     {
       hint = getHint(token);
@@ -1872,25 +1877,25 @@
   String arg2 = null;
   Expression nameArg;
 }
-{  
+{
   <DATASET>
     {
       funcName = token.image;
     }
-  ( ( arg1 = Identifier() ( <DOT> arg2 = Identifier() )? ) 
+  ( ( arg1 = Identifier() ( <DOT> arg2 = Identifier() )? )
     {
       String name = arg2 == null ? arg1 : arg1 + "." + arg2;
       LiteralExpr ds = new LiteralExpr();
       ds.setValue( new StringLiteral(name) );
       nameArg = ds;
       if(arg2 != null){
-      	addDataverse(arg1.toString());
-      	addDataset(name);
+          addDataverse(arg1.toString());
+          addDataset(name);
       } else {
-      	addDataset(defaultDataverse + "." + name);
+          addDataset(defaultDataverse + "." + name);
       }
     }
-  | ( <LEFTPAREN> nameArg = Expression() <RIGHTPAREN> ) )  
+  | ( <LEFTPAREN> nameArg = Expression() <RIGHTPAREN> ) )
     {
       String dataverse = MetadataConstants.METADATA_DATAVERSE_NAME;
       FunctionSignature signature = lookupFunctionSignature(dataverse, funcName, 1);
@@ -1934,11 +1939,11 @@
 
 Expression  FLWOGR() throws ParseException:
 {
-	FLWOGRExpression flworg = new FLWOGRExpression();
-	List<Clause> clauseList = new ArrayList<Clause>();
-	Expression returnExpr;
-	Clause tmp;
-	createNewScope();
+    FLWOGRExpression flworg = new FLWOGRExpression();
+    List<Clause> clauseList = new ArrayList<Clause>();
+    Expression returnExpr;
+    Clause tmp;
+    createNewScope();
 }
 {
      (tmp = ForClause()  {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);})
@@ -1958,11 +1963,11 @@
 }
 {
     (
-         clause = ForClause() 
-       | clause = LetClause() 
-       | clause = WhereClause() 
-       | clause = OrderbyClause() 
-       | clause = GroupClause() 
+         clause = ForClause()
+       | clause = LetClause()
+       | clause = WhereClause()
+       | clause = OrderbyClause()
+       | clause = GroupClause()
        | clause = LimitClause()
        | clause = DistinctClause()
     )
@@ -1973,11 +1978,11 @@
 
 Clause ForClause()throws ParseException :
 {
-	ForClause fc = new ForClause();
-	VariableExpr varExp;
-	VariableExpr varPos = null;
-	Expression inExp;
-	extendCurrentScope();
+    ForClause fc = new ForClause();
+    VariableExpr varExp;
+    VariableExpr varPos = null;
+    Expression inExp;
+    extendCurrentScope();
 }
 {
     (<FOR>|<FROM>) varExp = Variable() (<AT> varPos = Variable())?  <IN> ( inExp = Expression() )
@@ -1987,7 +1992,7 @@
       fc.setInExpr(inExp);
       if (varPos != null) {
         fc.setPosExpr(varPos);
-	    getCurrentScope().addNewVarSymbolToScope(varPos.getVar());
+        getCurrentScope().addNewVarSymbolToScope(varPos.getVar());
       }
       return fc;
     }
@@ -1995,10 +2000,10 @@
 
 Clause LetClause() throws ParseException:
 {
-	LetClause lc = new LetClause();
-	VariableExpr varExp;
-	Expression beExp;
-	extendCurrentScope();
+    LetClause lc = new LetClause();
+    VariableExpr varExp;
+    Expression beExp;
+    extendCurrentScope();
 }
 {
     (<LET>|<WITH>) varExp = Variable() <ASSIGN> beExp = Expression()
@@ -2033,28 +2038,28 @@
 }
 {
   (
-    <ORDER> 
+    <ORDER>
       {
          String hint = getHint(token);
          if (hint != null && hint.startsWith(INMEMORY_HINT)) {
-           String splits[] = hint.split(" +"); 
+           String splits[] = hint.split(" +");
            int numFrames = Integer.parseInt(splits[1]);
            int numTuples = Integer.parseInt(splits[2]);
            oc.setNumFrames(numFrames);
-           oc.setNumTuples(numTuples);   
-         } 
-      }     
+           oc.setNumTuples(numTuples);
+         }
+      }
     <BY> orderbyExpr = Expression()
     {
       orderbyList.add(orderbyExpr);
-      OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC;       
+      OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC;
     }
     ( (<ASC> { modif = OrderbyClause.OrderModifier.ASC; })
     | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))?
     {
       modifierList.add(modif);
     }
-    
+
     (<COMMA> orderbyExpr = Expression()
     {
       orderbyList.add(orderbyExpr);
@@ -2064,7 +2069,7 @@
     | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))?
     {
       modifierList.add(modif);
-    }    
+    }
     )*
 )
     {
@@ -2075,73 +2080,73 @@
 }
 Clause GroupClause()throws ParseException :
 {
-  	GroupbyClause gbc = new GroupbyClause();
-  	// GbyVariableExpressionPair pair = new GbyVariableExpressionPair();
- 	List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>();
+      GroupbyClause gbc = new GroupbyClause();
+      // GbyVariableExpressionPair pair = new GbyVariableExpressionPair();
+     List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>();
     List<GbyVariableExpressionPair> decorPairList = new ArrayList<GbyVariableExpressionPair>();
-	List<VariableExpr> withVarList= new ArrayList<VariableExpr>();
-	VariableExpr var = null;
-	VariableExpr withVar = null;
-	Expression expr = null;
-	VariableExpr decorVar = null;
-	Expression decorExpr = null;
+    List<VariableExpr> withVarList= new ArrayList<VariableExpr>();
+    VariableExpr var = null;
+    VariableExpr withVar = null;
+    Expression expr = null;
+    VariableExpr decorVar = null;
+    Expression decorExpr = null;
 }
 {
-  	{
-  	  Scope newScope = extendCurrentScopeNoPush(true); 
-  	  // extendCurrentScope(true);
-  	}
+      {
+        Scope newScope = extendCurrentScopeNoPush(true);
+        // extendCurrentScope(true);
+      }
     <GROUP>
       {
          String hint = getHint(token);
          if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) {
-           gbc.setHashGroupByHint(true);   
-         } 
-      } 
+           gbc.setHashGroupByHint(true);
+         }
+      }
     <BY> (LOOKAHEAD(2)  var = Variable()
     {
       newScope.addNewVarSymbolToScope(var.getVar());
     } <ASSIGN>)?
-    expr = Expression() 
+    expr = Expression()
        {
-         GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr);    
+         GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr);
          vePairList.add(pair1);
        }
     (<COMMA> ( LOOKAHEAD(2) var = Variable()
     {
       newScope.addNewVarSymbolToScope(var.getVar());
     } <ASSIGN>)?
-    	expr = Expression()  
-    	 {
-           GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr);    
+        expr = Expression()
+         {
+           GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr);
            vePairList.add(pair2);
          }
-    	)*
+        )*
     (<DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression()
-       {    
-         newScope.addNewVarSymbolToScope(decorVar.getVar()); 
+       {
+         newScope.addNewVarSymbolToScope(decorVar.getVar());
          GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr);
          decorPairList.add(pair3);
        }
       (<COMMA> <DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression()
-           { 
-             newScope.addNewVarSymbolToScope(decorVar.getVar()); 
+           {
+             newScope.addNewVarSymbolToScope(decorVar.getVar());
              GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr);
-             decorPairList.add(pair4);              
+             decorPairList.add(pair4);
            }
-       )*            
-    )?	
+       )*
+    )?
     (<WITH>|<KEEPING>) withVar = VariableRef()
     {
       if(withVar.getIsNewVar()==true)
-      	throw new ParseException("can't find variable " + withVar.getVar());
+          throw new ParseException("can't find variable " + withVar.getVar());
       withVarList.add(withVar);
       newScope.addNewVarSymbolToScope(withVar.getVar());
     }
     (<COMMA> withVar = VariableRef()
     {
       if(withVar.getIsNewVar()==true)
-      	throw new ParseException("can't find variable " + withVar.getVar());
+          throw new ParseException("can't find variable " + withVar.getVar());
       withVarList.add(withVar);
       newScope.addNewVarSymbolToScope(withVar.getVar());
     })*
@@ -2157,16 +2162,16 @@
 
 LimitClause LimitClause() throws ParseException:
 {
-	LimitClause lc = new LimitClause();
-	Expression expr;
-	pushForbiddenScope(getCurrentScope());
+    LimitClause lc = new LimitClause();
+    Expression expr;
+    pushForbiddenScope(getCurrentScope());
 }
 {
     <LIMIT> expr = Expression()    { lc.setLimitExpr(expr);    }
     (<OFFSET> expr = Expression() { lc.setOffset(expr);    })?
 
   {
-    popForbiddenScope();   
+    popForbiddenScope();
     return lc;
   }
 }
@@ -2177,17 +2182,17 @@
   Expression expr;
 }
 {
-  <DISTINCT> <BY> expr = Expression() 
+  <DISTINCT> <BY> expr = Expression()
   {
     exprs.add(expr);
   }
-  (<COMMA> expr = Expression() 
-  	{
-  		exprs.add(expr); 
-  	} 
+  (<COMMA> expr = Expression()
+      {
+          exprs.add(expr);
+      }
   )*
   {
-  	return new DistinctClause(exprs);
+      return new DistinctClause(exprs);
   }
 }
 
@@ -2204,41 +2209,41 @@
   {
     createNewScope();
   }
-	
+
    (      (<SOME>  {  qc.setQuantifier(QuantifiedExpression.Quantifier.SOME);	})
-		| (<EVERY> {  qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY);	}))
-	var = Variable() <IN> inExpr = Expression() 
-	{
-	  pair = new QuantifiedPair(var, inExpr);
-      getCurrentScope().addNewVarSymbolToScope(var.getVar());
-      quantifiedList.add(pair);
-	}
-	(
-	<COMMA> var = Variable() <IN> inExpr = Expression() 
-	{ 
+        | (<EVERY> {  qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY);	}))
+    var = Variable() <IN> inExpr = Expression()
+    {
       pair = new QuantifiedPair(var, inExpr);
       getCurrentScope().addNewVarSymbolToScope(var.getVar());
-      quantifiedList.add(pair);	
-	}
-	)*
-	 <SATISFIES> satisfiesExpr = Expression()
-	 {
-	   qc.setSatisfiesExpr(satisfiesExpr);
-	   qc.setQuantifiedList(quantifiedList);
-	   removeCurrentScope();
-	   return qc;
-	 }
+      quantifiedList.add(pair);
+    }
+    (
+    <COMMA> var = Variable() <IN> inExpr = Expression()
+    {
+      pair = new QuantifiedPair(var, inExpr);
+      getCurrentScope().addNewVarSymbolToScope(var.getVar());
+      quantifiedList.add(pair);
+    }
+    )*
+     <SATISFIES> satisfiesExpr = Expression()
+     {
+       qc.setSatisfiesExpr(satisfiesExpr);
+       qc.setQuantifiedList(quantifiedList);
+       removeCurrentScope();
+       return qc;
+     }
 }
 
 TOKEN_MGR_DECLS:
 {
     public int commentDepth = 0;
     public IntStack lexerStateStack = new IntStack();
-    
+
     public void pushState() {
       lexerStateStack.push( curLexState );
     }
-    
+
     public void popState(String token) {
       if (lexerStateStack.size() > 0) {
          SwitchTo( lexerStateStack.pop() );
@@ -2448,7 +2453,7 @@
 <DEFAULT,IN_DBL_BRACE>
 SKIP:
 {
-    <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?> 
+    <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?>
 }
 
 <DEFAULT,IN_DBL_BRACE>
