public static Expression AddFiled(string fieldAlias, string tableAlias, string schema, Lexem lexem, ExpressionParser parser) { if (fieldAlias == "*") { if (schema != null) { parser.Collection.Error("Can not use schema in * expression", lexem); } AllColumnExpr a = new AllColumnExpr(); a.Prefix = tableAlias; return(a); } FieldExpr res = new FieldExpr(); res.FieldName = fieldAlias; res.TableAlias = tableAlias; res.Schema = schema; res.Lexem = lexem; return(res); }
public Expression GetNode(ExpressionParser parser) { Lexem lex = parser.Collection.CurrentLexem(); Expression res = null; if (lex.LexemType == LexType.Command) { string lowerLexem = lex.LexemText.ToLower(); if (ParserUtils.ParseCommandPhrase(parser.Collection, "create view", false, false)) { res = new CreateView(); } if (ParserUtils.ParseCommandPhrase(parser.Collection, "create table", false, false)) { res = new CreateTable(); } if (res == null && ParserUtils.ParseCommandPhrase(parser.Collection, "alter table", false, false)) { res = new AlterTable(); } if (res == null && ParserUtils.ParseCommandPhrase(parser.Collection, "drop table", false, false)) { res = new DropTable(); } if (res == null && ParserUtils.ParseCommandPhrase(parser.Collection, "drop index", false, false)) { res = new DropIndex(); } if (res == null && (ParserUtils.ParseCommandPhrase(parser.Collection, "create unique index", false, false) || ParserUtils.ParseCommandPhrase(parser.Collection, "create index", false, false))) { res = new CreateIndex(); } if (res == null) { if (parser.Collection.GetNext() != null && parser.Collection.GetNext().IsSkobraOpen()) { switch (lowerLexem) { case "count": res = new CountExpr(); break; case "sum": res = new SumExpr(); break; case "min": res = new MinExpr(); break; case "max": res = new MaxExpr(); break; case "avg": res = new AvgExpr(); break; case "lastinsertrowid": res = new LastInsertRowidExpr(); break; case "exists": res = new ExistsExpr(); break; case "any": res = new AnyExpr(); break; } } switch (lowerLexem) { case "between": //не функция res = new Between(); break; case "select": res = new SelectExpresion(); break; case "update": res = new UpdateStatement(); break; case "insert": res = new InsertStatement(); break; case "delete": res = new DeleteStatement(); break; } } } if (res != null) { return(res); } return(res); }