Ejemplo n.º 1
0
        public SqlStatement ParseDeleteTableStatement()
        {
            DeleteStatement StatementDelete = new DeleteStatement();
            Token           token           = lexer.Get_Token();
            Error           error           = new Error();

            if (!(token.TokenType == TokenType.Keyword && token.Lexem == "SELECT"))
            {
                error.expected = "DROP";
                error.str      = "Create value expected";
                error.type     = "Keyword";
                result.Errors.Add(error);
            }

            token = lexer.Get_Token();
            if (!(token.TokenType == TokenType.Keyword && token.Lexem == "TABLE"))
            {
                error.expected = "TABLE";
                error.str      = "Table value expected";
                error.type     = "Keyword";
                result.Errors.Add(error);
            }

            token = lexer.Get_Token();
            if (token.TokenType != TokenType.ID)
            {
                error.expected = "Table name";
                error.str      = "Table title expected";
                error.type     = "ID";
                result.Errors.Add(error);
            }
            StatementDelete.TableName = token.Lexem;
            token = lexer.Get_Token();
            if (token.TokenType == TokenType.ID && token.Lexem != "(")
            {
                error.expected = "(";
                error.str      = "Expected (";
                error.type     = "Bracket";
                result.Errors.Add(error);
            }

            token = lexer.Get_Token();
            while (true)
            {
                if (token.TokenType != TokenType.ID)
                {
                    error.expected = "Column name";
                    error.str      = "Expected column name";
                    error.type     = "ID";
                    result.Errors.Add(error);
                }
                Expression columnDef;
                columnDef.Operand1 = token.Lexem;
                token = lexer.Get_Token();
                if (token.TokenType != TokenType.Operation)
                {
                    error.expected = "column type";
                    error.str      = "Expected column type";
                    error.type     = "TypeName";
                    result.Errors.Add(error);
                }
                columnDef.Operation = token.Lexem;
                token = lexer.Get_Token();
                if (token.TokenType != TokenType.Operation)
                {
                    error.expected = "column type";
                    error.str      = "Expected column type";
                    error.type     = "TypeName";
                    result.Errors.Add(error);
                }
                columnDef.Operand2 = token.Lexem;
                StatementDelete.set_columns(columnDef);
                token = lexer.Get_Token();
                if (token.TokenType == TokenType.Bracket)
                {
                    break;
                }
                token = lexer.Get_Token();
            }
            token = lexer.Get_Token();
            if (token.TokenType != TokenType.Semicolon)
            {
                error.expected = ";";
                error.str      = "Expected ;";
                error.type     = "Semicolon";
                result.Errors.Add(error);
            }
            return(StatementDelete);
        }
Ejemplo n.º 2
0
 public abstract void visit(ref DeleteStatement DeleteStatement);
Ejemplo n.º 3
0
 public override void visit(ref DeleteStatement DeleteStatement)
 {
     DeleteStatement.write_data();
 }
Ejemplo n.º 4
0
        public override void Accept(ref ExecuteVisitor visitor)
        {
            DeleteStatement DeleteStatement = this;

            visitor.visit(ref DeleteStatement);
        }