コード例 #1
0
        public override IExplore Expolore(DelegateExpessionExplorer del)
        {
            List <SetClause> Set2 = new List <SetClause>();

            Set.ForEach(a =>
            {
                SetClause ss = (SetClause)a.Expolore(del);
                if (ss != null)
                {
                    Set2.Add(ss);
                }
            });
            Set.Replace(Set2);
            if (Where != null)
            {
                Where = (Expression)Where.Expolore(del);
            }

            return(base.Expolore(del));
        }
コード例 #2
0
        public override void ParseInside(ExpressionParser parser)
        {
            var collection = parser.Collection;
            var lex        = collection.CurrentLexem();

            if (lex.LexemText.ToLower() != "update")
            {
                throw new Exception("Not UPDATE statment");
            }
            lex = collection.GotoNextMust();

            FromParser fc = new FromParser();

            fc.Parse(collection);
            if (fc.Tables.Count > 1)
            {
                collection.Error("Multi tables in update", collection.CurrentLexem());
            }
            if (fc.Tables.Count == 0)
            {
                collection.Error("Not table clause", collection.CurrentLexem());
            }
            TableClause = fc.Tables[0];


            //string[] tablename = CommonParserFunc.ReadTableName(collection);
            //TableClause = TableClause.CreateByTable(tablename, collection.TableGetter.GetTableByName(tablename));
            //lex = collection.GotoNextMust();
            lex = collection.CurrentLexem();

            if (lex.LexemText.ToLower() != "set")
            {
                collection.Error("SET keyword is not found", collection.CurrentLexem());
            }

            while (true)
            {
                lex = collection.GotoNextMust();//пропускаем SET или ','
                //lex = collection.CurrentLexem();

                SetClause sc = new SetClause();
                sc.Column = CommonParserFunc.ReadColumn(collection);
                lex       = collection.GotoNextMust();
                if (lex.LexemText != "=")
                {
                    collection.Error("Operator '=' is not found", collection.CurrentLexem());
                }
                lex = collection.GotoNextMust();
                ExpressionParser e = new ExpressionParser(parser.Collection);
                e.Parse();
                sc.Value = e.Single();
                Set.Add(sc);
                lex = collection.CurrentLexem();
                if (lex == null)
                {
                    break;
                }
                if (lex.LexemType == LexType.Zpt)
                {
                    continue;
                }
                break;
            }

            if (lex == null)
            {
                return;
            }
            if (lex.LexemText.ToLower() == "where")
            {
                collection.GotoNextMust();
                ExpressionParser e = new ExpressionParser(parser.Collection);
                e.Parse();
                Where = e.Single();
            }
            ParseReturining(parser);
        }