Ejemplo n.º 1
0
        public IExpression Parse(TextSpan token, IParser parser)
        {
            var variableName = parser.ConsumeAny(SqlToken.Identifier);
            var value        = parser.ConsumeAny(SqlToken.DoubleQuoteString);

            return(new ScriptSetvarSqlCodeExpr
            {
                Name = variableName as SqlCodeExpr,
                Value = value as SqlCodeExpr
            });
        }
Ejemplo n.º 2
0
        private IExpression AlterDatabase(TextSpan databaseSpan, IParser parser)
        {
            SqlCodeExpr databaseName = null;

            if (parser.MatchToken(SqlToken.CURRENT))
            {
                databaseName = new ObjectIdSqlCodeExpr
                {
                    ObjectName = "CURRENT"
                };
            }
            else
            {
                databaseName = parser.ConsumeObjectId();
            }

            var actionExpr = parser.ConsumeAny(
                ParseSetOnOff,
                ParseAddFileGroup);

            var isSemicolon = parser.MatchToken(SqlToken.Semicolon);

            return(new AlterDatabaseSqlCodeExpr
            {
                DatabaseName = databaseName,
                ActionExpr = actionExpr,
                IsSemicolon = isSemicolon,
            });
        }
Ejemplo n.º 3
0
 public IExpression Parse(TextSpan token, IParser parser)
 {
     return(parser.ConsumeAny(ParseDbccUpdateUsage,
                              ParseDbccCheckIdent,
                              ParseDbccInputbuffer,
                              ParseDbccLoginfo,
                              p => ParseDbcc(p, SqlToken.SQLPERF, 1, 1),
                              p => ParseDbcc(p, SqlToken.SHRINKFILE, 1, 4)));
 }
Ejemplo n.º 4
0
        public IExpression Parse(TextSpan token, IParser parser)
        {
            SqlCodeExpr returnVariable = null;

            if (parser.Scanner.TryConsume(SqlToken.Variable, out var returnVariableSpan))
            {
                returnVariable = parser.PrefixParse(returnVariableSpan, int.MaxValue) as SqlCodeExpr;
                parser.Scanner.Consume(SqlToken.Equal);
            }

            SqlCodeExpr funcName = null;

            if (parser.Scanner.Match(SqlToken.LParen))
            {
                funcName = new GroupSqlCodeExpr
                {
                    InnerExpr = parser.ParseExpIgnoreComment()
                };
                parser.Scanner.Consume(SqlToken.RParen);
            }
            else
            {
                funcName = parser.ConsumeAny(SqlToken.SqlIdentifier, SqlToken.Identifier) as SqlCodeExpr;
            }

            var isEnd = parser.IsToken(SqlToken.End);


            var parameters = new List <SqlCodeExpr>();

            if (!isEnd)
            {
                do
                {
                    var name = parser.ParseExpIgnoreComment();
                    if (name == null)
                    {
                        break;
                    }

                    var isOutput = parser.MatchTokenAny(SqlToken.Out, SqlToken.Output);
                    parameters.Add(new ParameterSqlCodeExpr
                    {
                        Name     = name,
                        IsOutput = isOutput
                    });
                } while (parser.Scanner.Match(SqlToken.Comma));
            }

            return(new ExecSqlCodeExpr
            {
                ExecToken = "EXEC",
                ReturnVariable = returnVariable,
                Name = funcName,
                Parameters = parameters
            });
        }
Ejemplo n.º 5
0
        public IExpression Parse(TextSpan token, IParser parser)
        {
            var constraintName = parser.ConsumeObjectId();

            var keyType = parser.ConsumeAny(SqlParserExtension.ParsePrimaryKey, ParseUnique);

            var clusterExpr = parser.ParseClustered();
            var withExpr    = parser.ParseConstraintWithOptions();
            var onPrimary   = parser.ParseOnPrimary();

            return(new ConstraintSqlCodeExpr
            {
                ConstraintName = constraintName,
                KeyType = keyType,
                ClusterExpr = clusterExpr,
                WithExpr = withExpr,
                OnPrimary = onPrimary,
            });
        }