Changeset View
Changeset View
Standalone View
Standalone View
src/parser/KDbSqlScanner.l
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | Copyright (C) 2004 Lucijan Busch <lucijan@kde.org> | 2 | Copyright (C) 2004 Lucijan Busch <lucijan@kde.org> | ||
3 | Copyright (C) 2004-2015 Jarosław Staniek <staniek@kde.org> | 3 | Copyright (C) 2004-2018 Jarosław Staniek <staniek@kde.org> | ||
4 | 4 | | |||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. | ||
9 | 9 | | |||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 26 Lines | |||||
38 | %} | 38 | %} | ||
39 | 39 | | |||
40 | /* *** Please reflect changes to this file in ../driver_p.cpp *** */ | 40 | /* *** Please reflect changes to this file in ../driver_p.cpp *** */ | ||
41 | 41 | | |||
42 | %option case-insensitive | 42 | %option case-insensitive | ||
43 | %option noyywrap | 43 | %option noyywrap | ||
44 | %option never-interactive | 44 | %option never-interactive | ||
45 | 45 | | |||
46 | %x DATE_OR_TIME | ||||
47 | | ||||
46 | whitespace [ \t\n] | 48 | whitespace [ \t\n] | ||
49 | whitespace_1_line [ \t] | ||||
47 | digit [0-9] | 50 | digit [0-9] | ||
48 | e_str1 (\\\'|\'\'|[^']) | 51 | e_str1 (\\\'|\'\'|[^']) | ||
49 | e_str2 (\\\"|\"\"|[^"]) | 52 | e_str2 (\\\"|\"\"|[^"]) | ||
50 | string (\'{e_str1}*\'|\"{e_str2}*\") | 53 | string (\'{e_str1}*\'|\"{e_str2}*\") | ||
51 | /*identifier [a-zA-Z_][a-zA-Z_0-9]* */ | 54 | /*identifier [a-zA-Z_][a-zA-Z_0-9]* */ | ||
52 | identifier [a-zA-Z_0-9]+ | 55 | identifier [a-zA-Z_0-9]+ | ||
53 | /* quoted_identifier (\"[a-zA-Z_0-9]+\") */ | 56 | /* quoted_identifier (\"[a-zA-Z_0-9]+\") */ | ||
54 | query_parameter \[[^\[\]]+\] | 57 | query_parameter \[[^\[\]]+\] | ||
55 | 58 | | |||
56 | integer {digit}+ | 59 | integer {digit}+ | ||
57 | decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*)) | 60 | decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*)) | ||
58 | real ((({digit}*\.{digit}+)|({digit}+\.{digit}*)|({digit}+))([Ee][-+]?{digit}+)) | 61 | real ((({digit}*\.{digit}+)|({digit}+\.{digit}*)|({digit}+))([Ee][-+]?{digit}+)) | ||
59 | 62 | | |||
60 | %% | 63 | %% | ||
61 | 64 | | |||
65 | int DATE_OR_TIME_caller = 0; | ||||
62 | 66 | | |||
63 | "<>" { | 67 | "<>" { | ||
64 | ECOUNT; | 68 | ECOUNT; | ||
65 | return NOT_EQUAL; | 69 | return NOT_EQUAL; | ||
66 | } | 70 | } | ||
67 | 71 | | |||
68 | "!=" { | 72 | "!=" { | ||
69 | ECOUNT; | 73 | ECOUNT; | ||
Show All 34 Lines | |||||
104 | } | 108 | } | ||
105 | 109 | | |||
106 | {decimal} { | 110 | {decimal} { | ||
107 | ECOUNT; | 111 | ECOUNT; | ||
108 | yylval.binaryValue = new QByteArray(yytext, yyleng); | 112 | yylval.binaryValue = new QByteArray(yytext, yyleng); | ||
109 | return REAL_CONST; | 113 | return REAL_CONST; | ||
110 | } | 114 | } | ||
111 | 115 | | |||
116 | /* --- DATE_OR_TIME --- */ | ||||
117 | # { | ||||
118 | ECOUNT; | ||||
119 | sqlParserDebug() << "### begin DATE_OR_TIME" << yytext << "(" << yyleng << ")"; | ||||
120 | DATE_OR_TIME_caller = YYSTATE; | ||||
121 | BEGIN(DATE_OR_TIME); | ||||
122 | return '#'; | ||||
123 | } | ||||
124 | | ||||
125 | <DATE_OR_TIME>{ | ||||
126 | | ||||
127 | [-+/:] { // year prefix or / or - or : separator | ||||
128 | ECOUNT; | ||||
129 | return yytext[0]; | ||||
130 | } | ||||
131 | | ||||
132 | {integer} { // year, month, day, hour, minute or second | ||||
133 | ECOUNT; | ||||
134 | yylval.binaryValue = new QByteArray(yytext, yyleng); | ||||
135 | return DATE_TIME_INTEGER; | ||||
136 | } | ||||
137 | | ||||
138 | {whitespace_1_line}+ { | ||||
139 | ECOUNT; | ||||
140 | return TABS_OR_SPACES; | ||||
141 | } | ||||
142 | | ||||
143 | {whitespace_1_line}*(?i:AM) { | ||||
144 | ECOUNT; | ||||
145 | return TIME_AM; | ||||
146 | } | ||||
147 | | ||||
148 | {whitespace_1_line}*(?i:PM) { | ||||
149 | ECOUNT; | ||||
150 | return TIME_PM; | ||||
151 | } | ||||
152 | | ||||
153 | # { | ||||
154 | ECOUNT; | ||||
155 | sqlParserDebug() << "### begin DATE_OR_TIME" << yytext << "(" << yyleng << ")"; | ||||
156 | BEGIN(DATE_OR_TIME_caller); | ||||
157 | return '#'; | ||||
158 | } | ||||
159 | | ||||
160 | } | ||||
161 | /* -- end of DATE_OR_TIME --- */ | ||||
162 | | ||||
112 | ("AND"|"&&") { | 163 | ("AND"|"&&") { | ||
113 | ECOUNT; | 164 | ECOUNT; | ||
114 | return AND; | 165 | return AND; | ||
115 | } | 166 | } | ||
116 | 167 | | |||
117 | "AS" { | 168 | "AS" { | ||
118 | ECOUNT; | 169 | ECOUNT; | ||
119 | return AS; | 170 | return AS; | ||
▲ Show 20 Lines • Show All 217 Lines • Show Last 20 Lines |