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