public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; var lex = collection.CurrentLexem(); if (lex.LexemText.ToLower() != "create") { parser.Collection.Error("error", collection.CurrentLexem()); } lex = collection.GotoNextMust(); if (lex.LexemText.ToLower() != "view") { parser.Collection.Error("error", collection.CurrentLexem()); } lex = collection.GotoNextMust(); //название Table = TableName.Parse(parser); lex = collection.GotoNextMust(); if (lex.IsSkobraOpen()) { lex = collection.GotoNextMust(); Columns.Clear(); while (true) { var col = CommonParserFunc.ReadColumnNameOnly(collection); Columns.Add(col); lex = collection.CurrentLexem(); if (lex == null) { parser.Collection.UnexceptEndError(); } if (lex.LexemType == LexType.Zpt) { collection.GotoNextMust(); continue; } if (lex.IsSkobraClose()) { break; } collection.ErrorUnexpected(collection.CurrentOrLast()); } lex = collection.GotoNextMust(); } lex = collection.CurrentLexem(); if (lex.LexemText.ToLower() != "as") { parser.Collection.ErrorWaitKeyWord("AS", collection.CurrentLexem()); } lex = collection.GotoNextMust(); AsSelect = new SelectExpresion(); AsSelect.ParseInside(parser); //переходим к следующей лексеме collection.GotoNext(); }
public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; if (!ParserUtils.ParseCommandPhrase(collection, "drop index")) { collection.ErrorWaitKeyWord("drop index", collection.CurrentOrLast()); } collection.GotoNextMust(); if (ParserUtils.ParseCommandPhrase(collection, "if exists")) { IfExists = true; collection.GotoNextMust(); } IndexName = TableName.Parse(parser); collection.GotoNext(); }
public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; var lex = collection.CurrentLexem(); if (lex.LexemText.ToLower() != "create") { parser.Collection.ErrorWaitKeyWord("CREATE", collection.CurrentLexem()); } lex = collection.GotoNextMust(); if (lex.LexemText.ToLower() != "table") { parser.Collection.ErrorWaitKeyWord("TABLE", collection.CurrentLexem()); } lex = collection.GotoNextMust(); //название Table = TableName.Parse(parser); lex = collection.GotoNextMust(); if (!lex.IsSkobraOpen()) { parser.Collection.ErrorWaitKeyWord("(", collection.CurrentLexem()); } lex = collection.GotoNextMust(); while (true) { AlterColumnInfo cd = ReadColumnInfo(collection); Columns.Add(cd); lex = collection.CurrentLexem(); if (lex == null) { parser.Collection.UnexceptEndError(); } if (lex.LexemType == LexType.Zpt) { collection.GotoNextMust(); continue; } if (lex.IsSkobraClose()) { break; } collection.ErrorUnexpected(collection.CurrentOrLast()); } //переходим к следующей лексеме collection.GotoNext(); }
public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; if (!ParserUtils.ParseCommandPhrase(collection, "alter table")) { collection.ErrorUnexpected(collection.CurrentOrLast()); } var lex = collection.GotoNextMust(); Table = TableName.Parse(parser); lex = collection.GotoNextMust(); string s = lex.LexemText.ToLower(); if (ParserUtils.ParseCommandPhrase(collection, "set schema")) { lex = collection.GotoNextMust(); NewName = CommonParserFunc.ReadColumnNameOnly(collection); AlterType = AlterType.RenameSchema; collection.GotoNext(); } else if (ParserUtils.ParseCommandPhrase(collection, "rename to", true, false)) { lex = collection.GotoNextMust(); NewName = CommonParserFunc.ReadColumnNameOnly(collection); AlterType = AlterType.RenameTable; collection.GotoNext(); } else if (ParserUtils.ParseCommandPhrase(collection, "rename column", true, false) || ParserUtils.ParseCommandPhrase(collection, "rename", true, false)) { lex = collection.GotoNextMust(); var col = CommonParserFunc.ReadColumnNameOnly(collection); OldColumnName = col; lex = collection.GotoNextMust(); if (lex.LexemText.ToLower() != "to") { collection.ErrorWaitKeyWord("TO", collection.CurrentOrLast()); } lex = collection.GotoNextMust(); NewName = CommonParserFunc.ReadColumnNameOnly(collection); AlterType = AlterType.RenameColumn; collection.GotoNext(); } else//actions { AlterType = AlterType.AlterColumn; while (true) { lex = collection.CurrentLexem(); if (ParserUtils.ParseCommandPhrase(collection, "add column", true, false) || ParserUtils.ParseCommandPhrase(collection, "add", true, false)) { collection.GotoNextMust(); var cd = CreateTable.ReadColumnInfo(collection); cd.AlterColumn = AlterColumnType.AddColumn; AlterColumns.Add(cd); } else if (ParserUtils.ParseCommandPhrase(collection, "drop column", true, false) || ParserUtils.ParseCommandPhrase(collection, "drop", true, false)) { lex = collection.GotoNextMust(); var cd = new AlterColumnInfo(); cd.Name = CommonParserFunc.ReadColumnNameOnly(collection); cd.AlterColumn = AlterColumnType.DropColumn; AlterColumns.Add(cd); } else if (ParserUtils.ParseCommandPhrase(collection, "alter column", true, false) || ParserUtils.ParseCommandPhrase(collection, "alter", true, false)) { lex = collection.GotoNextMust(); var cd = CreateTable.ReadColumnInfo(collection); AlterColumns.Add(cd); } else { collection.ErrorUnexpected(collection.CurrentOrLast()); } lex = collection.CurrentLexem(); if (lex != null && lex.LexemType == LexType.Zpt) { collection.GotoNextMust(); continue; } break; } collection.GotoNext(); } }
public override void ParseInside(ExpressionParser parser) { var collection = parser.Collection; var lex = collection.CurrentLexem(); if (lex.LexemText.ToLower() != "create") { collection.ErrorWaitKeyWord("CREATE", collection.CurrentOrLast()); } lex = collection.GotoNextMust(); if (lex.LexemText.ToLower() == "unique") { Unique = true; lex = collection.GotoNextMust(); } if (lex.LexemText.ToLower() != "index") { collection.ErrorWaitKeyWord("INDEX", collection.CurrentOrLast()); } lex = collection.GotoNextMust(); if (ParserUtils.ParseCommandPhrase(collection, "if not exists")) { IfNotExists = true; lex = collection.GotoNextMust(); } IndexName = TableName.Parse(parser); lex = collection.GotoNextMust(); lex = collection.CurrentLexem(); if (lex.LexemType != LexType.Command || lex.LexemText.ToLower() != "on") { collection.ErrorWaitKeyWord("ON", collection.CurrentOrLast()); } lex = collection.GotoNextMust(); OnTable = TableName.Parse(parser); lex = collection.GotoNextMust(); if (!lex.IsSkobraOpen()) { collection.ErrorWaitKeyWord("(", collection.CurrentOrLast()); } lex = collection.GotoNextMust(); while (true) { AlterColumnInfo cd = new AlterColumnInfo(); lex = collection.CurrentLexem(); cd.Name = CommonParserFunc.ReadColumnNameOnly(collection); lex = collection.GotoNextMust(); if (lex.LexemText.ToLower() == "desc") { cd.Sort = ParserCore.SortType.DESC; lex = collection.GotoNextMust(); } else if (lex.LexemText.ToLower() == "asc") { cd.Sort = ParserCore.SortType.ASC; lex = collection.GotoNextMust(); } IndexColumns.Add(cd); lex = collection.CurrentLexem(); if (lex == null) { parser.Collection.UnexceptEndError(); } if (lex.LexemType == LexType.Zpt) { collection.GotoNextMust(); continue; } if (lex.IsSkobraClose()) { break; } collection.ErrorUnexpected(collection.CurrentOrLast()); } collection.GotoNext(); }