33#pragma warning ( push )
36#pragma warning ( disable : 4005 )
43#ifndef INCLUDED_CONNECTIVITY_SOURCE_PARSE_SQLFLEX_L
44#define INCLUDED_CONNECTIVITY_SOURCE_PARSE_SQLFLEX_L
50#include "sqlbison.hxx"
54#include <osl/diagnose.h>
55#include <rtl/strbuf.hxx>
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) \
92 int c = xxx_pGLOBAL_SQLSCAN->SQLyygetc(); \
93 result = (c == EOF) ? YY_NULL : (buf[0] = c, 1);\
101 if ((0)) yy_fatal_error(msg);
104#define YY_FATAL_ERROR(msg) \
106 do_fatal_error(msg); \
void SQLyyerror(char const *fmt)
static void do_fatal_error(const char *msg)
static sal_Int32 gatherString(int delim, sal_Int32 nTyp)
static sal_Int32 gatherName(const char *)
OSQLScanner * xxx_pGLOBAL_SQLSCAN
static sal_Int32 gatherNamePre(const char *)
Read SQL Name literal for predicate check Valid Names or international keywords: As we have internati...
118%option never-interactive
#define SQL_NEW_KEYWORD(token)
176CURRENT_DEFAULT_TRANSFORM_GROUP {
SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP); }
426"<" {
SQL_NEW_NODE(OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQLNodeType::Less);
return SQL_LESS;}
#define SQL_NEW_NODE(text, token)
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;}
436[-+*/:(),.;?{}] {
return SQLyytext[0]; }
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);}
444<SQL>([0-9]+"."[0-9]*) |
445<SQL>[0-9]+[eE][+-]?[0-9]+ |
446<SQL>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
#define SQL_NEW_APPROXNUM
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);}
455<PREDICATE_ENG>([0-9]+"."[0-9]+) |
456<PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+"."[0-9]+) |
458<PREDICATE_ENG>[0-9]+[eE][+-]?[0-9]+ |
459<PREDICATE_ENG>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
462<PREDICATE_GER>([0-9]+","[0-9]+) |
463<PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+","[0-9]+) |
465<PREDICATE_GER>[0-9]+[eE][+-]?[0-9]+ |
466<PREDICATE_GER>[0-9]+","[0-9]*[eE][+-]?[0-9]+ |
469<PREDICATE_GER,PREDICATE_ENG>[0-9.,][A-Za-z0-9_.,%]* {
return gatherNamePre(SQLyytext);}
474<PREDICATE_GER,PREDICATE_ENG,DATE,SQL>"[" {
return gatherString(
']' ,0);}
478<PREDICATE_GER,PREDICATE_ENG,DATE># {
return gatherString(
'#' ,2); }
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; }
483<STRING>["-""+""*""/"":""("")"",""."";""?""{""}"] {
return SQLyytext[0]; }
493. {
YY_FATAL_ERROR(
"Invalid symbol");
return SQL_TOKEN_INVALIDSYMBOL;}
#define YY_FATAL_ERROR(msg)
499#if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5
501 #ifndef YY_FLUSH_BUFFER
502 #define YY_FLUSH_BUFFER SQLyy_flush_buffer(YY_CURRENT_BUFFER )
506 #define yytext_ptr SQLyytext
513inline bool checkeof(
int c) {
return c == 0 || c == EOF; }
527 OStringBuffer sBuffer(256);
529 assert(nTyp == 0 || nTyp == 1 || nTyp == 2);
535 if ((
ch = yyinput()) != delim)
543 SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::Name);
544 return SQL_TOKEN_NAME;
546 SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::String);
547 return SQL_TOKEN_STRING;
549 SQL_NEW_NODE(OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQLNodeType::AccessDate);
550 return SQL_TOKEN_ACCESS_DATE;
555 sBuffer.append(
static_cast<char>(
ch));
559 else if (nTyp == 2 && (
ch ==
'\r' ||
ch ==
'\n') )
563 sBuffer.append(
static_cast<char>(
ch));
567 return SQL_TOKEN_INVALIDSYMBOL;
572 sal_Int32 nTokenID = 0;
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;
600 OSL_FAIL(
"mapEnumToToken: unsupported key!" );
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:
645 return SQL_TOKEN_NAME;
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:
693 if (sStmt.getStr()[
nPos] ==
':')
701 nToken = SQL_TOKEN_STRING;
712OSQLScanner::OSQLScanner()
713 : m_pContext(nullptr)
715 , m_bInternational(false)
733 OSL_ENSURE(
m_pContext,
"OSQLScanner::SQLyyerror: No Context set");
740 OUStringBuffer
Buffer(256);
742 int ch = SQLyytext ? (SQLyytext[0] == 0 ?
' ' : SQLyytext[0]):
' ';
748 if ((
ch = yyinput()) !=
' ')
753 aError =
Buffer.makeStringAndClear();
791 OSL_ENSURE(
m_pContext,
"OSQLScanner::getInternationalTokenID: No Context set");
css::uno::Sequence< sal_Int8 > Buffer
virtual InternationalKeyCode getIntlKeyCode(const OString &rToken) const =0
static sal_Int32 GetENGRule()
static sal_Int32 GetGERRule()
static sal_Int32 GetSTRINGRule()
void prepareScan(const OUString &rNewStatement, const IParseContext *pContext, bool bInternational)
static sal_Int32 GetDATERule()
void setScanner(bool _bNull=false)
static sal_Int32 GetSQLRule()
const IParseContext * m_pContext
IParseContext::InternationalKeyCode getInternationalTokenID(const char *sToken) const
const OString & getStatement() const
static sal_Int32 SQLlex()
sal_Int32 GetCurrentPos() const
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
static bool IN_SQLyyerror
sal_Int32 mapEnumToToken(IParseContext::InternationalKeyCode _eKeyCode)