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);
73
std::vector<std::string> parsed_queries;
75
size_t pos= std::string::npos;
76
#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0)
78
inline void execute_error(::drizzled::execute::Context *context, yyscan_t *scanner, const char *error)
80
if (not context->end())
84
context->abort(context, error);*/
85
(void)scanner; (void)error;
92
%token <string> STRING
93
%token <string> QUOTED_STRING
101
query.append( std::string($1.str, $1.length));
102
query.push_back(' ');
107
query.append(std::string($2.str, $2.length));
108
query.push_back(' ');
119
std::vector<std::string> Context::start()
121
execute_parse(this, (void **)scanner);
122
parsed_queries.clear();
123
while ((pos= query.find(';')) != std::string::npos)
125
parsed_queries.push_back(query.substr(0, pos));
126
if (query[pos+1] == ' ')
127
query= query.substr(pos + 2, query.length());
129
query= query.substr(pos + 1, query.length());
131
parsed_queries.push_back(query);
133
return parsed_queries;
136
} // namespace execute
137
} // namespace drizzled