Пример #1
0
        public static CreateStatement ParseAlter(Scope scope, KeywordToken alterToken)
        {
            scope       = scope.Clone();
            scope.Hint |= ScopeHint.SuppressStatementStarts | ScopeHint.SuppressFunctionDefinition | ScopeHint.SuppressFunctionCall | ScopeHint.SuppressLogic;

            var ret = new CreateStatement(scope);

            ret.AddToken(alterToken);

            var code = scope.Code;

            var word = code.PeekWordR();

            if (word == "table")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "table"));
                ret.ParseAlterTable();
            }

            return(ret);
        }
Пример #2
0
        public static CreateStatement ParseCreate(Scope scope, KeywordToken createToken)
        {
            scope       = scope.Clone();
            scope.Hint |= ScopeHint.SuppressStatementStarts | ScopeHint.SuppressFunctionDefinition | ScopeHint.SuppressFunctionCall | ScopeHint.SuppressLogic;

            var ret = new CreateStatement(scope);

            ret.AddToken(createToken);

            var code = scope.Code;

            var word = code.PeekWordR();

            if (word == "table")
            {
                ret.ParseCreateTable(new KeywordToken(scope, code.MovePeekedSpan(), "table"));
            }
            else if (word == "relationship")
            {
                ret.ParseCreateRelationship(new KeywordToken(scope, code.MovePeekedSpan(), "relationship"));
            }
            else if (word == "index")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "index"));
                ret.ParseCreateIndex();
            }
            else if (word == "unique")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "unique"));
                switch (code.PeekWordR())
                {
                case "index":
                    ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "index"));
                    ret.ParseCreateIndex();
                    break;

                case "primary":
                case "nopick":
                case "NOPICK":
                    ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), word));
                    if (code.PeekWordR() == "index")
                    {
                        ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "index"));
                        ret.ParseCreateIndex();
                    }
                    break;
                }
            }
            else if (word == "primary" || word == "NOPICK" || word == "nopick")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), word));
                if (code.PeekWordR() == "index")
                {
                    ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "index"));
                    ret.ParseCreateIndex();
                }
            }
            else if (word == "stringdef")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "stringdef"));
                ret.ParseCreateStringdef();
            }
            else if (word == "typedef")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "typedef"));
                ret.ParseCreateTypedef();
            }
            else if (word == "time")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "time"));
                if (code.ReadExactWholeWord("relationship"))
                {
                    ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "relationship"));
                    ret.ParseCreateTimeRelationship();
                }
            }
            else if (word == "workspace")
            {
                ret.AddToken(new KeywordToken(scope, code.MovePeekedSpan(), "workspace"));
                ret.ParseCreateWorkspace();
            }

            return(ret);
        }