public BatchInfo(int startLine, int startColumn, string batchText, SqlCmdCommand sqlCmdCommand, int repeatCount = 1)
 {
     this.startLine      = startLine;
     this.startColumn    = startColumn;
     this.executionCount = repeatCount;
     this.batchText      = batchText;
     this.sqlCmdCommand  = sqlCmdCommand;
 }
Esempio n. 2
0
        private void ParseConnect(Token connectToken)
        {
            string serverName = null;
            string userName   = null;
            string password   = null;

            Accept(LexerTokenType.Whitespace);
            Expect(LexerTokenType.Text);

            serverName = ResolveVariables(LookaheadToken, 0, null);
            if (serverName == null)
            {
                //found some text but couldn't parse for servername
                RaiseError(ErrorCode.UnrecognizedToken);
            }

            Accept();
            Accept(LexerTokenType.Whitespace);

            switch (LookaheadTokenType)
            {
            case LexerTokenType.Text:
                userName = ParseUserName();
                password = ParsePassword();
                if (userName == null || password == null)
                {
                    //found some text but couldn't parse for user/password
                    RaiseError(ErrorCode.UnrecognizedToken);
                }
                break;

            case LexerTokenType.NewLine:
            case LexerTokenType.Eof:
                Accept();
                break;

            default:
                RaiseError(ErrorCode.UnrecognizedToken);
                break;
            }

            this.sqlCmdCommand = new ConnectSqlCmdCommand(serverName, userName, password);
        }
Esempio n. 3
0
        private void ParseOnErrorCommand(Token onErrorToken)
        {
            ExpectAndAccept(LexerTokenType.Whitespace);
            Expect(LexerTokenType.Text);

            string action;

            action = ResolveVariables(LookaheadToken, 0, null);

            OnErrorAction onErrorAction;

            if (action.Equals("exit", StringComparison.OrdinalIgnoreCase))
            {
                onErrorAction = OnErrorAction.Exit;
            }
            else if (action.Equals("ignore", StringComparison.OrdinalIgnoreCase))
            {
                onErrorAction = OnErrorAction.Ignore;
            }
            else
            {
                RaiseError(ErrorCode.UnrecognizedToken);
                return;
            }

            Accept(LexerTokenType.Text);
            AcceptWhitespaceOrComment();
            if (LookaheadTokenType != LexerTokenType.Eof)
            {
                Expect(LexerTokenType.NewLine);
            }

            BatchParserAction parserAction;

            parserAction = commandHandler.OnError(onErrorToken, onErrorAction);

            this.sqlCmdCommand = new OnErrorSqlCmdCommand(onErrorAction);

            if (parserAction == BatchParserAction.Abort)
            {
                RaiseError(ErrorCode.Aborted);
            }
        }