drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
scanner.l
1/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Drizzle Execute Parser
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2011 Vijay Samuel, [email protected]
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
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
20 * distribution.
21 *
22 * * The names of its contributors may not be used to endorse or
23 * promote products derived from this software without specific prior
24 * written permission.
25 *
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.
37 *
38 */
39
40%top{
41
42#include <config.h>
43#include <unistd.h>
44
45#ifndef execute_HEADER_H
46# define execute_HEADER_H 1
47#endif
48
49#include "drizzled/execute/common.h"
50#include "drizzled/lex_string.h"
51
52using namespace drizzled;
53
54#pragma GCC diagnostic ignored "-Wold-style-cast"
55#pragma GCC diagnostic ignored "-Wsign-compare"
56#pragma GCC diagnostic ignored "-Wunused-parameter"
57#pragma GCC diagnostic ignored "-Wmissing-declarations"
58
59#ifndef YY_EXTRA_TYPE
60# define YY_EXTRA_TYPE drizzled::execute::Context*
61#endif
62
TODO: Rename this file - func.h is stupid.
63}
64
65
66%{
67#include <cstdio>
68#include <cstdlib>
69#include <cstring>
70
71#define PARAM yyget_extra(yyscanner)
72
73#define get_lex_chars(buffer, result, max_size, context) \
74{ \
75 if (context->pos >= context->length) \
76 { \
77 result= YY_NULL; \
78 } \
79 else \
80 { \
81 result= (int)(context->length - context->pos); \
82 (size_t)result > (size_t)max_size ? result= max_size : 0; \
83 memcpy(buffer, context->buf + context->pos, result); \
84 context->pos += result; \
85 } \
86}
87
88
89#define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
90
91%}
92
93
94UTF8_BYTE_ORDER_MARK [\xEF][\xBB][\xBF]
95
96DIGITS [0-9]
97ASCII [\x0-\xFF]
98
99U1 [a-zA-Z_]
100U2 [\xC2-\xDF][\x80-\xBF]
101U3 [\xE0][\xA0-\xBF][\x80-\xBF]
102U4 [\xE1-\xEC][\x80-\xBF][\x80-\xBF]
103U5 [\xED][\x80-\x9F][\x80-\xBF]
104U6 [\xEE-\xEF][\x80-\xBF][\x80-\xBF]
105U7 [\nxF0][\x90-\xBF][\x80-\xBF][\x80-\xBF]
106U8 [\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]
107U9 [\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF]
108
109LETTERS {ASCII}|{U2}|{U3}|{U4}|{U5}|{U6}|{U7}|{U8}|{U9}
110ALNUM {LETTERS}|{DIGITS}
111
112%option nounistd
113%option 8bit
114%option bison-bridge
115%option case-insensitive
116%option debug
117%option nounput
118%option noyywrap
119%option outfile="drizzled/execute/scanner.cc" header-file="drizzled/execute/scanner.h"
120%option perf-report
121%option prefix="execute_"
122%option reentrant
123%option never-interactive
124%%
125
126{UTF8_BYTE_ORDER_MARK} { /* Byte Order Mark */ }
127
128[\t\r\n ] ; /* skip whitespace */
129
130
131[[:punct:]]?{ALNUM}*["."{ALNUM}_-]*{ALNUM}*[[:punct:]]? {
132 yylval->string.assign(yytext, yyleng);
133 return STRING;
134 }
135
136%%
137namespace drizzled {
138namespace execute {
139
140void Context::init_scanner()
141{
142 yylex_init(&scanner);
143 yyset_extra(this, scanner);
144}
145
146void Context::destroy_scanner()
147{
148 yylex_destroy(scanner);
149}
150
151} // namespace execute
152} // namespace drizzled