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