1
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
* Drizzle Execute Parser
5
* Copyright (C) 2011 Data Differential, http://datadifferential.com/
6
* Copyright (C) 2011 Vijay Samuel, vjsamuel1990@gmail.com
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions are
14
* * Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
17
* * Redistributions in binary form must reproduce the above
18
* copyright notice, this list of conditions and the following disclaimer
19
* in the documentation and/or other materials provided with the
22
* * The names of its contributors may not be used to endorse or
23
* promote products derived from this software without specific prior
26
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
%output "drizzled/execute/parser.cc"
45
%defines "drizzled/execute/parser.h"
46
%lex-param { yyscan_t *scanner }
47
%name-prefix="execute_"
48
%parse-param { ::drizzled::execute::Context *context }
49
%parse-param { yyscan_t *scanner }
60
#include <drizzled/execute/symbol.h>
61
#include <drizzled/execute/scanner.h>
62
#include <drizzled/execute/context.h>
65
#ifndef __INTEL_COMPILER
66
#pragma GCC diagnostic ignored "-Wold-style-cast"
69
#define YYENABLE_NLS 0
70
#define YYLTYPE_IS_TRIVIAL 0
72
int execute_lex(YYSTYPE* lvalp, void* scanner);
74
#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0)
76
inline void execute_error(::drizzled::execute::Context *context, yyscan_t *scanner, const char *error)
78
if (not context->end())
82
context->abort(context, error);*/
89
%token <string> STRING
90
%token <string> QUOTED_STRING
98
query.append( std::string($1.str, $1.length));
104
query.append(std::string($2.str, $2.length));
105
query.push_back(' ');
116
std::vector<std::string> Context::start()
118
execute_parse(this, (void **)scanner);
119
std::vector<std::string> parsed_queries;
120
while ((pos= query.find(';')) != std::string::npos)
122
parsed_queries.push_back(query.substr(0, pos));
123
if (query[pos+1] == ' ')
125
query= query.substr(pos + 2, query.length());
129
query= query.substr(pos + 1, query.length());
132
parsed_queries.push_back(query);
135
return parsed_queries;
138
} // namespace execute
139
} // namespace drizzled