public TSQLCaseExpression Parse(ITSQLTokenizer tokenizer)
        {
            TSQLCaseExpression caseExpression = new TSQLCaseExpression();

            if (!tokenizer.Current.IsKeyword(TSQLKeywords.CASE))
            {
                throw new InvalidOperationException("CASE expected.");
            }

            caseExpression.Tokens.Add(tokenizer.Current);

            TSQLSubqueryHelper.ReadUntilStop(
                tokenizer,
                caseExpression,
                new List <TSQLFutureKeywords>()
            {
            },
                new List <TSQLKeywords>()
            {
                TSQLKeywords.END
            },
                lookForStatementStarts: false);

            // this is different than the other clauses because the
            // stop word is still part of the expression instead of
            // being part of the next expression or clause like in
            // the other parsers
            caseExpression.Tokens.Add(tokenizer.Current);

            return(caseExpression);
        }
Exemple #2
0
        public TSQLValuesExpression Parse(ITSQLTokenizer tokenizer)
        {
            TSQLValuesExpression valuesExpression = new TSQLValuesExpression();

            if (!tokenizer.Current.IsKeyword(TSQLKeywords.VALUES))
            {
                throw new InvalidOperationException("VALUES expected.");
            }

            valuesExpression.Tokens.Add(tokenizer.Current);

            TSQLSubqueryHelper.ReadUntilStop(
                tokenizer,
                valuesExpression,
                // stop words come from usage in MERGE
                new List <TSQLFutureKeywords>()
            {
                TSQLFutureKeywords.OUTPUT
            },
                new List <TSQLKeywords>()
            {
                TSQLKeywords.ON,
                TSQLKeywords.WHEN
            },
                // INSERT INTO ... VALUES ... SELECT
                lookForStatementStarts: true);

            return(valuesExpression);
        }
        public TSQLExecuteStatement Parse()
        {
            Statement.Tokens.Add(Tokenizer.Current);

            TSQLSubqueryHelper.ReadUntilStop(
                Tokenizer,
                Statement,
                new List <TSQLFutureKeywords>()
            {
            },
                new List <TSQLKeywords>()
            {
            },
                lookForStatementStarts: true);

            if (
                Tokenizer.Current?.AsKeyword != null &&
                Tokenizer.Current.AsKeyword.Keyword.IsStatementStart())
            {
                Tokenizer.Putback();
            }

            return(Statement);
        }