tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / connectivity / source / parse / sqlflex.l
blob44daeb236bf71cc3adcf93f1eb37d0c36d23a413
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
22 #include "sal/config.h"
24 #define YY_EXIT 1               // YY_FATAL will not halt the application
26 #ifndef _CSTDARG_
27 #include <cstdarg>
28 #endif
30 #include <string.h>
32 #if defined _MSC_VER
33 #pragma warning ( push )
34 // Silence warnings about redefinition of INT8_MIN etc in stdint.h
35 // The flex-generated workdir/LexTarget/idlc/source/scanner.cxx defines them prior to these includes
36 #pragma warning ( disable : 4005 )
37 #endif
38 #include <connectivity/internalnode.hxx>
39 #if defined _MSC_VER
40 #pragma warning(pop)
41 #endif
43 #ifndef INCLUDED_CONNECTIVITY_SOURCE_PARSE_SQLFLEX_L
44 #define INCLUDED_CONNECTIVITY_SOURCE_PARSE_SQLFLEX_L
46 #ifndef SQLYYDEBUG
47 #define SQLYYDEBUG 1
48 #endif
50 #include "sqlbison.hxx"
51 #undef SQLyylex
52 #undef SQLyyerror
53 #endif
54 #include <osl/diagnose.h>
55 #include <rtl/strbuf.hxx>
56 #include <connectivity/sqlparse.hxx>
57 #include <connectivity/sqlscan.hxx>
59 #if defined _MSC_VER
60 /**/
61 #ifdef yywrap
62 #undef  yywrap
63 #define yywrap() 1
64 #endif
65 /**/
66 #endif
67 #define YY_NO_UNISTD_H
69 using namespace connectivity;
71 // Creation of the pages for the tokens
72 // Pages generally are created from the Lexer
74 static sal_Int32    gatherString(int delim, sal_Int32 nTyp);
75 static sal_Int32    gatherName(const char*);
76 static sal_Int32    gatherNamePre(const char* );
77 // has to be set before the parser starts
78 OSQLScanner* xxx_pGLOBAL_SQLSCAN = nullptr;
80 #define SQL_NEW_NODE(text, token)   \
81         SQLyylval.pParseNode = new OSQLInternalNode(text, token);
83 #define SQL_NEW_KEYWORD(token)                      \
84         SQLyylval.pParseNode = new OSQLInternalNode("", SQLNodeType::Keyword, (token));       return token;
86 #define SQL_NEW_INTNUM      SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::IntNum); return SQL_TOKEN_INTNUM;
87 #define SQL_NEW_APPROXNUM   SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::ApproxNum); return SQL_TOKEN_APPROXNUM;
88 #define SQL_NEW_DATE        SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::AccessDate); return SQL_TOKEN_ACCESS_DATE;
90 #define YY_INPUT(buf,result,max_size)               \
91 {                                                   \
92     int c = xxx_pGLOBAL_SQLSCAN->SQLyygetc();       \
93     result = (c == EOF) ? YY_NULL : (buf[0] = c, 1);\
96 // coverity[+kill]
97 static void do_fatal_error(const char* msg)
99     xxx_pGLOBAL_SQLSCAN->SQLyyerror(msg);
100     /*hack to silence -Wunused-function*/
101     if ((0)) yy_fatal_error(msg);
104 #define YY_FATAL_ERROR(msg) \
105 {                           \
106     do_fatal_error(msg);    \
111 %s SQL
112 %s PREDICATE_ENG
113 %s PREDICATE_GER
114 %s DATE
115 %s STRING
117 %option noyywrap
118 %option never-interactive
121 ABS                 {SQL_NEW_KEYWORD(SQL_TOKEN_ABS);  }
122 ACOS                {SQL_NEW_KEYWORD(SQL_TOKEN_ACOS);  }
123 AFTER               {SQL_NEW_KEYWORD(SQL_TOKEN_AFTER);  }
124 ALL                 {SQL_NEW_KEYWORD(SQL_TOKEN_ALL);  }
125 ALTER               {SQL_NEW_KEYWORD(SQL_TOKEN_ALTER);  }
126 AND                 {SQL_NEW_KEYWORD(SQL_TOKEN_AND);  }
127 ANY                 {SQL_NEW_KEYWORD(SQL_TOKEN_ANY);  }
128 ARRAY_AGG           {SQL_NEW_KEYWORD(SQL_TOKEN_ARRAY_AGG);  }
129 AS                  {SQL_NEW_KEYWORD(SQL_TOKEN_AS);  }
130 ASC                 {SQL_NEW_KEYWORD(SQL_TOKEN_ASC);  }
131 ASCII               {SQL_NEW_KEYWORD(SQL_TOKEN_ASCII);  }
132 ASIN                {SQL_NEW_KEYWORD(SQL_TOKEN_ASIN);  }
133 AT                  {SQL_NEW_KEYWORD(SQL_TOKEN_AT);  }
134 ATAN                {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN);  }
135 ATAN2               {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN2);  }
136 ATOMIC              {SQL_NEW_KEYWORD(SQL_TOKEN_ATOMIC);  }
137 AUTHORIZATION       {SQL_NEW_KEYWORD(SQL_TOKEN_AUTHORIZATION);  }
138 AVG                 {SQL_NEW_KEYWORD(SQL_TOKEN_AVG);  }
140 BEFORE              {SQL_NEW_KEYWORD(SQL_TOKEN_BEFORE);  }
141 BEGIN               {SQL_NEW_KEYWORD(SQL_TOKEN_BEGIN);  }
142 BETWEEN             {SQL_NEW_KEYWORD(SQL_TOKEN_BETWEEN);  }
143 BIGINT              {SQL_NEW_KEYWORD(SQL_TOKEN_BIGINT);  }
144 BINARY              {SQL_NEW_KEYWORD(SQL_TOKEN_BINARY);  }
145 BIT                 {SQL_NEW_KEYWORD(SQL_TOKEN_BIT);  }
146 BIT_LENGTH          {SQL_NEW_KEYWORD(SQL_TOKEN_BIT_LENGTH);  }
147 BLOB                {SQL_NEW_KEYWORD(SQL_TOKEN_BLOB);  }
148 BOTH                {SQL_NEW_KEYWORD(SQL_TOKEN_BOTH);  }
149 BY                  {SQL_NEW_KEYWORD(SQL_TOKEN_BY);  }
151 CALL                {SQL_NEW_KEYWORD(SQL_TOKEN_CALL);  }
152 CASE                {SQL_NEW_KEYWORD(SQL_TOKEN_CASE);  }
153 CAST                {SQL_NEW_KEYWORD(SQL_TOKEN_CAST);  }
154 CEILING             {SQL_NEW_KEYWORD(SQL_TOKEN_CEILING);  }
155 CHAR                {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR);  }
156 CHARACTER           {SQL_NEW_KEYWORD(SQL_TOKEN_CHARACTER);  }
157 CHAR(ACTER)?_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR_LENGTH);  }
158 CHECK               {SQL_NEW_KEYWORD(SQL_TOKEN_CHECK);  }
159 CLOB                {SQL_NEW_KEYWORD(SQL_TOKEN_CLOB);  }
160 COALESCE            {SQL_NEW_KEYWORD(SQL_TOKEN_COALESCE);  }
161 COLLATE             {SQL_NEW_KEYWORD(SQL_TOKEN_COLLATE);  }
162 COLLECT             {SQL_NEW_KEYWORD(SQL_TOKEN_COLLECT);  }
163 COMMIT              {SQL_NEW_KEYWORD(SQL_TOKEN_COMMIT);  }
164 CONCAT              {SQL_NEW_KEYWORD(SQL_TOKEN_CONCAT);  }
165 CONTINUE            {SQL_NEW_KEYWORD(SQL_TOKEN_CONTINUE);  }
166 CONVERT             {SQL_NEW_KEYWORD(SQL_TOKEN_CONVERT);  }
167 COS                 {SQL_NEW_KEYWORD(SQL_TOKEN_COS);  }
168 COT                 {SQL_NEW_KEYWORD(SQL_TOKEN_COT);  }
169 COUNT               {SQL_NEW_KEYWORD(SQL_TOKEN_COUNT);  }
170 CREATE              {SQL_NEW_KEYWORD(SQL_TOKEN_CREATE);  }
171 CROSS               {SQL_NEW_KEYWORD(SQL_TOKEN_CROSS);  }
172 CUME_RANK           {SQL_NEW_KEYWORD(SQL_TOKEN_CUME_DIST);  }
173 CURRENT             {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT);  }
174 CURRENT_DATE        {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DATE);  }
175 CURRENT_CATALOG                 {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_CATALOG);  }
176 CURRENT_DEFAULT_TRANSFORM_GROUP {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP);  }
177 CURRENT_PATH                    {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_PATH);  }
178 CURRENT_ROLE                    {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_ROLE);  }
179 CURRENT_SCHEMA                  {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_SCHEMA);  }
180 CURRENT_USER                    {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_USER);  }
181 CURDATE             {SQL_NEW_KEYWORD(SQL_TOKEN_CURDATE);  }
182 CURRENT_TIME        {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIME);  }
183 CURTIME             {SQL_NEW_KEYWORD(SQL_TOKEN_CURTIME);  }
184 CURRENT_TIMESTAMP   {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIMESTAMP);  }
185 CURSOR              {SQL_NEW_KEYWORD(SQL_TOKEN_CURSOR);  }
187 D                   {SQL_NEW_KEYWORD(SQL_TOKEN_D);  }
188 DATE                {SQL_NEW_KEYWORD(SQL_TOKEN_DATE);  }
189 DATEADD             {SQL_NEW_KEYWORD(SQL_TOKEN_DATEADD);  }
190 DATEDIFF            {SQL_NEW_KEYWORD(SQL_TOKEN_DATEDIFF);  }
191 DATEVALUE           {SQL_NEW_KEYWORD(SQL_TOKEN_DATEVALUE);  }
192 DAY                 {SQL_NEW_KEYWORD(SQL_TOKEN_DAY);  }
193 DAYNAME             {SQL_NEW_KEYWORD(SQL_TOKEN_DAYNAME);  }
194 DAYOFMONTH          {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFMONTH);  }
195 DAYOFWEEK           {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFWEEK);  }
196 DAYOFYEAR           {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFYEAR);  }
197 DEC                 {SQL_NEW_KEYWORD(SQL_TOKEN_DEC);  }
198 DECIMAL             {SQL_NEW_KEYWORD(SQL_TOKEN_DECIMAL);  }
199 DECLARE             {SQL_NEW_KEYWORD(SQL_TOKEN_DECLARE);  }
200 DEFAULT             {SQL_NEW_KEYWORD(SQL_TOKEN_DEFAULT);  }
201 DEGREES             {SQL_NEW_KEYWORD(SQL_TOKEN_DEGREES);  }
202 DELETE              {SQL_NEW_KEYWORD(SQL_TOKEN_DELETE);  }
203 DENSE_RANK          {SQL_NEW_KEYWORD(SQL_TOKEN_DENSE_RANK);  }
204 DESC                {SQL_NEW_KEYWORD(SQL_TOKEN_DESC);  }
205 DIFFERENCE          {SQL_NEW_KEYWORD(SQL_TOKEN_DIFFERENCE);  }
206 DISTINCT            {SQL_NEW_KEYWORD(SQL_TOKEN_DISTINCT);  }
207 DOUBLE              {SQL_NEW_KEYWORD(SQL_TOKEN_DOUBLE);  }
208 DROP                {SQL_NEW_KEYWORD(SQL_TOKEN_DROP);  }
210 EACH                {SQL_NEW_KEYWORD(SQL_TOKEN_EACH);  }
211 ELSE                {SQL_NEW_KEYWORD(SQL_TOKEN_ELSE);  }
212 END                 {SQL_NEW_KEYWORD(SQL_TOKEN_END);  }
213 EVERY               {SQL_NEW_KEYWORD(SQL_TOKEN_EVERY);  }
214 ESCAPE              {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE);  }
215 EXCEPT              {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT);  }
216 EXCLUDE             {SQL_NEW_KEYWORD(SQL_TOKEN_EXCLUDE);  }
217 EXISTS              {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS);  }
218 EXP                 {SQL_NEW_KEYWORD(SQL_TOKEN_EXP);  }
219 EXTRACT             {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT);  }
221 FALSE               {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE);  }
222 FETCH               {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH);  }
223 FIRST               {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST);  }
224 FIRST_VALUE         {SQL_NEW_KEYWORD(SQL_TOKEN_FIRST_VALUE);  }
225 FLOAT               {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT);  }
226 FLOOR               {SQL_NEW_KEYWORD(SQL_TOKEN_FLOOR);  }
227 FN                  {SQL_NEW_KEYWORD(SQL_TOKEN_FN);  }
228 FOLLOWING           {SQL_NEW_KEYWORD(SQL_TOKEN_FOLLOWING);  }
229 FOR                 {SQL_NEW_KEYWORD(SQL_TOKEN_FOR);  }
230 FOREIGN             {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN);  }
231 FOUND               {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND);  }
232 FROM                {SQL_NEW_KEYWORD(SQL_TOKEN_FROM);  }
233 FULL                {SQL_NEW_KEYWORD(SQL_TOKEN_FULL);  }
234 FUSION              {SQL_NEW_KEYWORD(SQL_TOKEN_FUSION);  }
236 GRANT               {SQL_NEW_KEYWORD(SQL_TOKEN_GRANT);  }
237 GROUP               {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP);  }
239 HAVING              {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING);  }
240 HOUR                {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR);  }
242 IGNORE              {SQL_NEW_KEYWORD(SQL_TOKEN_IGNORE);  }
243 IN                  {SQL_NEW_KEYWORD(SQL_TOKEN_IN);  }
244 INNER               {SQL_NEW_KEYWORD(SQL_TOKEN_INNER);  }
245 INSERT              {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT);  }
246 INSTEAD             {SQL_NEW_KEYWORD(SQL_TOKEN_INSTEAD);  }
247 INT(EGER)?          {SQL_NEW_KEYWORD(SQL_TOKEN_INTEGER);  }
248 INTERSECT           {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECT);  }
249 INTERVAL            {SQL_NEW_KEYWORD(SQL_TOKEN_INTERVAL);  }
250 INTERSECTION        {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECTION);  }
251 INTO                {SQL_NEW_KEYWORD(SQL_TOKEN_INTO);  }
252 IS                  {SQL_NEW_KEYWORD(SQL_TOKEN_IS);  }
254 JOIN                {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN);  }
256 KEY                 {SQL_NEW_KEYWORD(SQL_TOKEN_KEY);  }
258 LAG                 {SQL_NEW_KEYWORD(SQL_TOKEN_LAG);  }
259 LARGE               {SQL_NEW_KEYWORD(SQL_TOKEN_LARGE);  }
260 LAST                {SQL_NEW_KEYWORD(SQL_TOKEN_LAST);  }
261 LAST_VALUE          {SQL_NEW_KEYWORD(SQL_TOKEN_LAST_VALUE);  }
262 LCASE               {SQL_NEW_KEYWORD(SQL_TOKEN_LCASE);  }
263 LEAD                {SQL_NEW_KEYWORD(SQL_TOKEN_LEAD);  }
264 LEADING             {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING);  }
265 LEFT                {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT);  }
266 LENGTH              {SQL_NEW_KEYWORD(SQL_TOKEN_LENGTH);  }
267 LIKE                {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE);  }
268 LIMIT               {SQL_NEW_KEYWORD(SQL_TOKEN_LIMIT);  }
269 LN                  {SQL_NEW_KEYWORD(SQL_TOKEN_LN);  }
270 LOCAL               {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL);  }
271 LOCATE              {SQL_NEW_KEYWORD(SQL_TOKEN_LOCATE);  }
272 LOG                 {SQL_NEW_KEYWORD(SQL_TOKEN_LOG);  }
273 LOGF                {SQL_NEW_KEYWORD(SQL_TOKEN_LOGF);  }
274 LOG10               {SQL_NEW_KEYWORD(SQL_TOKEN_LOG10);  }
275 LOWER               {SQL_NEW_KEYWORD(SQL_TOKEN_LOWER);  }
276 LTRIM               {SQL_NEW_KEYWORD(SQL_TOKEN_LTRIM);  }
278 MAX                 {SQL_NEW_KEYWORD(SQL_TOKEN_MAX);  }
279 MILLISECOND         {SQL_NEW_KEYWORD(SQL_TOKEN_MILLISECOND);  }
280 MIN                 {SQL_NEW_KEYWORD(SQL_TOKEN_MIN);  }
281 MINUTE              {SQL_NEW_KEYWORD(SQL_TOKEN_MINUTE);  }
282 MOD                 {SQL_NEW_KEYWORD(SQL_TOKEN_MOD);  }
283 MONTH               {SQL_NEW_KEYWORD(SQL_TOKEN_MONTH);  }
284 MONTHNAME           {SQL_NEW_KEYWORD(SQL_TOKEN_MONTHNAME);  }
286 NATIONAL            {SQL_NEW_KEYWORD(SQL_TOKEN_NATIONAL);  }
287 NATURAL             {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL);  }
288 NCHAR               {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR);  }
289 NCLOB               {SQL_NEW_KEYWORD(SQL_TOKEN_NCLOB);  }
290 NEW                 {SQL_NEW_KEYWORD(SQL_TOKEN_NEW);  }
291 NEXT                {SQL_NEW_KEYWORD(SQL_TOKEN_NEXT);  }
292 NO                  {SQL_NEW_KEYWORD(SQL_TOKEN_NO);  }
293 NOT                 {SQL_NEW_KEYWORD(SQL_TOKEN_NOT);  }
294 NOW                 {SQL_NEW_KEYWORD(SQL_TOKEN_NOW);  }
295 NTH_VALUE           {SQL_NEW_KEYWORD(SQL_TOKEN_NTH_VALUE);  }
296 NTILE               {SQL_NEW_KEYWORD(SQL_TOKEN_NTILE);  }
297 NULL                {SQL_NEW_KEYWORD(SQL_TOKEN_NULL);  }
298 NULLIF              {SQL_NEW_KEYWORD(SQL_TOKEN_NULLIF);  }
299 NULLS               {SQL_NEW_KEYWORD(SQL_TOKEN_NULLS);  }
300 NUMERIC             {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC);  }
302 OBJECT              {SQL_NEW_KEYWORD(SQL_TOKEN_OBJECT);  }
303 OCTET_LENGTH        {SQL_NEW_KEYWORD(SQL_TOKEN_OCTET_LENGTH);  }
304 OF                  {SQL_NEW_KEYWORD(SQL_TOKEN_OF);  }
305 OFFSET              {SQL_NEW_KEYWORD(SQL_TOKEN_OFFSET);  }
306 OJ                  {SQL_NEW_KEYWORD(SQL_TOKEN_OJ);  }
307 OLD                 {SQL_NEW_KEYWORD(SQL_TOKEN_OLD);  }
308 ON                  {SQL_NEW_KEYWORD(SQL_TOKEN_ON);  }
309 ONLY                {SQL_NEW_KEYWORD(SQL_TOKEN_ONLY);  }
310 OPTION              {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION);  }
311 OR                  {SQL_NEW_KEYWORD(SQL_TOKEN_OR);  }
312 ORDER               {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER);  }
313 OTHERS              {SQL_NEW_KEYWORD(SQL_TOKEN_OTHERS);  }
314 OUTER               {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER);  }
315 OVER                {SQL_NEW_KEYWORD(SQL_TOKEN_OVER);  }
317 PARTITION           {SQL_NEW_KEYWORD(SQL_TOKEN_PARTITION);  }
318 PERCENT_RANK        {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENT_RANK);  }
319 PERCENTILE_CONT     {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_CONT);  }
320 PERCENTILE_DISC     {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_DISC);  }
321 PI                  {SQL_NEW_KEYWORD(SQL_TOKEN_PI);  }
322 POSITION            {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION);  }
323 POWER               {SQL_NEW_KEYWORD(SQL_TOKEN_POWER);  }
324 PRECEDING           {SQL_NEW_KEYWORD(SQL_TOKEN_PRECEDING);  }
325 PRECISION           {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION);  }
326 PRIMARY             {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY);  }
327 PRIVILEGES          {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES);  }
328 PROCEDURE           {SQL_NEW_KEYWORD(SQL_TOKEN_PROCEDURE);  }
329 PUBLIC              {SQL_NEW_KEYWORD(SQL_TOKEN_PUBLIC);  }
331 QUARTER             {SQL_NEW_KEYWORD(SQL_TOKEN_QUARTER);  }
333 RADIANS             {SQL_NEW_KEYWORD(SQL_TOKEN_RADIANS);  }
334 RAND                {SQL_NEW_KEYWORD(SQL_TOKEN_RAND);  }
335 RANGE               {SQL_NEW_KEYWORD(SQL_TOKEN_RANGE);  }
336 RANK                {SQL_NEW_KEYWORD(SQL_TOKEN_RANK);  }
337 REAL                {SQL_NEW_KEYWORD(SQL_TOKEN_REAL);  }
338 REFERENCES          {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES);  }
339 REFERENCING         {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCING);  }
340 REPEAT              {SQL_NEW_KEYWORD(SQL_TOKEN_REPEAT);  }
341 REPLACE             {SQL_NEW_KEYWORD(SQL_TOKEN_REPLACE);  }
342 RESPECT             {SQL_NEW_KEYWORD(SQL_TOKEN_RESPECT);  }
343 ROLLBACK            {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK);  }
344 ROUND               {SQL_NEW_KEYWORD(SQL_TOKEN_ROUND);  }
345 ROUNDMAGIC          {SQL_NEW_KEYWORD(SQL_TOKEN_ROUNDMAGIC);  }
346 ROW                 {SQL_NEW_KEYWORD(SQL_TOKEN_ROW);  }
347 ROWS                {SQL_NEW_KEYWORD(SQL_TOKEN_ROWS);  }
348 ROW_NUMBER          {SQL_NEW_KEYWORD(SQL_TOKEN_ROW_NUMBER);  }
349 RIGHT               {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT);  }
350 RTRIM               {SQL_NEW_KEYWORD(SQL_TOKEN_RTRIM);  }
352 SCHEMA              {SQL_NEW_KEYWORD(SQL_TOKEN_SCHEMA);  }
353 SECOND              {SQL_NEW_KEYWORD(SQL_TOKEN_SECOND);  }
354 SELECT              {SQL_NEW_KEYWORD(SQL_TOKEN_SELECT);  }
355 SET                 {SQL_NEW_KEYWORD(SQL_TOKEN_SET);  }
356 SIZE                {SQL_NEW_KEYWORD(SQL_TOKEN_SIZE);  }
357 SIGN                {SQL_NEW_KEYWORD(SQL_TOKEN_SIGN);  }
358 SIN                 {SQL_NEW_KEYWORD(SQL_TOKEN_SIN);  }
359 SMALLINT            {SQL_NEW_KEYWORD(SQL_TOKEN_SMALLINT);  }
360 SOME                {SQL_NEW_KEYWORD(SQL_TOKEN_SOME);  }
361 SOUNDEX             {SQL_NEW_KEYWORD(SQL_TOKEN_SOUNDEX);  }
362 SPACE               {SQL_NEW_KEYWORD(SQL_TOKEN_SPACE);  }
363 SQRT                {SQL_NEW_KEYWORD(SQL_TOKEN_SQRT);  }
364 STDDEV_POP          {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_POP);  }
365 STDDEV_SAMP         {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_SAMP); }
366 STATEMENT           {SQL_NEW_KEYWORD(SQL_TOKEN_STATEMENT);  }
367 SUBSTRING           {SQL_NEW_KEYWORD(SQL_TOKEN_SUBSTRING);  }
368 SUM                 {SQL_NEW_KEYWORD(SQL_TOKEN_SUM);  }
369 SESSION_USER        {SQL_NEW_KEYWORD(SQL_TOKEN_SESSION_USER);  }
370 SYSTEM_USER         {SQL_NEW_KEYWORD(SQL_TOKEN_SYSTEM_USER);  }
372 TABLE               {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE);  }
373 TAN                 {SQL_NEW_KEYWORD(SQL_TOKEN_TAN);  }
374 THEN                {SQL_NEW_KEYWORD(SQL_TOKEN_THEN);  }
375 TIES                {SQL_NEW_KEYWORD(SQL_TOKEN_TIES);  }
376 TIME                {SQL_NEW_KEYWORD(SQL_TOKEN_TIME);  }
377 TIMESTAMP           {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP);  }
378 TIMESTAMPADD        {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPADD);  }
379 TIMESTAMPDIFF       {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPDIFF);  }
380 TIMEVALUE           {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEVALUE);  }
381 TIMEZONE_HOUR       {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_HOUR);  }
382 TIMEZONE_MINUTE     {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_MINUTE);  }
383 TO                  {SQL_NEW_KEYWORD(SQL_TOKEN_TO);  }
384 TRAILING            {SQL_NEW_KEYWORD(SQL_TOKEN_TRAILING);  }
385 TRANSLATE           {SQL_NEW_KEYWORD(SQL_TOKEN_TRANSLATE);  }
386 TRIGGER             {SQL_NEW_KEYWORD(SQL_TOKEN_TRIGGER);  }
387 TRIM                {SQL_NEW_KEYWORD(SQL_TOKEN_TRIM);  }
388 TRUE                {SQL_NEW_KEYWORD(SQL_TOKEN_TRUE);  }
389 TRUNCATE            {SQL_NEW_KEYWORD(SQL_TOKEN_TRUNCATE);  }
390 TS                  {SQL_NEW_KEYWORD(SQL_TOKEN_TS);  }
391 T                   {SQL_NEW_KEYWORD(SQL_TOKEN_T);  }
393 UCASE               {SQL_NEW_KEYWORD(SQL_TOKEN_UCASE);  }
394 UNBOUNDED           {SQL_NEW_KEYWORD(SQL_TOKEN_UNBOUNDED);  }
395 UNION               {SQL_NEW_KEYWORD(SQL_TOKEN_UNION);  }
396 UNIQUE              {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE);  }
397 UNKNOWN             {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN);  }
398 UPDATE              {SQL_NEW_KEYWORD(SQL_TOKEN_UPDATE);  }
399 UPPER               {SQL_NEW_KEYWORD(SQL_TOKEN_UPPER);  }
400 USAGE               {SQL_NEW_KEYWORD(SQL_TOKEN_USAGE);  }
401 USER                {SQL_NEW_KEYWORD(SQL_TOKEN_USER);  }
402 USING               {SQL_NEW_KEYWORD(SQL_TOKEN_USING);  }
404 VARBINARY           {SQL_NEW_KEYWORD(SQL_TOKEN_VARBINARY);  }
405 VARCHAR             {SQL_NEW_KEYWORD(SQL_TOKEN_VARCHAR);  }
406 VARYING             {SQL_NEW_KEYWORD(SQL_TOKEN_VARYING);  }
407 VAR_POP             {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_POP);  }
408 VAR_SAMP            {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_SAMP);  }
409 VALUE               {SQL_NEW_KEYWORD(SQL_TOKEN_VALUE);  }
410 VALUES              {SQL_NEW_KEYWORD(SQL_TOKEN_VALUES);  }
411 VIEW                {SQL_NEW_KEYWORD(SQL_TOKEN_VIEW);  }
413 WEEK                {SQL_NEW_KEYWORD(SQL_TOKEN_WEEK);  }
414 WEEKDAY             {SQL_NEW_KEYWORD(SQL_TOKEN_WEEKDAY);  }
415 WHEN                {SQL_NEW_KEYWORD(SQL_TOKEN_WHEN);  }
416 WHERE               {SQL_NEW_KEYWORD(SQL_TOKEN_WHERE);  }
417 WITH                {SQL_NEW_KEYWORD(SQL_TOKEN_WITH);  }
418 WITHIN              {SQL_NEW_KEYWORD(SQL_TOKEN_WITHIN);  }
419 WITHOUT             {SQL_NEW_KEYWORD(SQL_TOKEN_WITHOUT);  }
420 WORK                {SQL_NEW_KEYWORD(SQL_TOKEN_WORK);  }
422 YEAR                {SQL_NEW_KEYWORD(SQL_TOKEN_YEAR);  }
423 YEARDAY             {SQL_NEW_KEYWORD(SQL_TOKEN_YEARDAY);  }
425 ZONE                {SQL_NEW_KEYWORD(SQL_TOKEN_ZONE);  }
427 "<"                 { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::Less);return SQL_LESS;}
428 ">"                 { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::Great);return SQL_GREAT;}
429 "="                 { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::Equal);return SQL_EQUAL;}
430 "<="                { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::LessEq);return SQL_LESSEQ;}
431 ">="                { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::GreatEq);return SQL_GREATEQ;}
432 "<>"                { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::NotEqual);return SQL_NOTEQUAL;}
433 "!="                { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::NotEqual);return SQL_NOTEQUAL;}
434 "||"                { SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::Concat);return SQL_CONCAT;}
437 [-+*/:(),.;?{}]    { return SQLyytext[0]; }
440 <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);}
442 <SQL>([0-9]+)                   {SQL_NEW_INTNUM; }
444 <SQL>("."[0-9]*) |
445 <SQL>([0-9]+"."[0-9]*) |
446 <SQL>[0-9]+[eE][+-]?[0-9]+   |
447 <SQL>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
448 <SQL>"."[0-9]*[eE][+-]?[0-9]+       {SQL_NEW_APPROXNUM;  }
450 <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);}
452 <PREDICATE_GER,PREDICATE_ENG>([0-9]+)       {SQL_NEW_INTNUM; }
453 <PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+)   {SQL_NEW_INTNUM; }
454 <PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+)   {SQL_NEW_INTNUM; }
456 <PREDICATE_ENG>([0-9]+"."[0-9]+) |
457 <PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+"."[0-9]+) |
458 <PREDICATE_ENG>("."[0-9]+)                  {SQL_NEW_APPROXNUM;  }
459 <PREDICATE_ENG>[0-9]+[eE][+-]?[0-9]+   |
460 <PREDICATE_ENG>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
461 <PREDICATE_ENG>"."[0-9]*[eE][+-]?[0-9]+     {SQL_NEW_APPROXNUM;  }
463 <PREDICATE_GER>([0-9]+","[0-9]+) |
464 <PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+","[0-9]+) |
465 <PREDICATE_GER>(","[0-9]+)                  {SQL_NEW_APPROXNUM;  }
466 <PREDICATE_GER>[0-9]+[eE][+-]?[0-9]+   |
467 <PREDICATE_GER>[0-9]+","[0-9]*[eE][+-]?[0-9]+ |
468 <PREDICATE_GER>","[0-9]*[eE][+-]?[0-9]+     {SQL_NEW_APPROXNUM;  }
470 <PREDICATE_GER,PREDICATE_ENG>[0-9.,][A-Za-z0-9_.,%]* {return gatherNamePre(SQLyytext);}
472 <SQL>\" { return gatherString('\"',0); }
473 <SQL>`  { return gatherString('`' ,0); }
475 <PREDICATE_GER,PREDICATE_ENG,DATE,SQL>"["       { return gatherString(']' ,0);}
477 \'      { return gatherString('\'',1); }
479 <PREDICATE_GER,PREDICATE_ENG,DATE># { return gatherString('#' ,2); }
481 <DATE>[0-9]{1,4}[^ ]*[0-9] |
482 <DATE>[0-9]{1,4}[^ ]*[0-9][ ][0-9]{1,4}[^ ]*[0-9]       { SQL_NEW_DATE; }
484 <STRING>["-""+""*""/"":""("")"",""."";""?""{""}"]       { return SQLyytext[0]; } /*  */
485 <STRING>"["                 { return gatherString(']' ,0); }
486 <STRING>[^ ':["?"]*         { return gatherNamePre(SQLyytext); }
488 \n              {}
490 [ \t\r]+        {}
492 "--".*$         {}
494 .               {YY_FATAL_ERROR("Invalid symbol"); return SQL_TOKEN_INVALIDSYMBOL;}
498 // Kludge around a bug (well, Posix incompatibility) in flex 2.5.x
499 // http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=189332
500 #if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5
502   #ifndef YY_FLUSH_BUFFER
503     #define YY_FLUSH_BUFFER SQLyy_flush_buffer(YY_CURRENT_BUFFER )
504   #endif
506   #ifndef yytext_ptr
507     #define yytext_ptr SQLyytext
508   #endif
510 #endif
512 // Versions of flex apparently differ in whether input() resp. yyinput() returns
513 // zero or EOF upon end of file:
514 inline bool checkeof(int c) { return c == 0 || c == EOF; }
517  * Read SQL string literal
518  * Valid strings:
519  *  ''  'a string'  'quote '' within string'
520  *  ""  "a string"  "quote "" within string"
521  * nTyp == 0 -> SQLNodeType::Name
522  * nTyp == 1 -> SQLNodeType::String
523  * nTyp == 2 -> SQLNodeType::AccessDate
524  */
525 sal_Int32 gatherString(int delim, sal_Int32 nTyp)
527     int ch;
528     OStringBuffer sBuffer(256);
530     assert(nTyp == 0 || nTyp == 1 || nTyp == 2);
532     while (!checkeof(ch = yyinput()))
533     {
534         if (ch == delim)
535         {
536             if ((ch = yyinput()) != delim)
537             {
538                 if (!checkeof(ch))
539                     unput(ch);
541                 switch(nTyp)
542                 {
543                 case 0:
544                     SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::Name);
545                     return SQL_TOKEN_NAME;
546                 case 1:
547                     SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::String);
548                     return SQL_TOKEN_STRING;
549                 case 2:
550                     SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::AccessDate);
551                     return SQL_TOKEN_ACCESS_DATE;
552                 }
553             }
554             else
555             {
556                 sBuffer.append(static_cast<char>(ch));
557             }
559         }
560         else if (nTyp == 2 && (ch == '\r' || ch == '\n') )
561             break;
562         else
563         {
564             sBuffer.append(static_cast<char>(ch));
565         }
566     }
567     YY_FATAL_ERROR("Unterminated name string");
568     return SQL_TOKEN_INVALIDSYMBOL;
571 sal_Int32 mapEnumToToken(IParseContext::InternationalKeyCode _eKeyCode )
573     sal_Int32 nTokenID = 0;
574     switch( _eKeyCode )
575     {
576         case IParseContext::InternationalKeyCode::Like:       nTokenID = SQL_TOKEN_LIKE;      break;
577         case IParseContext::InternationalKeyCode::Not:        nTokenID = SQL_TOKEN_NOT;       break;
578         case IParseContext::InternationalKeyCode::Null:       nTokenID = SQL_TOKEN_NULL;      break;
579         case IParseContext::InternationalKeyCode::True:       nTokenID = SQL_TOKEN_TRUE;      break;
580         case IParseContext::InternationalKeyCode::False:      nTokenID = SQL_TOKEN_FALSE;     break;
581         case IParseContext::InternationalKeyCode::Is:         nTokenID = SQL_TOKEN_IS;        break;
582         case IParseContext::InternationalKeyCode::Between:    nTokenID = SQL_TOKEN_BETWEEN;   break;
583         case IParseContext::InternationalKeyCode::Or:         nTokenID = SQL_TOKEN_OR;        break;
584         case IParseContext::InternationalKeyCode::And:        nTokenID = SQL_TOKEN_AND;       break;
585         case IParseContext::InternationalKeyCode::Avg:        nTokenID = SQL_TOKEN_AVG;       break;
586         case IParseContext::InternationalKeyCode::Count:      nTokenID = SQL_TOKEN_COUNT;     break;
587         case IParseContext::InternationalKeyCode::Max:        nTokenID = SQL_TOKEN_MAX;       break;
588         case IParseContext::InternationalKeyCode::Min:        nTokenID = SQL_TOKEN_MIN;       break;
589         case IParseContext::InternationalKeyCode::Sum:        nTokenID = SQL_TOKEN_SUM;       break;
590         case IParseContext::InternationalKeyCode::Every:      nTokenID = SQL_TOKEN_EVERY;     break;
591         case IParseContext::InternationalKeyCode::Any:        nTokenID = SQL_TOKEN_ANY;       break;
592         case IParseContext::InternationalKeyCode::Some:       nTokenID = SQL_TOKEN_SOME;      break;
593         case IParseContext::InternationalKeyCode::StdDevPop: nTokenID = SQL_TOKEN_STDDEV_POP; break;
594         case IParseContext::InternationalKeyCode::StdDevSamp: nTokenID = SQL_TOKEN_STDDEV_SAMP; break;
595         case IParseContext::InternationalKeyCode::VarSamp:   nTokenID = SQL_TOKEN_VAR_SAMP;  break;
596         case IParseContext::InternationalKeyCode::VarPop:    nTokenID = SQL_TOKEN_VAR_POP;   break;
597         case IParseContext::InternationalKeyCode::Collect:    nTokenID = SQL_TOKEN_COLLECT;   break;
598         case IParseContext::InternationalKeyCode::Fusion:     nTokenID = SQL_TOKEN_FUSION;    break;
599         case IParseContext::InternationalKeyCode::Intersection: nTokenID = SQL_TOKEN_INTERSECTION; break;
600         default:
601             OSL_FAIL( "mapEnumToToken: unsupported key!" );
602     }
603     return nTokenID;
606  * Read SQL Name literal
607  * Valid Names or international keywords:
608  *  As we have international keywords, we test first on them
609  */
610 sal_Int32 gatherName(const char* text)
612     sal_Int32 nToken;
613     OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
614     IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
615     switch (eKeyCode)
616     {
617         case IParseContext::InternationalKeyCode::Like:
618         case IParseContext::InternationalKeyCode::Not:
619         case IParseContext::InternationalKeyCode::Null:
620         case IParseContext::InternationalKeyCode::True:
621         case IParseContext::InternationalKeyCode::False:
622         case IParseContext::InternationalKeyCode::Is:
623         case IParseContext::InternationalKeyCode::Between:
624         case IParseContext::InternationalKeyCode::Or:
625         case IParseContext::InternationalKeyCode::And:
626         case IParseContext::InternationalKeyCode::Count:
627         case IParseContext::InternationalKeyCode::Avg:
628         case IParseContext::InternationalKeyCode::Max:
629         case IParseContext::InternationalKeyCode::Min:
630         case IParseContext::InternationalKeyCode::Sum:
631         case IParseContext::InternationalKeyCode::Every:
632         case IParseContext::InternationalKeyCode::Any:
633         case IParseContext::InternationalKeyCode::Some:
634         case IParseContext::InternationalKeyCode::StdDevPop:
635         case IParseContext::InternationalKeyCode::StdDevSamp:
636         case IParseContext::InternationalKeyCode::VarSamp:
637         case IParseContext::InternationalKeyCode::VarPop:
638         case IParseContext::InternationalKeyCode::Collect:
639         case IParseContext::InternationalKeyCode::Fusion:
640         case IParseContext::InternationalKeyCode::Intersection:
641             nToken = mapEnumToToken(eKeyCode);
642             SQL_NEW_KEYWORD(nToken);
643             break;
644         default:
645             SQL_NEW_NODE(OUString(text,strlen(text),RTL_TEXTENCODING_UTF8), SQLNodeType::Name);
646             return SQL_TOKEN_NAME;
647     }
650  Read SQL Name literal for predicate check
651  Valid Names or international keywords:
652  As we have international keywords, we test first on them
654 sal_Int32 gatherNamePre(const char* text)
656     sal_Int32 nToken;
657     OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
658     IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
659     switch (eKeyCode)
660     {
661         case IParseContext::InternationalKeyCode::Like:
662         case IParseContext::InternationalKeyCode::Not:
663         case IParseContext::InternationalKeyCode::Null:
664         case IParseContext::InternationalKeyCode::True:
665         case IParseContext::InternationalKeyCode::False:
666         case IParseContext::InternationalKeyCode::Is:
667         case IParseContext::InternationalKeyCode::Between:
668         case IParseContext::InternationalKeyCode::Or:
669         case IParseContext::InternationalKeyCode::And:
670         case IParseContext::InternationalKeyCode::Count:
671         case IParseContext::InternationalKeyCode::Avg:
672         case IParseContext::InternationalKeyCode::Max:
673         case IParseContext::InternationalKeyCode::Min:
674         case IParseContext::InternationalKeyCode::Sum:
675         case IParseContext::InternationalKeyCode::Every:
676         case IParseContext::InternationalKeyCode::Any:
677         case IParseContext::InternationalKeyCode::Some:
678         case IParseContext::InternationalKeyCode::StdDevPop:
679         case IParseContext::InternationalKeyCode::StdDevSamp:
680         case IParseContext::InternationalKeyCode::VarSamp:
681         case IParseContext::InternationalKeyCode::VarPop:
682         case IParseContext::InternationalKeyCode::Collect:
683         case IParseContext::InternationalKeyCode::Fusion:
684         case IParseContext::InternationalKeyCode::Intersection:
685             nToken = mapEnumToToken(eKeyCode);
686             SQL_NEW_KEYWORD(nToken);
687             break;
688         default:
689         // we need a special handling for parameter
690         {
691             OString sStmt = xxx_pGLOBAL_SQLSCAN->getStatement();
692             sal_Int32 nLength = strlen(text);
693             sal_Int32 nPos = xxx_pGLOBAL_SQLSCAN->GetCurrentPos() - nLength - 2;
694             if (sStmt.getStr()[nPos] == ':')
695             {
696                 SQL_NEW_NODE(OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQLNodeType::Name);
697                 nToken = SQL_TOKEN_NAME;
698             }
699             else
700             {
701                 SQL_NEW_NODE(OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQLNodeType::String);
702                 nToken = SQL_TOKEN_STRING;
703             }
704         }
705     }
706     return nToken;
709 using namespace connectivity;
711 static bool IN_SQLyyerror;
712 //------------------------------------------------------------------------------
713 OSQLScanner::OSQLScanner()
714             : m_pContext(nullptr)
715             , m_nCurrentPos(0)
716             , m_bInternational(false)
717             , m_nRule(0) // 0 is INITIAL
719     IN_SQLyyerror = false;
722 //------------------------------------------------------------------------------
723 OSQLScanner::~OSQLScanner()
726 //------------------------------------------------------------------------------
727 void OSQLScanner::SQLyyerror(char const *fmt)
730     if(IN_SQLyyerror)
731         return;
732     IN_SQLyyerror = true;
734     OSL_ENSURE(m_pContext, "OSQLScanner::SQLyyerror: No Context set");
735     m_sErrorMessage = OUString(fmt,strlen(fmt),RTL_TEXTENCODING_UTF8);
736     if (m_nCurrentPos < m_sStatement.getLength())
737     {
738         m_sErrorMessage += ": ";
740         OUString aError;
741         OUStringBuffer Buffer(256);
743         int ch = SQLyytext ? (SQLyytext[0] == 0 ? ' ' : SQLyytext[0]): ' ';
744         Buffer.append((sal_Unicode)ch);
745         while (!checkeof(ch = yyinput()))
746         {
747             if (ch == ' ')
748             {
749                 if ((ch = yyinput()) != ' ')
750                 {
751                     if (!checkeof(ch))
752                         unput(ch);
753                 }
754                 aError = Buffer.makeStringAndClear();
755                 break;
756             }
757             else
758             {
759                 Buffer.append((sal_Unicode)ch);
760             }
761         }
762         m_sErrorMessage += aError;
763     }
764     IN_SQLyyerror = false;
765     YY_FLUSH_BUFFER;
768 //------------------------------------------------------------------------------
769 void OSQLScanner::prepareScan(const OUString & rNewStatement, const IParseContext* pContext, bool bInternational)
771     YY_FLUSH_BUFFER;
772     BEGIN(m_nRule);
774     m_sErrorMessage = OUString();
775     m_sStatement = OUStringToOString(rNewStatement, RTL_TEXTENCODING_UTF8);
776     m_nCurrentPos = 0;
777     m_bInternational = bInternational;
778     m_pContext = pContext;
781 //------------------------------------------------------------------------------
782 sal_Int32 OSQLScanner::SQLyygetc(void)
784     sal_Int32 nPos = (m_nCurrentPos >= m_sStatement.getLength()) ? EOF : m_sStatement.getStr()[m_nCurrentPos];
785     m_nCurrentPos++;
786     return nPos;
789 //------------------------------------------------------------------------------
790 IParseContext::InternationalKeyCode OSQLScanner::getInternationalTokenID(const char* sToken) const
792     OSL_ENSURE(m_pContext, "OSQLScanner::getInternationalTokenID: No Context set");
793     return (m_bInternational) ? m_pContext->getIntlKeyCode(OString(sToken) ) : IParseContext::InternationalKeyCode::None;
795 sal_Int32   OSQLScanner::GetGERRule()       { return PREDICATE_GER; }
796 sal_Int32   OSQLScanner::GetENGRule()       { return PREDICATE_ENG; }
797 sal_Int32   OSQLScanner::GetSQLRule()       { return SQL; }
798 sal_Int32   OSQLScanner::GetDATERule()  { return DATE; }
799 sal_Int32   OSQLScanner::GetSTRINGRule()    { return STRING; }
800 void OSQLScanner::setScanner(bool _bNull)
802     xxx_pGLOBAL_SQLSCAN = _bNull ? nullptr : this;
804 sal_Int32 OSQLScanner::SQLlex()
806     return SQLyylex();
809 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */