public SqlExpressionInBracket(SymbolPosition leftb, SqlExpressionList inner, SymbolPosition rightb) { LeftBracket = leftb; RightBracket = rightb; Inner = inner; Inner.Parent = this; }
public SqlFunctionCall(SqlNameExpression name, SymbolPosition leftb, SqlExpressionList args, SymbolPosition rignhtb) { FunctionName = name; LeftBracket = leftb; Arguments = args; RightBracket = rignhtb; FunctionName.Parent = this; Arguments.Parent = this; }
protected SqlExpression ParseExprInBracket() { if (!IsSymbol("(")) { return(null); } var leftb = SkipSymbol("("); if (IsKeyword("select")) { SqlSelect select = ParseSelect(); SymbolPosition rightb = SkipSymbol(")"); return(new SqlSelectExpression(leftb, select, rightb)); } else { SqlExpressionList inner = ParseExprList(IsCloseBracket); SymbolPosition rightb = SkipSymbol(")"); return(new SqlExpressionInBracket(leftb, inner, rightb)); } }
private SqlExpression ParseExprTerm() { if (IsSymbol("(")) { return(ParseExprInBracket()); } else { switch (Current) { case TokenType.IdentOrKeyword: case TokenType.QuotedIdent: var name = ParseName(); var ident = name as SqlIdentifier; bool canbespecial = ident != null && !ident.IsQuoted; if (IsSymbol("(")) // function call { SymbolPosition leftb = CurrentOriginal; NextToken(); SqlExpressionList args = ParseExprList(IsCloseBracket); SymbolPosition rightb = SkipSymbol(")"); if (AllowSpecialConstantReplacement && canbespecial && args.Items.Count == 0) { // maybe it is special function mappable to constant SqlSpecialConstant sc = GetFunctionAsConstant(ident.Identifier); if (sc != SqlSpecialConstant.None) { SymbolPosition pos = new SymbolPosition { Start = ident.Original.Start, Stop = rightb.Stop, Original = Tokernizer.SliceProvider, }; return(new SpecialConstantSqlExpression(sc, pos)); } } return(new SqlFunctionCall(name, leftb, args, rightb)); } if (AllowSpecialConstantReplacement && canbespecial) { if (ident.Identifier.ToUpper() == "NULL") { return(new NullSqlExpression(ident.Original)); } // maybe it is special constant SqlSpecialConstant sc = GetSymbolAsConstant(ident.Identifier); if (sc != SqlSpecialConstant.None) { return(new SpecialConstantSqlExpression(sc, ident.Original)); } } return(name); case TokenType.Symbol: { var starpos = SkipSymbol("*"); return(new SqlStarSymbol(starpos)); } case TokenType.Number: { SymbolPosition pos = CurrentOriginal; string numdata = CurrentData; NextToken(); return(new ConstNumberSqlExpression(Double.Parse(numdata), pos)); } break; case TokenType.StringSingle: { return(ParseString()); } break; default: throw CreateParseError("DAE-00252 Unexpected token:" + Current.ToString()); break; } } }