Ejemplo n.º 1
0
        public override void ParseInside(ExpressionParser parser)
        {
            var collection = parser.Collection;

            collection.GotoNextMust();
            var lex = collection.GotoNextMust();

            ExpressionParser tonode = new ExpressionParser(collection);

            tonode.Parse();
            AddChild(tonode.Single());
            lex = collection.CurrentLexem();
            if (lex.LexemType != LexType.Command || lex.LexemText.ToLower() != "as")
            {
                collection.ErrorWaitKeyWord("AS", collection.CurrentOrLast());
            }
            lex = collection.GotoNextMust();
            var ex = ExactType.Parse(collection);

            if (ex == null)
            {
                collection.Error("Type is unknow", collection.CurrentOrLast());
            }
            ToType = ex.Value;
            lex    = collection.GotoNextMust();
            if (!lex.IsSkobraClose())
            {
                collection.Error("not closed function", collection.CurrentOrLast());
            }
            collection.GotoNext();
        }
Ejemplo n.º 2
0
        public static AlterColumnInfo ReadColumnInfo(LexemCollection collection)
        {
            var             lex = collection.CurrentLexem();
            var             col = CommonParserFunc.ReadColumnNameOnly(collection);
            AlterColumnInfo cd  = new AlterColumnInfo();

            cd.Name = col;
            lex     = collection.GotoNextMust();
            if (lex.LexemType != LexType.Command)
            {
                collection.ErrorUnexpected(collection.CurrentLexem());
            }
            ExactType?tp = ExactType.Parse(collection);

            if (tp == null)
            {
                collection.Error("Unknow data type", collection.CurrentOrLast());
            }
            cd.Type = tp.Value;
            lex     = collection.GotoNext();
            while (lex != null && lex.LexemType != LexType.Zpt && !lex.IsSkobraClose())
            {
                string s1 = lex.LexemText.ToLower();
                if (ParserUtils.ParseCommandPhrase(collection, "not null"))
                {
                    cd.Nullable = false;
                }
                else if (ParserUtils.ParseCommandPhrase(collection, "null"))
                {
                    cd.Nullable = true;
                }
                else if (ParserUtils.ParseCommandPhrase(collection, "primary key"))
                {
                    cd.PrimaryKey = true;
                }
                else if (lex.LexemType == LexType.Command && (s1 == "auto_increment"))
                {
                    cd.AutoIncrement = true;
                }
                else
                {
                    collection.ErrorUnexpected(collection.CurrentOrLast());
                }
                lex = collection.GotoNext();
            }
            return(cd);
        }