/// Implements <Query> ::= SELECT <TypeIdentifier> public Reduction CreateRULE_QUERY_SELECT(Reduction reduction) { object selectType = ((Reduction)((Token)reduction.GetToken(1)).Data).Tag; Predicate selectTypePredicate = selectType as Predicate; if (selectTypePredicate == null) reduction.Tag = new IsOfTypePredicate(selectType.ToString()); else reduction.Tag = selectTypePredicate; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_QUERY_SELECT"); return null; }
/// Implements <AndExpr> ::= <AndExpr> AND <UnaryExpr> public Reduction CreateRULE_ANDEXPR_AND(Reduction reduction) { Predicate lhs = (Predicate)((Reduction)reduction.GetToken(0).Data).Tag; Predicate rhs = (Predicate)((Reduction)reduction.GetToken(2).Data).Tag; reduction.Tag = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_ANDEXPR_AND"); return null; }
/// Implements <Query> ::= SELECT <TypeIdentifier> WHERE <Expression> public Reduction CreateRULE_QUERY_SELECT_WHERE(Reduction reduction) { //selectType can be one of the following depending on the query text: - //1. A plain string that is the name of Type; we can build IsOfTypePredicate from this. //2. AggregateFunctionPredicate that has IsOfTypePredicate set as its ChildPredicate // cant be this, grammer changed //3. IsOfTypePredicate object selectType = ((Reduction)reduction.GetToken(1).Data).Tag; Predicate lhs = null; Predicate rhs = (Predicate)((Reduction)reduction.GetToken(3).Data).Tag; Predicate selectTypePredicate = selectType as Predicate; Predicate result = null; //1. selectType is string if (selectTypePredicate == null) { lhs = new IsOfTypePredicate(selectType.ToString()); result = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); } ////2. selectType is AggregateFunctionPredicate //3. selectType is IsOfTypePredicate else { lhs = selectTypePredicate; result = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); } reduction.Tag = result; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_QUERY_SELECT_WHERE"); return null; }
/// Implements <CountFunction> ::= 'COUNT(' <Property> ')' public Reduction CreateRULE_COUNTFUNCTION_COUNTLPARAN_TIMES_RPARAN(Reduction reduction) { string typeName = ((Reduction)reduction.GetToken(1).Data).Tag as string; Predicate childPredicate = new IsOfTypePredicate(typeName); AggregateFunctionPredicate countFunctionPredicate = ExpressionBuilder.CreateCountFunctionPredicate() as AggregateFunctionPredicate; countFunctionPredicate.ChildPredicate = childPredicate; reduction.Tag = countFunctionPredicate; return null; }
public Reduction CreateRULE_DATE_DATETIME_LPARAN_STRINGLITERAL_RPARAN(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_DATE_DATETIME_LPARAN_STRINGLITERAL_RPARAN"); string dateTime = reduction.GetToken(2).Data.ToString().Trim('\''); reduction.Tag = new DateTimeConstantValue(dateTime); return null; }
/// Implements <NumLiteralList> ::= <NumLiteral> public Reduction CreateRULE_NUMLITERALLIST(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_NUMLITERALLIST"); IsInListPredicate pred = new IsInListPredicate(); pred.Append(((Reduction)reduction.GetToken(0).Data).Tag); reduction.Tag = pred; return null; }
/// Implements <Identifier> ::= Keyword public Reduction CreateRULE_IDENTIFIER_KEYWORD(Reduction reduction) { reduction.Tag = ((Token)reduction.GetToken(0)).Data; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_IDENTIFIER_KEYWORD -> " + reduction.Tag); return null; }
/// Implements <Property> ::= <Identifier> public Reduction CreateRULE_PROPERTY(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_PROPERTY"); reduction.Tag = ((Token)reduction.GetToken(0)).Data; return null; }
/// Implements <CompareExpr> ::= '(' <Expression> ')' public Reduction CreateRULE_COMPAREEXPR_LPARAN_RPARAN(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_COMPAREEXPR_LPARAN_RPARAN"); reduction.Tag = ((Reduction)((Token)reduction.GetToken(1)).Data).Tag; return null; }
/// Implements <CompareExpr> ::= <Value> IS NOT NUll public Reduction CreateRULE_COMPAREEXPR_IS_NOT_NULL(Reduction reduction) { object lhs = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; Predicate predicate = new IsNullPredicate(lhs as IFunctor); predicate.Invert(); reduction.Tag = predicate; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_COMPAREEXPR_IS_NOT_NULL"); return null; }
/// Implements <CompareExpr> ::= <Value> NOT IN <InList> public Reduction CreateRULE_COMPAREEXPR_NOT_IN(Reduction reduction) { object lhs = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; IsInListPredicate pred = (IsInListPredicate) ((Reduction)((Token)reduction.GetToken(3)).Data).Tag; pred.Invert(); pred.Functor = lhs as IFunctor; reduction.Tag = pred; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_COMPAREEXPR_NOT_IN"); return null; }
/// Implements <CompareExpr> ::= <Value> NOT LIKE StringLiteral public Reduction CreateRULE_COMPAREEXPR_NOT_LIKE_STRINGLITERAL(Reduction reduction) { object lhs = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; RuntimeValue rhs = new RuntimeValue(); Predicate predicate = ExpressionBuilder.CreateLikePatternPredicate(lhs, rhs); predicate.Invert(); reduction.Tag = predicate; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_COMPAREEXPR_LIKE_STRINGLITERAL"); return null; }
/// Implements <CompareExpr> ::= <Value> '>=' <Value> public Reduction CreateRULE_COMPAREEXPR_GTEQ(Reduction reduction) { object lhs = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; object rhs = ((Reduction)((Token)reduction.GetToken(2)).Data).Tag; reduction.Tag = ExpressionBuilder.CreateGreaterEqualsPredicate(lhs, rhs); if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_COMPAREEXPR_GTEQ"); return null; }
/// Implements <UnaryExpr> ::= <CompareExpr> public Reduction CreateRULE_UNARYEXPR(Reduction reduction) { reduction.Tag = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_UNARYEXPR"); return null; }
/// Implements <UnaryExpr> ::= NOT <CompareExpr> public Reduction CreateRULE_UNARYEXPR_NOT(Reduction reduction) { Predicate pred = (Predicate)((Reduction)((Token)reduction.GetToken(1)).Data).Tag; pred.Invert(); reduction.Tag = pred; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_UNARYEXPR_NOT"); return null; }
/// Implements <ObjectValue> ::= Keyword '.' <Property> public Reduction CreateRULE_OBJECTVALUE_KEYWORD_DOT(Reduction reduction) { object pred = ((Reduction)((Token)reduction.GetToken(2)).Data).Tag; if(pred is IFunctor) reduction.Tag = pred; else { reduction.Tag = new MemberFunction(pred.ToString()); } if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_IDENTIFIER_KEYWORD"); return null; }
/// Implements <Property> ::= <Property> '.' <Identifier> public Reduction CreateRULE_PROPERTY_DOT(Reduction reduction) { IFunctor nested = new MemberFunction(((Reduction)((Token)reduction.GetToken(2)).Data).Tag.ToString()); IFunctor func = new MemberFunction(((Reduction)((Token)reduction.GetToken(0)).Data).Tag.ToString()); reduction.Tag = new CompositeFunction(func, nested); if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_PROPERTY_DOT -> " + reduction.Tag); return null; }
/// Implements <Value> ::= '-' <NumLiteral> public Reduction CreateRULE_VALUE_MINUS(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_VALUE_MINUS"); object functor = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; if(functor is IntegerConstantValue) reduction.Tag = new IntegerConstantValue("-" + reduction.GetToken(1).Data.ToString()); else reduction.Tag = new DoubleConstantValue("-" + reduction.GetToken(1).Data.ToString()); return null; }
/// Implements <Identifier> ::= Identifier public Reduction CreateRULE_IDENTIFIER_IDENTIFIER(Reduction reduction) { reduction.Tag = ((Token)reduction.GetToken(0)).Data.ToString(); if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_IDENTIFIER_IDENTIFIER -> " + reduction.Tag); return null; }
/// Implements <Date> ::= DateTime '(' <StrLiteral> ')' public Reduction CreateRULE_DATE_DATETIME_LPARAN_RPARAN(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_DATE_DATETIME_LPARAN_RPARAN"); reduction.Tag = new DateTimeConstantValue(reduction.GetToken(2).Data.ToString()); return null; }
/// Implements <InList> ::= '(' <ListType> ')' public Reduction CreateRULE_INLIST_LPARAN_RPARAN(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_INLIST_LPARAN_RPARAN"); object obj = ((Reduction)((Token)reduction.GetToken(1)).Data).Tag; if (obj is ConstantValue || obj is RuntimeValue) { IsInListPredicate pred = new IsInListPredicate(); pred.Append(obj); reduction.Tag = pred; } else { reduction.Tag = ((Reduction)((Token)reduction.GetToken(1)).Data).Tag; } return null; }
/// Implements <NumLiteral> ::= RealLiteral public Reduction CreateRULE_NUMLITERAL_REALLITERAL(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_NUMLITERAL_REALLITERAL"); reduction.Tag = new DoubleConstantValue(reduction.GetToken(0).Data.ToString()); return null; }
//self create //========================= public Reduction CreateRULE_ATRRIB(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_ATRRIB"); reduction.Tag = ((Reduction)((Token)reduction.GetToken(0)).Data).Tag; return null; }
/// Implements <TypeIdentifier> ::= <Identifier> public Reduction CreateRULE_OBJECTTYPE_IDENTIFIER(Reduction reduction) { reduction.Tag = ((Token)reduction.GetToken(0)).Data; if(NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_TYPEIDENTIFIER_IDENTIFIER"); return null; }
public Reduction CreateRULE_OBJECTVALUE_KEYWORD_DOT_IDENTIFIER(Reduction reduction) { if(NCacheLog.IsInfoEnabled) NCacheLog.Info("RULE_OBJECTVALUE_KEYWORD_DOT_IDENTIFIER"); string memName = reduction.GetToken(2).Data.ToString(); reduction.Tag = new MemberFunction(memName); return null; }
/// Implements <TypeIdentifier> ::= <TypeIdentifier> '.' <Identifier> public Reduction CreateRULE_OBJECTTYPE_IDENTIFIER_DOT(Reduction reduction) { string lhs = ((Reduction)reduction.GetToken(0).Data).Tag.ToString(); string rhs = reduction.GetToken(2).Data.ToString(); reduction.Tag = lhs + "." + rhs; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_OBJECTTYPE_IDENTIFIER_DOT"); return null; }
/// Implements <AverageFunction> ::= 'AVG(' <TypePlusAttribute> ')' public Reduction CreateRULE_AVERAGEFUNCTION_AVGLPARAN_RPARAN(Reduction reduction) { Reduction typePlusAttributeReduction = (Reduction)reduction.GetToken(1).Data; string typeName = ((Reduction)typePlusAttributeReduction.GetToken(0).Data).Tag as string; string memberName = ((Reduction)typePlusAttributeReduction.GetToken(2).Data).Tag as string; Predicate childPredicate = new IsOfTypePredicate(typeName); AggregateFunctionPredicate avgFunctionPredicate = ExpressionBuilder.CreateAverageFunctionPredicate(memberName) as AggregateFunctionPredicate; avgFunctionPredicate.ChildPredicate = childPredicate; reduction.Tag = avgFunctionPredicate; return null; }
/// Implements <ObjectAttribute> ::= Identifier public Reduction CreateRULE_OBJECTATTRIBUTE_IDENTIFIER(Reduction reduction) { string memberName = reduction.GetToken(0).Data.ToString(); reduction.Tag = memberName; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_OBJECTATTRIBUTE_IDENTIFIER"); return null; }
//======================== public Reduction CreateInclusionList(Reduction reduction) { object tag = ((Reduction)reduction.GetToken(2).Data).Tag; IsInListPredicate inc = null; if(tag is IsInListPredicate) inc = tag as IsInListPredicate; else { inc = new IsInListPredicate(); inc.Append(tag); } inc.Append(((Reduction)reduction.GetToken(0).Data).Tag); reduction.Tag = inc; return null; }
public Reduction CreateRULE_QUERY_SELECT_WHERE2(Reduction reduction) { //selectType can be one of the following depending on the query text: - // AggregateFunctionPredicate that has IsOfTypePredicate set as its ChildPredicate object selectType = ((Reduction)reduction.GetToken(1).Data).Tag; Predicate lhs = null; Predicate rhs = (Predicate)((Reduction)reduction.GetToken(3).Data).Tag; Predicate selectTypePredicate = selectType as Predicate; Predicate result = null; AggregateFunctionPredicate parentPredicate = selectTypePredicate as AggregateFunctionPredicate; lhs = parentPredicate.ChildPredicate; parentPredicate.ChildPredicate = ExpressionBuilder.CreateLogicalAndPredicate(lhs, rhs); result = parentPredicate; reduction.Tag = result; if (NCacheLog.IsInfoEnabled) NCacheLog.Info("CreateRULE_QUERY_SELECT_WHERE2"); return null; }