3 //--------------------------------------------------------------------------
5 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 // Copyright 2008 by Sun Microsystems, Inc.
9 // OpenOffice.org - a multi-platform office productivity suite
11 // $RCSfile: sqlflex.l,v $
15 // This file is part of OpenOffice.org.
17 // OpenOffice.org is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU Lesser General Public License version 3
19 // only, as published by the Free Software Foundation.
21 // OpenOffice.org is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU Lesser General Public License version 3 for more details
25 // (a copy is included in the LICENSE file that accompanied this code).
27 // You should have received a copy of the GNU Lesser General Public License
28 // version 3 along with OpenOffice.org. If not, see
29 // <http://www.openoffice.org/license.html>
30 // for a copy of the LGPLv3 License.
32 //--------------------------------------------------------------------------
34 #define YY_EXIT 1 // YY_FATAL will not halt the application
37 #include <cstdarg> // std::va_list
44 #include "internalnode.hxx"
46 #ifndef _CONNECTIVITY_SQLYACC_HXX
47 #define _CONNECTIVITY_SQLYACC_HXX
53 #include "sqlbison.hxx"
55 #include "sqlscan.hxx"
56 #include <osl/diagnose.h>
57 #include <rtl/strbuf.hxx>
58 #include <connectivity/sqlparse.hxx>
61 #pragma GCC system_header
62 #elif defined __SUNPRO_CC
64 #elif defined _MSC_VER
65 #pragma warning(push, 1)
74 using namespace connectivity;
76 //=============================================================================
78 // Erzeugung der Blaetter fuer die Token
79 // Blaetter werden generell vom Lexer erzeugt
81 static ::rtl::OUString aEmptyString;
83 static sal_Int32 gatherString(sal_Int32 delim, sal_Int32 nTyp);
84 static sal_Int32 gatherName(const sal_Char*);
85 static sal_Int32 gatherNamePre(const sal_Char* );
86 // has to be set before the parser starts
87 OSQLScanner* xxx_pGLOBAL_SQLSCAN = NULL;
89 #define SQL_NEW_NODE(text, token) \
90 SQLyylval.pParseNode = new OSQLInternalNode(text, token);
92 #define SQL_NEW_KEYWORD(token) \
93 SQLyylval.pParseNode = new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, (token));
95 #define SQL_NEW_NAME SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME)
96 #define SQL_NEW_INTNUM SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_INTNUM)
97 #define SQL_NEW_APPROXNUM SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_APPROXNUM)
98 #define SQL_NEW_STRING SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_STRING)
99 #define SQL_NEW_COMPARISON SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_COMPARISON)
100 #define SQL_NEW_AMMSC SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_AMMSC)
101 #define SQL_NEW_DATE SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE)
103 #define YY_INPUT(buf,result,max_size) \
105 buf[0] = xxx_pGLOBAL_SQLSCAN->SQLyygetc(); \
106 result = buf[0] != -1; \
109 #define YY_FATAL_ERROR(msg) \
111 xxx_pGLOBAL_SQLSCAN->SQLyyerror(msg); \
115 //=============================================================================
126 %option never-interactive
129 [Aa][Bb][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_ABS); return SQL_TOKEN_ABS; }
130 [Aa][Cc][Oo][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_ACOS); return SQL_TOKEN_ACOS; }
131 [Aa][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_ALL); return SQL_TOKEN_ALL; }
132 [Aa][Ll][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_ALTER); return SQL_TOKEN_ALTER; }
133 [Aa][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_AND); return SQL_TOKEN_AND; }
134 [Aa][Nn][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_ANY); return SQL_TOKEN_ANY; }
135 [Aa][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_AS); return SQL_TOKEN_AS; }
136 [Aa][Ss][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_ASC); return SQL_TOKEN_ASC; }
137 [Aa][Ss][Cc][Ii][Ii] {SQL_NEW_KEYWORD(SQL_TOKEN_ASCII); return SQL_TOKEN_ASCII; }
138 [Aa][Ss][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_ASIN); return SQL_TOKEN_ASIN; }
139 [Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_AT); return SQL_TOKEN_AT; }
140 [Aa][Tt][Aa][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN); return SQL_TOKEN_ATAN; }
141 [Aa][Tt][Aa][Nn]2 {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN2); return SQL_TOKEN_ATAN2; }
142 [Aa][Uu][Tt][Hh][Oo][Rr][Ii][Zz][Aa][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_AUTHORIZATION); return SQL_TOKEN_AUTHORIZATION; }
143 [Aa][Vv][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_AVG); return SQL_TOKEN_AVG; }
145 [Bb][Ee][Tt][Ww][Ee][Ee][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_BETWEEN); return SQL_TOKEN_BETWEEN; }
146 [Bb][Ii][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_BIT); return SQL_TOKEN_BIT; }
147 [Bb][Ii][Tt]_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_BIT_LENGTH); return SQL_TOKEN_BIT_LENGTH; }
148 [Bb][Oo][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_BOTH); return SQL_TOKEN_BOTH; }
149 [Bb][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_BY); return SQL_TOKEN_BY; }
151 [Cc][Aa][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_CALL); return SQL_TOKEN_CALL; }
152 [Cc][Aa][Ss][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CAST); return SQL_TOKEN_CAST; }
153 [Cc][Hh][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR); return SQL_TOKEN_CHAR; }
154 [Cc][Hh][Aa][Rr][Aa][Cc][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_CHARACTER); return SQL_TOKEN_CHARACTER; }
155 [Cc][Hh][Aa][Rr]([Aa][Cc][Tt][Ee][Rr])?_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR_LENGTH); return SQL_TOKEN_CHAR_LENGTH; }
156 [Cc][Hh][Ee][Cc][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_CHECK); return SQL_TOKEN_CHECK; }
157 [Cc][Ee][Ii][Ll][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_CEILING); return SQL_TOKEN_CEILING; }
158 [Cc][Oo][Ll][Ll][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_COLLATE); return SQL_TOKEN_COLLATE; }
159 COLLECT {SQL_NEW_KEYWORD(SQL_TOKEN_COLLECT); return SQL_TOKEN_COLLECT; }
160 [Cc][Oo][Mm][Mm][Ii][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_COMMIT); return SQL_TOKEN_COMMIT; }
161 [Cc][Oo][Nn][Cc][Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CONCAT); return SQL_TOKEN_CONCAT; }
162 [Cc][Oo][Nn][Tt][Ii][Nn][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CONTINUE); return SQL_TOKEN_CONTINUE; }
163 [Cc][Oo][Nn][Vv][Ee][Rr][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CONVERT); return SQL_TOKEN_CONVERT; }
164 [Cc][Oo][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_COS); return SQL_TOKEN_COS; }
165 [Cc][Oo][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_COT); return SQL_TOKEN_COT; }
166 [Cc][Oo][Uu][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_COUNT); return SQL_TOKEN_COUNT; }
167 [Cc][Rr][Ee][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CREATE); return SQL_TOKEN_CREATE; }
168 [Cc][Rr][Oo][Ss][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_CROSS); return SQL_TOKEN_CROSS; }
169 [Cc][Uu][Rr][Rr][Ee][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT); return SQL_TOKEN_CURRENT; }
170 [Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DATE); return SQL_TOKEN_CURRENT_DATE; }
171 [Cc][Uu][Rr][Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURDATE); return SQL_TOKEN_CURDATE; }
172 [Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Tt][Ii][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIME); return SQL_TOKEN_CURRENT_TIME; }
173 [Cc][Uu][Rr][Tt][Ii][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_CURTIME); return SQL_TOKEN_CURTIME; }
174 [Cc][Uu][Rr][Rr][Ee][Nn][Tt]_[Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIMESTAMP); return SQL_TOKEN_CURRENT_TIMESTAMP; }
175 [Cc][Uu][Rr][Ss][Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_CURSOR); return SQL_TOKEN_CURSOR; }
177 [Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_D); return SQL_TOKEN_D; }
178 [Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DATE); return SQL_TOKEN_DATE; }
179 [Dd][Aa][Tt][Ee][Dd][Ii][Ff][Ff] {SQL_NEW_KEYWORD(SQL_TOKEN_DATEDIFF); return SQL_TOKEN_DATEDIFF; }
180 [Dd][Aa][Tt][Ee][Vv][Aa][Ll][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DATEVALUE); return SQL_TOKEN_DATEVALUE; }
181 [Dd][Aa][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_DAY); return SQL_TOKEN_DAY; }
182 [Dd][Aa][Yy][Nn][Aa][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DAYNAME); return SQL_TOKEN_DAYNAME; }
183 [Dd][Aa][Yy][Oo][Ff][Mm][Oo][Nn][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFMONTH); return SQL_TOKEN_DAYOFMONTH; }
184 [Dd][Aa][Yy][Oo][Ff][Ww][Ee][Ee][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFWEEK); return SQL_TOKEN_DAYOFWEEK; }
185 [Dd][Aa][Yy][Oo][Ff][Yy][Ee][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFYEAR); return SQL_TOKEN_DAYOFYEAR; }
186 [Dd][Ee][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_DEC); return SQL_TOKEN_DEC; }
187 [Dd][Ee][Cc][Ii][Mm][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_DECIMAL); return SQL_TOKEN_DECIMAL; }
188 [Dd][Ee][Cc][Ll][Aa][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DECLARE); return SQL_TOKEN_DECLARE; }
189 [Dd][Ee][Ff][Aa][Uu][Ll][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_DEFAULT); return SQL_TOKEN_DEFAULT; }
190 [Dd][Ee][Gg][Rr][Ee][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_DEGREES); return SQL_TOKEN_DEGREES; }
191 [Dd][Ee][Ll][Ee][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DELETE); return SQL_TOKEN_DELETE; }
192 [Dd][Ee][Ss][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_DESC); return SQL_TOKEN_DESC; }
193 [Dd][Ii][Ff][Ff][Ee][Rr][Ee][Nn][Cc][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DIFFERENCE); return SQL_TOKEN_DIFFERENCE; }
194 [Dd][Ii][Ss][Tt][Ii][Nn][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_DISTINCT); return SQL_TOKEN_DISTINCT; }
195 [Dd][Oo][Uu][Bb][Ll][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_DOUBLE); return SQL_TOKEN_DOUBLE; }
196 [Dd][Rr][Oo][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_DROP); return SQL_TOKEN_DROP; }
198 EVERY {SQL_NEW_KEYWORD(SQL_TOKEN_EVERY); return SQL_TOKEN_EVERY; }
199 [Ee][Ss][Cc][Aa][Pp][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE); return SQL_TOKEN_ESCAPE; }
200 [Ee][Xx][Cc][Ee][Pp][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT); return SQL_TOKEN_EXCEPT; }
201 [Ee][Xx][Ii][Ss][Tt][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS); return SQL_TOKEN_EXISTS; }
202 [Ee][Xx][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_EXP); return SQL_TOKEN_EXP; }
203 [Ee][Xx][Tt][Rr][Aa][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); return SQL_TOKEN_EXTRACT; }
205 [Ff][Aa][Ll][Ss][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE); return SQL_TOKEN_FALSE; }
206 [Ff][Ee][Tt][Cc][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH); return SQL_TOKEN_FETCH; }
207 [Ff][Ll][Oo][Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT); return SQL_TOKEN_FLOAT; }
208 [Ff][Ll][Oo][Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_FLOOR); return SQL_TOKEN_FLOOR; }
209 [Ff][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_FN); return SQL_TOKEN_FN; }
210 [Ff][Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_FOR); return SQL_TOKEN_FOR; }
211 [Ff][Oo][Rr][Ee][Ii][Gg][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN); return SQL_TOKEN_FOREIGN; }
212 [Ff][Oo][Uu][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND); return SQL_TOKEN_FOUND; }
213 [Ff][Rr][Oo][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_FROM); return SQL_TOKEN_FROM; }
214 [Ff][Uu][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_FULL); return SQL_TOKEN_FULL; }
215 FUSION {SQL_NEW_KEYWORD(SQL_TOKEN_FUSION); return SQL_TOKEN_FUSION; }
217 [Gg][Rr][Aa][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_GRANT); return SQL_TOKEN_GRANT; }
218 [Gg][Rr][Oo][Uu][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP); return SQL_TOKEN_GROUP; }
220 [Hh][Aa][Vv][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING); return SQL_TOKEN_HAVING; }
221 [Hh][Oo][Uu][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR); return SQL_TOKEN_HOUR; }
223 [Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_IN); return SQL_TOKEN_IN; }
224 [Ii][Nn][Nn][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_INNER); return SQL_TOKEN_INNER; }
225 [Ii][Nn][Ss][Ee][Rr][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT); return SQL_TOKEN_INSERT; }
226 [Ii][Nn][Tt]([Ee][Gg][Ee][Rr])? {SQL_NEW_KEYWORD(SQL_TOKEN_INTEGER); return SQL_TOKEN_INTEGER; }
227 [Ii][Nn][Tt][Ee][Rr][Ss][Ee][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECT); return SQL_TOKEN_INTERSECT; }
228 INTERSECTION {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECTION); return SQL_TOKEN_INTERSECTION; }
229 [Ii][Nn][Tt][Oo] {SQL_NEW_KEYWORD(SQL_TOKEN_INTO); return SQL_TOKEN_INTO; }
230 [Ii][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_IS); return SQL_TOKEN_IS; }
232 [Jj][Oo][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN); return SQL_TOKEN_JOIN; }
234 [Kk][Ee][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_KEY); return SQL_TOKEN_KEY; }
236 [Ll][Cc][Aa][Ss][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_LCASE); return SQL_TOKEN_LCASE; }
237 [Ll][Ee][Aa][Dd][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING); return SQL_TOKEN_LEADING; }
238 [Ll][Ee][Ff][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT); return SQL_TOKEN_LEFT; }
239 [Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_LENGTH); return SQL_TOKEN_LENGTH; }
240 [Ll][Ii][Kk][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE); return SQL_TOKEN_LIKE; }
241 [Ll][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_LN); return SQL_TOKEN_LN; }
242 [Ll][Oo][Cc][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL); return SQL_TOKEN_LOCAL; }
243 [Ll][Oo][Cc][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_LOCATE); return SQL_TOKEN_LOCATE; }
244 [Ll][Oo][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_LOG); return SQL_TOKEN_LOG; }
245 [Ll][Oo][Gg][Ff] {SQL_NEW_KEYWORD(SQL_TOKEN_LOGF); return SQL_TOKEN_LOGF; }
246 [Ll][Oo][Gg]10 {SQL_NEW_KEYWORD(SQL_TOKEN_LOG10); return SQL_TOKEN_LOG10; }
247 [Ll][Oo][Ww][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_LOWER); return SQL_TOKEN_LOWER; }
248 [Ll][Tt][Rr][Ii][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_LTRIM); return SQL_TOKEN_LTRIM; }
250 [Mm][Aa][Xx] {SQL_NEW_KEYWORD(SQL_TOKEN_MAX); return SQL_TOKEN_MAX; }
251 [Mm][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_MIN); return SQL_TOKEN_MIN; }
252 [Mm][Ii][Nn][Uu][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_MINUTE); return SQL_TOKEN_MINUTE; }
253 [Mm][Oo][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_MOD); return SQL_TOKEN_MOD; }
254 [Mm][Oo][Nn][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_MONTH); return SQL_TOKEN_MONTH; }
255 [Mm][Oo][Nn][Tt][Hh][Nn][Aa][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_MONTHNAME); return SQL_TOKEN_MONTHNAME; }
257 [Nn][Aa][Tt][Uu][Rr][Aa][LL] {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL); return SQL_TOKEN_NATURAL; }
258 [Nn][Cc][Hh][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR); return SQL_TOKEN_NCHAR; }
259 [Nn][Oo][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_NOT); return SQL_TOKEN_NOT; }
260 [Nn][Oo][Ww] {SQL_NEW_KEYWORD(SQL_TOKEN_NOW); return SQL_TOKEN_NOW; }
261 [Nn][Uu][Ll][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_NULL); return SQL_TOKEN_NULL; }
262 [Nn][Uu][Mm][Ee][Rr][Ii][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC); return SQL_TOKEN_NUMERIC; }
264 [Oo][Cc][Tt][Ee][Tt]_[Ll][Ee][Nn][Gg][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_OCTET_LENGTH); return SQL_TOKEN_OCTET_LENGTH; }
265 [Oo][Ff] {SQL_NEW_KEYWORD(SQL_TOKEN_OF); return SQL_TOKEN_OF; }
266 [Oo][Jj] {SQL_NEW_KEYWORD(SQL_TOKEN_OJ); return SQL_TOKEN_OJ; }
267 [Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_ON); return SQL_TOKEN_ON; }
268 [Oo][Pp][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION); return SQL_TOKEN_OPTION; }
269 [Oo][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_OR); return SQL_TOKEN_OR; }
270 [Oo][Rr][Dd][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER); return SQL_TOKEN_ORDER; }
271 [Oo][Uu][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER); return SQL_TOKEN_OUTER; }
273 [Pp][Ii] {SQL_NEW_KEYWORD(SQL_TOKEN_PI); return SQL_TOKEN_PI; }
274 [Pp][Oo][Ss][Ii][Tt][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION); return SQL_TOKEN_POSITION; }
275 [Pp][Oo][Ww][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_POWER); return SQL_TOKEN_POWER; }
276 [Pp][Rr][Ee][Cc][Ii][Ss][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION); return SQL_TOKEN_PRECISION; }
277 [Pp][Rr][Ii][Mm][Aa][Rr][Yy] {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY); return SQL_TOKEN_PRIMARY; }
278 [Pp][Rr][Ii][Vv][Ii][Ll][Ee][Gg][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES); return SQL_TOKEN_PRIVILEGES; }
279 [Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_PROCEDURE); return SQL_TOKEN_PROCEDURE; }
280 [Pp][Uu][Bb][Ll][Ii][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_PUBLIC); return SQL_TOKEN_PUBLIC; }
282 [Qq][Uu][Aa][Rr][Tt][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_QUARTER); return SQL_TOKEN_QUARTER; }
284 [Rr][Aa][Dd][Ii][Aa][Nn][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_RADIANS); return SQL_TOKEN_RADIANS; }
285 [Rr][Aa][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_RAND); return SQL_TOKEN_RAND; }
286 [Rr][Ee][Aa][Ll] {SQL_NEW_KEYWORD(SQL_TOKEN_REAL); return SQL_TOKEN_REAL; }
287 [Rr][Ee][Ff][Ee][Rr][Ee][Nn][Cc][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES); return SQL_TOKEN_REFERENCES; }
288 [Rr][Ee][Pp][Ee][Aa][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_REPEAT); return SQL_TOKEN_REPEAT; }
289 [Rr][Ee][Pp][Ll][Aa][Cc][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_REPLACE); return SQL_TOKEN_REPLACE; }
290 [Rr][Oo][Ll][Ll][Bb][Aa][Cc][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK); return SQL_TOKEN_ROLLBACK; }
291 [Rr][Oo][Uu][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_ROUND); return SQL_TOKEN_ROUND; }
292 [Rr][Oo][Uu][Nn][Dd][Mm][Aa][Gg][Ii][Cc] {SQL_NEW_KEYWORD(SQL_TOKEN_ROUNDMAGIC); return SQL_TOKEN_ROUNDMAGIC; }
293 [Rr][Ii][Gg][Hh][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT); return SQL_TOKEN_RIGHT; }
294 [Rr][Tt][Rr][Ii][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_RTRIM); return SQL_TOKEN_RTRIM; }
296 [Ss][Cc][Hh][Ee][Mm][Aa] {SQL_NEW_KEYWORD(SQL_TOKEN_SCHEMA); return SQL_TOKEN_SCHEMA; }
297 [Ss][Ee][Cc][Oo][Nn][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_SECOND); return SQL_TOKEN_SECOND; }
298 [Ss][Ee][Ll][Ee][Cc][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SELECT); return SQL_TOKEN_SELECT; }
299 [Ss][Ee][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SET); return SQL_TOKEN_SET; }
300 [Ss][Ii][Zz][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_SIZE); return SQL_TOKEN_SIZE; }
301 [Ss][Ii][Gg][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_SIGN); return SQL_TOKEN_SIGN; }
302 [Ss][Ii][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_SIN); return SQL_TOKEN_SIN; }
303 [Ss][Mm][Aa][Ll][Ll][Ii][Nn][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SMALLINT); return SQL_TOKEN_SMALLINT; }
304 [Ss][Oo][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_SOME); return SQL_TOKEN_SOME; }
305 [Ss][Oo][Uu][Nn][Dd][Ee][Xx] {SQL_NEW_KEYWORD(SQL_TOKEN_SOUNDEX); return SQL_TOKEN_SOUNDEX; }
306 [Ss][Pp][Aa][Cc][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_SPACE); return SQL_TOKEN_SPACE; }
307 [Ss][Qq][Rr][Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_SQRT); return SQL_TOKEN_SQRT; }
308 STDDEV_POP {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_POP); return SQL_TOKEN_STDDEV_POP; }
309 STDDEV_SAMP {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_SAMP); return SQL_TOKEN_STDDEV_SAMP; }
310 [Ss][Uu][Bb][Ss][Tt][Rr][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_SUBSTRING); return SQL_TOKEN_SUBSTRING; }
311 [Ss][Uu][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_SUM); return SQL_TOKEN_SUM; }
313 [Tt][Aa][Bb][Ll][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE); return SQL_TOKEN_TABLE; }
314 [Tt][Aa][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_TAN); return SQL_TOKEN_TAN; }
315 [Tt][Ii][Mm][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TIME); return SQL_TOKEN_TIME; }
316 [Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP); return SQL_TOKEN_TIMESTAMP; }
317 [Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp][Aa][Dd][Dd] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPADD); return SQL_TOKEN_TIMESTAMPADD; }
318 [Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp][Dd][Ii][Ff][Ff] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPDIFF); return SQL_TOKEN_TIMESTAMPDIFF; }
319 [Tt][Ii][Mm][Ee][Vv][Aa][Ll][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEVALUE); return SQL_TOKEN_TIMEVALUE; }
320 [Tt][Ii][Mm][Ee][Zz][Oo][Nn][Ee]_[Hh][Oo][Uu][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_HOUR); return SQL_TOKEN_TIMEZONE_HOUR; }
321 [Tt][Ii][Mm][Ee][Zz][Oo][Nn][Ee]_[Mm][Ii][Nn][Uu][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_MINUTE); return SQL_TOKEN_TIMEZONE_MINUTE; }
322 [Tt][Oo] {SQL_NEW_KEYWORD(SQL_TOKEN_TO); return SQL_TOKEN_TO; }
323 [Tt][Rr][Aa][Ii][Ll][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_TRAILING); return SQL_TOKEN_TRAILING; }
324 [Tt][Rr][Aa][Nn][Ss][Ll][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TRANSLATE); return SQL_TOKEN_TRANSLATE; }
325 [Tt][Rr][Ii][Mm] {SQL_NEW_KEYWORD(SQL_TOKEN_TRIM); return SQL_TOKEN_TRIM; }
326 [Tt][Rr][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TRUE); return SQL_TOKEN_TRUE; }
327 [Tt][Rr][Uu][Nn][Cc][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_TRUNCATE); return SQL_TOKEN_TRUNCATE; }
328 [Tt][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_TS); return SQL_TOKEN_TS; }
329 [Tt] {SQL_NEW_KEYWORD(SQL_TOKEN_T); return SQL_TOKEN_T; }
331 [Uu][Cc][Aa][Ss][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_UCASE); return SQL_TOKEN_UCASE; }
332 [Uu][Nn][Ii][Oo][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_UNION); return SQL_TOKEN_UNION; }
333 [Uu][Nn][Ii][Qq][Uu][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE); return SQL_TOKEN_UNIQUE; }
334 [Uu][Nn][Kk][Nn][Oo][Ww][Nn] {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN); return SQL_TOKEN_UNKNOWN; }
335 [Uu][Pp][Dd][Aa][Tt][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_UPDATE); return SQL_TOKEN_UPDATE; }
336 [Uu][Pp][Pp][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_UPPER); return SQL_TOKEN_UPPER; }
337 [Uu][Ss][Aa][Gg][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_USAGE); return SQL_TOKEN_USAGE; }
338 [Uu][Ss][Ee][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_USER); return SQL_TOKEN_USER; }
339 [Uu][Ss][Ii][Nn][Gg] {SQL_NEW_KEYWORD(SQL_TOKEN_USING); return SQL_TOKEN_USING; }
341 VAR_POP {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_POP); return SQL_TOKEN_VAR_POP; }
342 VAR_SAMP {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_SAMP); return SQL_TOKEN_VAR_SAMP; }
343 [Vv][Aa][Ll][Uu][Ee][Ss] {SQL_NEW_KEYWORD(SQL_TOKEN_VALUES); return SQL_TOKEN_VALUES; }
344 [Vv][Ii][Ee][Ww] {SQL_NEW_KEYWORD(SQL_TOKEN_VIEW); return SQL_TOKEN_VIEW; }
346 [Ww][Ee][Ee][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_WEEK); return SQL_TOKEN_WEEK; }
347 [Ww][Hh][Ee][Rr][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_WHERE); return SQL_TOKEN_WHERE; }
348 [Ww][Ii][Tt][Hh] {SQL_NEW_KEYWORD(SQL_TOKEN_WITH); return SQL_TOKEN_WITH; }
349 [Ww][Oo][Rr][Kk] {SQL_NEW_KEYWORD(SQL_TOKEN_WORK); return SQL_TOKEN_WORK; }
351 [Yy][Ee][Aa][Rr] {SQL_NEW_KEYWORD(SQL_TOKEN_YEAR); return SQL_TOKEN_YEAR; }
353 [Zz][Oo][Nn][Ee] {SQL_NEW_KEYWORD(SQL_TOKEN_ZONE); return SQL_TOKEN_ZONE; }
355 "<" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_LESS);return SQL_LESS;}
356 ">" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_GREAT);return SQL_GREAT;}
357 "=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_EQUAL);return SQL_EQUAL;}
358 "<=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_LESSEQ);return SQL_LESSEQ;}
359 ">=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_GREATEQ);return SQL_GREATEQ;}
360 "<>" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_NOTEQUAL);return SQL_NOTEQUAL;}
361 "!=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_NOTEQUAL);return SQL_NOTEQUAL;}
362 "||" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_CONCAT);return SQL_CONCAT;}
365 [-+*/:(),.;?{}] { return SQLyytext[0]; }
368 <SQL>[A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375][A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375_0-9]* {return gatherName( SQLyytext);}
371 <SQL>([0-9]+"."[0-9]*) |
372 <SQL>("."[0-9]*) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;}
374 <SQL>[0-9]+[eE][+-]?[0-9]+ |
375 <SQL>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
376 <SQL>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; }
378 <PREDICATE_GER,PREDICATE_ENG,DATE>[A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375][A-Za-z0-9_%.,*?\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375]* {return gatherNamePre(SQLyytext);}
380 <PREDICATE_GER,PREDICATE_ENG>([0-9]+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;}
381 <PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;}
382 <PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+) {SQL_NEW_INTNUM; return SQL_TOKEN_INTNUM;}
384 <PREDICATE_ENG>([0-9]+"."[0-9]+) |
385 <PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+"."[0-9]+) |
386 <PREDICATE_ENG>("."[0-9]+) {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; }
387 <PREDICATE_ENG>[0-9]+[eE][+-]?[0-9]+ |
388 <PREDICATE_ENG>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
389 <PREDICATE_ENG>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; }
391 <PREDICATE_GER>([0-9]+","[0-9]+) |
392 <PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+","[0-9]+) |
393 <PREDICATE_GER>(","[0-9]+) {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; }
394 <PREDICATE_GER>[0-9]+[eE][+-]?[0-9]+ |
395 <PREDICATE_GER>[0-9]+","[0-9]*[eE][+-]?[0-9]+ |
396 <PREDICATE_GER>","[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; return SQL_TOKEN_APPROXNUM; }
398 <PREDICATE_GER,PREDICATE_ENG>[0-9.,][A-Za-z0-9_.,%]* {return gatherNamePre(SQLyytext);}
400 <SQL>\" { return gatherString('\"',0); }
401 <SQL>` { return gatherString('`' ,0); }
403 <PREDICATE_GER,PREDICATE_ENG,DATE>"[" { return gatherString(']' ,0);}
405 \' { return gatherString('\'',1); }
407 <PREDICATE_GER,PREDICATE_ENG,DATE># { return gatherString('#' ,2); }
409 <DATE>[0-9]{1,4}[^ ]*[0-9] |
410 <DATE>[0-9]{1,4}[^ ]*[0-9][ ][0-9]{1,4}[^ ]*[0-9] { SQL_NEW_DATE; return SQL_TOKEN_ACCESS_DATE;}
412 <STRING>["-""+""*""/"":""("")"",""."";""?""{""}"] { return SQLyytext[0]; } /* */
413 <STRING>"[" { return gatherString(']' ,0); }
414 <STRING>[^ ':["?"]* { return gatherNamePre(SQLyytext); }
422 . {YY_FATAL_ERROR("Invalid symbol"); return SQL_TOKEN_INVALIDSYMBOL;}
426 // Kludge around a bug (well, Posix incompatibility) in flex 2.5.x
427 // http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=189332
428 #if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5
430 #ifndef YY_FLUSH_BUFFER
431 #define YY_FLUSH_BUFFER SQLyy_flush_buffer(YY_CURRENT_BUFFER )
435 #define yytext_ptr SQLyytext
440 // Versions of flex apparently differ in whether input() resp. yyinput() returns
441 // zero or EOF upon end of file:
442 inline bool checkeof(int c) { return c == 0 || c == EOF; }
445 * Read SQL string literal
447 * '' 'a string' 'quote '' within string'
448 * "" "a string" "quote "" within string"
449 * nTyp == 0 -> SQL_NODE_NAME
450 * nTyp == 1 -> SQL_NODE_STRING
451 * nTyp == 2 -> SQL_NODE_ACCESS_DATE
453 sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp)
456 ::rtl::OStringBuffer sBuffer(256);
458 while (!checkeof(ch = yyinput()))
462 if ((ch = yyinput()) != delim)
470 SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
471 return SQL_TOKEN_NAME;
473 SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_STRING);
474 return SQL_TOKEN_STRING;
476 SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE);
477 return SQL_TOKEN_ACCESS_DATE;
486 else if (nTyp != 1 && (ch == '\r' || ch == '\n') )
493 YY_FATAL_ERROR("Unterminated name string");
494 return SQL_TOKEN_INVALIDSYMBOL;
497 sal_Int32 mapEnumToToken(IParseContext::InternationalKeyCode _eKeyCode )
499 sal_Int32 nTokenID = 0;
502 case IParseContext::KEY_LIKE: nTokenID = SQL_TOKEN_LIKE; break;
503 case IParseContext::KEY_NOT: nTokenID = SQL_TOKEN_NOT; break;
504 case IParseContext::KEY_NULL: nTokenID = SQL_TOKEN_NULL; break;
505 case IParseContext::KEY_TRUE: nTokenID = SQL_TOKEN_TRUE; break;
506 case IParseContext::KEY_FALSE: nTokenID = SQL_TOKEN_FALSE; break;
507 case IParseContext::KEY_IS: nTokenID = SQL_TOKEN_IS; break;
508 case IParseContext::KEY_BETWEEN: nTokenID = SQL_TOKEN_BETWEEN; break;
509 case IParseContext::KEY_OR: nTokenID = SQL_TOKEN_OR; break;
510 case IParseContext::KEY_AND: nTokenID = SQL_TOKEN_AND; break;
511 case IParseContext::KEY_AVG: nTokenID = SQL_TOKEN_AVG; break;
512 case IParseContext::KEY_COUNT: nTokenID = SQL_TOKEN_COUNT; break;
513 case IParseContext::KEY_MAX: nTokenID = SQL_TOKEN_MAX; break;
514 case IParseContext::KEY_MIN: nTokenID = SQL_TOKEN_MIN; break;
515 case IParseContext::KEY_SUM: nTokenID = SQL_TOKEN_SUM; break;
516 case IParseContext::KEY_EVERY: nTokenID = SQL_TOKEN_EVERY; break;
517 case IParseContext::KEY_ANY: nTokenID = SQL_TOKEN_ANY; break;
518 case IParseContext::KEY_SOME: nTokenID = SQL_TOKEN_SOME; break;
519 case IParseContext::KEY_STDDEV_POP: nTokenID = SQL_TOKEN_STDDEV_POP; break;
520 case IParseContext::KEY_STDDEV_SAMP: nTokenID = SQL_TOKEN_STDDEV_SAMP; break;
521 case IParseContext::KEY_VAR_SAMP: nTokenID = SQL_TOKEN_VAR_SAMP; break;
522 case IParseContext::KEY_VAR_POP: nTokenID = SQL_TOKEN_VAR_POP; break;
523 case IParseContext::KEY_COLLECT: nTokenID = SQL_TOKEN_COLLECT; break;
524 case IParseContext::KEY_FUSION: nTokenID = SQL_TOKEN_FUSION; break;
525 case IParseContext::KEY_INTERSECTION: nTokenID = SQL_TOKEN_INTERSECTION; break;
527 OSL_ENSURE( false, "mapEnumToToken: unsupported key!" );
532 * Read SQL Name literal
533 * Valid Names or internatioanl keywords:
534 * As we have international keywords, we test first on them
536 sal_Int32 gatherName(const sal_Char* text)
539 OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
540 IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
543 case IParseContext::KEY_LIKE:
544 case IParseContext::KEY_NOT:
545 case IParseContext::KEY_NULL:
546 case IParseContext::KEY_TRUE:
547 case IParseContext::KEY_FALSE:
548 case IParseContext::KEY_IS:
549 case IParseContext::KEY_BETWEEN:
550 case IParseContext::KEY_OR:
551 case IParseContext::KEY_AND:
552 case IParseContext::KEY_COUNT:
553 case IParseContext::KEY_AVG:
554 case IParseContext::KEY_MAX:
555 case IParseContext::KEY_MIN:
556 case IParseContext::KEY_SUM:
557 case IParseContext::KEY_EVERY:
558 case IParseContext::KEY_ANY:
559 case IParseContext::KEY_SOME:
560 case IParseContext::KEY_STDDEV_POP:
561 case IParseContext::KEY_STDDEV_SAMP:
562 case IParseContext::KEY_VAR_SAMP:
563 case IParseContext::KEY_VAR_POP:
564 case IParseContext::KEY_COLLECT:
565 case IParseContext::KEY_FUSION:
566 case IParseContext::KEY_INTERSECTION:
567 nToken = mapEnumToToken(eKeyCode);
568 SQL_NEW_KEYWORD(nToken);
571 SQL_NEW_NODE(::rtl::OUString(text,strlen(text),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
572 return SQL_TOKEN_NAME;
576 Read SQL Name literal for predicate check
577 Valid Names or internatioanl keywords:
578 As we have international keywords, we test first on them
580 sal_Int32 gatherNamePre(const sal_Char* text)
583 OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
584 IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
587 case IParseContext::KEY_LIKE:
588 case IParseContext::KEY_NOT:
589 case IParseContext::KEY_NULL:
590 case IParseContext::KEY_TRUE:
591 case IParseContext::KEY_FALSE:
592 case IParseContext::KEY_IS:
593 case IParseContext::KEY_BETWEEN:
594 case IParseContext::KEY_OR:
595 case IParseContext::KEY_AND:
596 case IParseContext::KEY_COUNT:
597 case IParseContext::KEY_AVG:
598 case IParseContext::KEY_MAX:
599 case IParseContext::KEY_MIN:
600 case IParseContext::KEY_SUM:
601 case IParseContext::KEY_EVERY:
602 case IParseContext::KEY_ANY:
603 case IParseContext::KEY_SOME:
604 case IParseContext::KEY_STDDEV_POP:
605 case IParseContext::KEY_STDDEV_SAMP:
606 case IParseContext::KEY_VAR_SAMP:
607 case IParseContext::KEY_VAR_POP:
608 case IParseContext::KEY_COLLECT:
609 case IParseContext::KEY_FUSION:
610 case IParseContext::KEY_INTERSECTION:
611 nToken = mapEnumToToken(eKeyCode);
612 SQL_NEW_KEYWORD(nToken);
615 // we need a special handling for parameter
617 ::rtl::OString sStmt = xxx_pGLOBAL_SQLSCAN->getStatement();
618 sal_Int32 nLength = strlen(text);
619 sal_Int32 nPos = xxx_pGLOBAL_SQLSCAN->GetCurrentPos() - nLength - 2;
620 if (sStmt.getStr()[nPos] == ':')
622 SQL_NEW_NODE(::rtl::OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
623 nToken = SQL_TOKEN_NAME;
627 SQL_NEW_NODE(::rtl::OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQL_NODE_STRING);
628 nToken = SQL_TOKEN_STRING;
635 using namespace connectivity;
637 static sal_uInt32 Intl_TokenID[] =
639 SQL_TOKEN_LIKE, SQL_TOKEN_NOT, SQL_TOKEN_NULL, SQL_TOKEN_TRUE,
640 SQL_TOKEN_FALSE, SQL_TOKEN_IS, SQL_TOKEN_BETWEEN, SQL_TOKEN_OR,
641 SQL_TOKEN_AND, SQL_TOKEN_AVG, SQL_TOKEN_COUNT, SQL_TOKEN_MAX,
642 SQL_TOKEN_MIN, SQL_TOKEN_SUM
644 static bool IN_SQLyyerror;
645 //------------------------------------------------------------------------------
646 OSQLScanner::OSQLScanner()
648 , m_bInternational(sal_False)
650 , m_nRule(0) // 0 is INITIAL
652 IN_SQLyyerror = false;
655 //------------------------------------------------------------------------------
656 OSQLScanner::~OSQLScanner()
659 //------------------------------------------------------------------------------
660 void OSQLScanner::SQLyyerror(sal_Char *fmt)
665 IN_SQLyyerror = true;
667 OSL_ENSURE(m_pContext, "OSQLScanner::SQLyyerror: No Context set");
668 m_sErrorMessage = ::rtl::OUString(fmt,strlen(fmt),RTL_TEXTENCODING_UTF8);
669 if (m_nCurrentPos < m_sStatement.getLength())
671 m_sErrorMessage += ::rtl::OUString::createFromAscii(": ");
673 ::rtl::OUString aError;
674 static sal_Int32 BUFFERSIZE = 256;
675 static sal_Char* Buffer = 0;
677 Buffer = new sal_Char[BUFFERSIZE];
679 sal_Char *s = Buffer;
681 sal_Int32 ch = SQLyytext ? (SQLyytext[0] == 0 ? ' ' : SQLyytext[0]): ' ';
683 while (!checkeof(ch = yyinput()))
687 if ((ch = yyinput()) != ' ')
693 aError = ::rtl::OUString(Buffer,nPos,RTL_TEXTENCODING_UTF8);
699 if (++nPos == BUFFERSIZE)
701 ::rtl::OString aBuf(Buffer);
704 Buffer = new sal_Char[BUFFERSIZE];
705 for(sal_Int32 i=0;i<aBuf.getLength();++i,++Buffer)
706 *Buffer = aBuf.getStr()[i];
711 m_sErrorMessage += aError;
715 IN_SQLyyerror = false;
719 //------------------------------------------------------------------------------
720 void OSQLScanner::prepareScan(const ::rtl::OUString & rNewStatement, const IParseContext* pContext, sal_Bool bInternational)
725 m_sErrorMessage = ::rtl::OUString();
726 m_sStatement = ::rtl::OString(rNewStatement,rNewStatement.getLength(), RTL_TEXTENCODING_UTF8);
728 m_bInternational = bInternational;
729 m_pContext = pContext;
732 //------------------------------------------------------------------------------
733 sal_Int32 OSQLScanner::SQLyygetc(void)
735 sal_Int32 nPos = (m_nCurrentPos >= m_sStatement.getLength()) ? -1 : m_sStatement.getStr()[m_nCurrentPos];
740 //------------------------------------------------------------------------------
741 IParseContext::InternationalKeyCode OSQLScanner::getInternationalTokenID(const sal_Char* sToken) const
743 OSL_ENSURE(m_pContext, "OSQLScanner::getInternationalTokenID: No Context set");
744 return (m_bInternational) ? m_pContext->getIntlKeyCode(::rtl::OString(sToken) ) : IParseContext::KEY_NONE;
746 // -------------------------------------------------------------------------
747 sal_Int32 OSQLScanner::GetCurrentRule() const { return m_nRule; }
748 sal_Int32 OSQLScanner::GetGERRule() const { return PREDICATE_GER; }
749 sal_Int32 OSQLScanner::GetENGRule() const { return PREDICATE_ENG; }
750 sal_Int32 OSQLScanner::GetSQLRule() const { return SQL; }
751 sal_Int32 OSQLScanner::GetDATERule() const { return DATE; }
752 sal_Int32 OSQLScanner::GetSTRINGRule() const { return STRING; }
753 // -------------------------------------------------------------------------
754 void OSQLScanner::setScanner(sal_Bool _bNull)
756 xxx_pGLOBAL_SQLSCAN = _bNull ? NULL : this;
758 // -------------------------------------------------------------------------
759 sal_Int32 OSQLScanner::SQLlex()
764 #if defined __SUNPRO_CC
766 #elif defined _MSC_VER