Beispiel #1
0
        public SqlStatement ParseInsertTableStatement()
        {
            InsertStatement StatementInsert = new InsertStatement();
            Token           token           = lexer.Get_Token();
            Error           error           = new Error();

            if (!(token.TokenType == TokenType.Keyword && token.Lexem == "CREATE"))
            {
                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);
            }
            StatementInsert.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);
                }
                ColumnDef columnDef;
                columnDef.ColumnName = token.Lexem;
                token = lexer.Get_Token();
                if (token.TokenType != TokenType.TypeName)
                {
                    error.expected = "column type";
                    error.str      = "Expected column type";
                    error.type     = "TypeName";
                    result.Errors.Add(error);
                }
                columnDef.TypeName_or_value = token.Lexem;
                StatementInsert.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(StatementInsert);
        }
Beispiel #2
0
 public abstract void visit(ref InsertStatement InsertStatement);
 public override void visit(ref InsertStatement InsertStatement)
 {
     InsertStatement.write_data();
 }
Beispiel #4
0
        public override void Accept(ref ExecuteVisitor visitor)
        {
            InsertStatement InsertStatement = this;

            visitor.visit(ref InsertStatement);
        }