kaqing 2.0.71__py3-none-any.whl → 2.0.73__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- adam/sql/sql_completer.py +6 -6
- adam/sql/state_machine.py +154 -169
- adam/version.py +1 -1
- {kaqing-2.0.71.dist-info → kaqing-2.0.73.dist-info}/METADATA +1 -1
- {kaqing-2.0.71.dist-info → kaqing-2.0.73.dist-info}/RECORD +8 -8
- {kaqing-2.0.71.dist-info → kaqing-2.0.73.dist-info}/WHEEL +0 -0
- {kaqing-2.0.71.dist-info → kaqing-2.0.73.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.71.dist-info → kaqing-2.0.73.dist-info}/top_level.txt +0 -0
adam/sql/sql_completer.py
CHANGED
@@ -4,7 +4,7 @@ from prompt_toolkit.document import Document
|
|
4
4
|
import sqlparse
|
5
5
|
from sqlparse.sql import Statement
|
6
6
|
|
7
|
-
from adam.sql.state_machine import StateMachine
|
7
|
+
from adam.sql.state_machine import StateMachine, StateTo
|
8
8
|
from adam.sql.term_completer import TermCompleter
|
9
9
|
|
10
10
|
__all__ = [
|
@@ -36,17 +36,17 @@ class SqlCompleter(Completer):
|
|
36
36
|
completer = DML_COMPLETER
|
37
37
|
else:
|
38
38
|
statement: Statement = stmts[0]
|
39
|
-
state = self.machine.traverse_tokens(statement.tokens, state)
|
39
|
+
state: StateTo = self.machine.traverse_tokens(statement.tokens, StateTo(state))
|
40
40
|
if self.debug:
|
41
|
-
print('\n =>', state)
|
41
|
+
print('\n =>', state.to_s if isinstance(state, StateTo) else '')
|
42
42
|
|
43
|
-
if not state:
|
43
|
+
if not state or not state.to_s:
|
44
44
|
completer = DML_COMPLETER
|
45
45
|
|
46
|
-
if state in self.machine.suggestions:
|
46
|
+
if state and state.to_s in self.machine.suggestions:
|
47
47
|
terms = []
|
48
48
|
|
49
|
-
for word in self.machine.suggestions[state].strip(' ').split(','):
|
49
|
+
for word in self.machine.suggestions[state.to_s].strip(' ').split(','):
|
50
50
|
if word == 'tables':
|
51
51
|
terms.extend(self.tables())
|
52
52
|
elif word == 'single':
|
adam/sql/state_machine.py
CHANGED
@@ -130,24 +130,19 @@ __all__ = [
|
|
130
130
|
|
131
131
|
SPEC = [
|
132
132
|
' > select > select',
|
133
|
-
'select_ > name|* > select_a
|
133
|
+
'select_ > name|* > select_a ^ *',
|
134
134
|
'select_a > , > select_a_comma_',
|
135
|
-
'select_a_comma_ > name|* > select_a
|
136
|
-
'select_a_ > from > select_from
|
137
|
-
'select_from_ > name > select_from_x
|
138
|
-
'- >
|
139
|
-
'
|
135
|
+
'select_a_comma_ > name|* > select_a ^ *',
|
136
|
+
'select_a_ > from > select_from ^ from',
|
137
|
+
'select_from_ > name > select_from_x ^ (select,tables',
|
138
|
+
'- > ( > select_from_lp_',
|
139
|
+
'- < ) > select_from_ns',
|
140
|
+
'select_from_lp_ > select > select',
|
140
141
|
'select_from_x > , > select_from_x_comma_',
|
141
|
-
'
|
142
|
-
'
|
143
|
-
'
|
144
|
-
'
|
145
|
-
'- > group > select_group',
|
146
|
-
'- > group by > select_group_by',
|
147
|
-
'- > limit > select_where_sc_limit',
|
148
|
-
'select_from_x_comma_ > name > select_from_x ^ tables',
|
149
|
-
'select_from_x_ ^ as,where,inner join,left outer join,right outer join,full outer join,group by,limit',
|
150
|
-
'select_from_x_as_x_ > , > select_from_x_comma_ ^ where,inner join,left outer join,right outer join,full outer join,group by,limit',
|
142
|
+
'select_from_ns_ > as > select_from_x_as ^ as',
|
143
|
+
'select_from_x_comma_ > name > select_from_x ^ tables',
|
144
|
+
'select_from_x_ ^ as,where,inner join,left outer join,right outer join,full outer join,group by,limit',
|
145
|
+
'select_from_x_as_x_ > , > select_from_x_comma_ ^ where,inner join,left outer join,right outer join,full outer join,group by,limit',
|
151
146
|
'- > as > select_from_x_as',
|
152
147
|
'- > where > select_where',
|
153
148
|
'- > limit > select_where_sc_limit',
|
@@ -163,122 +158,108 @@ SPEC = [
|
|
163
158
|
'- > right outer join > select_join',
|
164
159
|
'- > full > select_from_x_full',
|
165
160
|
'- > full outer join > select_join',
|
166
|
-
'select_from_x_as_ > name > select_from_x_as_x
|
161
|
+
'select_from_x_as_ > name > select_from_x_as_x ^ x,y,z',
|
167
162
|
'select_from_x_as_x > , > select_from_x_as_x_comma_',
|
168
|
-
'
|
169
|
-
'
|
170
|
-
'
|
171
|
-
'
|
172
|
-
'select_where_a_ > comparison > select_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
163
|
+
'select_from_x_as_x_comma_ > name > select_from_x ^ tables',
|
164
|
+
'select_where_ > name > select_where_a ^ id,x.,y.,z.',
|
165
|
+
'select_where_a > comparison > select_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
166
|
+
'select_where_a_ > comparison > select_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
173
167
|
'- > not > select_where_a_not',
|
174
168
|
'- > in > select_where_a_in',
|
175
|
-
'select_where_a_not_ > comparison > select_where_a_not_op
|
169
|
+
'select_where_a_not_ > comparison > select_where_a_not_op ^ like,in',
|
176
170
|
'- > in > select_where_a_in',
|
177
|
-
'select_where_a_in >
|
178
|
-
'
|
171
|
+
'select_where_a_in > ( > select_where_a_in_lp_ ^ (',
|
172
|
+
'- < ) > select_where_sc',
|
173
|
+
'select_where_a_in_lp_ > name|single|num > select_where_a_in_lp_a ^ single,select',
|
179
174
|
'- > select > select_where_a_in_lp_select',
|
180
|
-
'select_where_a_in_lp_select_ > name > select_a
|
181
|
-
'select_where_a_in_lp_a > , > select_where_a_in_lp_a_comma_
|
182
|
-
'
|
183
|
-
'
|
184
|
-
'
|
185
|
-
'
|
186
|
-
'select_where_sc > ) > select_where_sc_rp_',
|
187
|
-
'select_where_sc > } > select_where_sc_re_',
|
188
|
-
'select_where_sc_re__ > as > select_from_x_as ^ as',
|
189
|
-
'select_where_sc_rp_ > } > select_where_sc_re_',
|
190
|
-
'select_where_sc_rp__ > as > select_from_x_as ^ and,or,group by,limit',
|
191
|
-
'- > and|or > select_where',
|
192
|
-
'- > group > select_group',
|
193
|
-
'- > group by > select_group_by',
|
194
|
-
'- > limit > select_where_sc_limit',
|
195
|
-
'- > } > select_where_sc_re_',
|
196
|
-
'select_where_sc_ > and|or > select_where ^ and,or,group by,limit',
|
175
|
+
'select_where_a_in_lp_select_ > name > select_a ^ id',
|
176
|
+
'select_where_a_in_lp_a > , > select_where_a_in_lp_a_comma_ ^ comma,)',
|
177
|
+
'select_where_a_in_lp_a_comma_ > name|single|num > select_where_a_in_lp_a ^ single',
|
178
|
+
'select_where_a_not_op > name|single|num > select_where_sc ^ single',
|
179
|
+
'select_where_a_op > name|single|num > select_where_sc ^ single',
|
180
|
+
'select_where_sc_ > and|or > select_where ^ and,or,group by,limit',
|
197
181
|
'- > group > select_group',
|
198
182
|
'- > group by > select_group_by',
|
199
183
|
'- > limit > select_where_sc_limit',
|
200
|
-
'select_group_ > by > select_group_by
|
201
|
-
'select_group_by_ > name > select_group_by_a
|
184
|
+
'select_group_ > by > select_group_by ^ by',
|
185
|
+
'select_group_by_ > name > select_group_by_a ^ id,x.,y.,z.',
|
202
186
|
'select_group_by_a > , > select_group_by_a_comma_',
|
203
|
-
'
|
204
|
-
'
|
205
|
-
'
|
206
|
-
'
|
207
|
-
'select_where_sc_limit_num > ) > select_where_sc_limit_num_rp_',
|
208
|
-
'select_where_sc_limit_num_rp__ > as > select_from_x_as ^ as',
|
187
|
+
'select_group_by_a_comma_ > name > select_group_by_a ^ id,x.,y.,z.',
|
188
|
+
'select_group_by_a_ > limit > select_where_sc_limit ^ limit',
|
189
|
+
'select_where_sc_limit_ > num > select_where_sc_limit_num ^ 1',
|
190
|
+
'select_where_sc_limit_num_rp__ > as > select_from_x_as ^ as',
|
209
191
|
'select_where_x_inner_ > join > select_join',
|
210
|
-
'select_join_ > name > select_x_join_y
|
211
|
-
'select_from_x_left_ > join > select_join
|
192
|
+
'select_join_ > name > select_x_join_y ^ tables',
|
193
|
+
'select_from_x_left_ > join > select_join ^ outer join',
|
212
194
|
'- > outer > select_from_x_left_outer',
|
213
|
-
'select_from_x_left_outer_ > join > select_join
|
214
|
-
'select_from_x_right_ > join > select_join
|
195
|
+
'select_from_x_left_outer_ > join > select_join ^ join',
|
196
|
+
'select_from_x_right_ > join > select_join ^ outer join',
|
215
197
|
'- > outer > select_from_x_right_outer',
|
216
|
-
'select_from_x_right_outer_ > join > select_join
|
217
|
-
'select_from_x_full_ > join > select_join
|
198
|
+
'select_from_x_right_outer_ > join > select_join ^ join',
|
199
|
+
'select_from_x_full_ > join > select_join ^ outer join',
|
218
200
|
'- > outer > select_from_x_full_outer',
|
219
|
-
'select_from_x_full_outer_ > join > select_join
|
220
|
-
'select_x_join_y_ > as > select_x_join_y_as
|
221
|
-
'- > on > select_x_join_y_on
|
222
|
-
'select_x_join_y_as_ > name > select_x_join_y_as_y
|
223
|
-
'select_x_join_y_as_y_ > on > select_x_join_y_on
|
224
|
-
'select_x_join_y_on_ > name > select_x_join_y_on_a
|
225
|
-
'select_x_join_y_on_a > comparison > select_x_join_y_on_a_op
|
226
|
-
'select_x_join_y_on_a_op > name > select_x_join_y_on_a_op_b
|
201
|
+
'select_from_x_full_outer_ > join > select_join ^ join',
|
202
|
+
'select_x_join_y_ > as > select_x_join_y_as ^ as,on',
|
203
|
+
'- > on > select_x_join_y_on ^ as,on',
|
204
|
+
'select_x_join_y_as_ > name > select_x_join_y_as_y ^ x,y,z',
|
205
|
+
'select_x_join_y_as_y_ > on > select_x_join_y_on ^ on',
|
206
|
+
'select_x_join_y_on_ > name > select_x_join_y_on_a ^ id,x.,y.,z.',
|
207
|
+
'select_x_join_y_on_a > comparison > select_x_join_y_on_a_op ^ =',
|
208
|
+
'select_x_join_y_on_a_op > name > select_x_join_y_on_a_op_b ^ id,x.,y.,z.',
|
227
209
|
'select_x_join_y_on_a_op_b > _ > select_from_x_as_x_',
|
228
|
-
'- > } > select_where_sc_re_',
|
229
210
|
|
230
211
|
|
231
212
|
' > insert > insert',
|
232
|
-
'insert_ > into > insert_into
|
233
|
-
'insert_into_ > name > insert_into_x
|
213
|
+
'insert_ > into > insert_into ^ into',
|
214
|
+
'insert_into_ > name > insert_into_x ^ tables',
|
234
215
|
'insert_into_x > ( > insert_into_x_lp_',
|
235
|
-
'insert_into_x_ > ( > insert_into_x_lp_
|
216
|
+
'insert_into_x_ > ( > insert_into_x_lp_ ^ (,values(',
|
236
217
|
'- > values > insert_values',
|
237
|
-
'insert_into_x_lp_ > name > insert_into_x_lp_a
|
218
|
+
'insert_into_x_lp_ > name > insert_into_x_lp_a ^ id',
|
238
219
|
'insert_into_x_lp_a > , > insert_into_x_lp_a_comma_',
|
239
220
|
'- > ) > insert_into_x_lp_a_rp_',
|
240
|
-
'insert_into_x_lp_a_comma_ > name > insert_into_x_lp_a
|
241
|
-
'insert_into_x_lp_a_rp__ > values > insert_values
|
221
|
+
'insert_into_x_lp_a_comma_ > name > insert_into_x_lp_a ^ id',
|
222
|
+
'insert_into_x_lp_a_rp__ > values > insert_values ^ values(,select',
|
242
223
|
'- > select > select',
|
243
224
|
'insert_values > ( > insert_values_lp_',
|
244
|
-
'insert_values_lp_ > name|single|num > insert_values_lp_v
|
225
|
+
'insert_values_lp_ > name|single|num > insert_values_lp_v ^ single',
|
245
226
|
'insert_values_lp_v > , > insert_values_lp_v_comma_',
|
246
227
|
'insert_values_lp_v_comma_ > name|single|num > insert_values_lp_v',
|
247
228
|
|
248
229
|
|
249
230
|
' > update > update',
|
250
|
-
'update_ > name > update_x
|
251
|
-
'update_x_ > set > update_set
|
252
|
-
'update_set_ > name > update_set_a
|
231
|
+
'update_ > name > update_x ^ tables',
|
232
|
+
'update_x_ > set > update_set ^ set',
|
233
|
+
'update_set_ > name > update_set_a ^ id',
|
253
234
|
'update_set_a > comparison > update_set_a_op',
|
254
|
-
'update_set_a_op > name|single|num > update_set_sc
|
235
|
+
'update_set_a_op > name|single|num > update_set_sc ^ single',
|
255
236
|
'update_set_sc > , > update_set_sc_comma_',
|
256
|
-
'update_set_sc_comma_ > name > update_set_a
|
257
|
-
'update_set_sc_ > , > update_set_sc_comma_
|
237
|
+
'update_set_sc_comma_ > name > update_set_a ^ id',
|
238
|
+
'update_set_sc_ > , > update_set_sc_comma_ ^ where',
|
258
239
|
'- > where > update_where',
|
259
|
-
'update_where_ > name > update_where_a
|
240
|
+
'update_where_ > name > update_where_a ^ id',
|
260
241
|
'update_where_a > comparison > update_where_a_op',
|
261
|
-
'update_where_a_ > comparison > update_where_a_op
|
242
|
+
'update_where_a_ > comparison > update_where_a_op ^ =,<,<=,>,>=,<>,like,not,in',
|
262
243
|
'- > not > update_where_a_not',
|
263
244
|
'- > in > update_where_a_in',
|
264
|
-
'update_where_a_not_ > comparison > update_where_a_not_op
|
245
|
+
'update_where_a_not_ > comparison > update_where_a_not_op ^ like,in',
|
265
246
|
'- > in > update_where_a_in',
|
266
|
-
'update_where_a_in > ( > update_where_a_in_lp_
|
267
|
-
'
|
247
|
+
'update_where_a_in > ( > update_where_a_in_lp_ ^ (',
|
248
|
+
'- < ) > update_where_sc',
|
249
|
+
'update_where_a_in_lp_ > name|single|num > update_where_a_in_lp_a ^ single,select',
|
268
250
|
'- > select > update_where_a_in_lp_select',
|
269
|
-
'update_where_a_in_lp_select_ > name > select_a
|
270
|
-
'update_where_a_in_lp_a > , > update_where_a_in_lp_a_comma_
|
271
|
-
'
|
272
|
-
'
|
273
|
-
'
|
274
|
-
'
|
275
|
-
'update_where_sc_ > and|or > update_where ^ and,or',
|
251
|
+
'update_where_a_in_lp_select_ > name > select_a ^ id',
|
252
|
+
'update_where_a_in_lp_a > , > update_where_a_in_lp_a_comma_ ^ comma,)',
|
253
|
+
'update_where_a_in_lp_a_comma_ > name|single|num > update_where_a_in_lp_a ^ single',
|
254
|
+
'update_where_a_not_op > name|single|num > update_where_sc ^ single',
|
255
|
+
'update_where_a_op > name|single|num > update_where_sc ^ single',
|
256
|
+
'update_where_sc_ > and|or > update_where ^ and,or',
|
276
257
|
|
277
258
|
|
278
259
|
' > delete > delete',
|
279
|
-
'delete_ > from > delete_from
|
280
|
-
'delete_from_ > name > delete_from_x
|
281
|
-
'delete_from_x_ > where > update_where
|
260
|
+
'delete_ > from > delete_from ^ from',
|
261
|
+
'delete_from_ > name > delete_from_x ^ tables',
|
262
|
+
'delete_from_x_ > where > update_where ^ where',
|
282
263
|
]
|
283
264
|
|
284
265
|
KEYWORDS = [
|
@@ -286,37 +267,32 @@ KEYWORDS = [
|
|
286
267
|
'and', 'or', 'group', 'by', 'group by', 'limit',
|
287
268
|
'inner join', 'on', 'left', 'right', 'full', 'outer', 'left outer join',
|
288
269
|
'left join', 'right outer join', 'right join', 'full join', 'full outer join',
|
289
|
-
|
290
270
|
'insert', 'into', 'values',
|
291
|
-
|
292
271
|
'update', 'where', 'set',
|
293
|
-
|
294
272
|
'delete'
|
295
273
|
]
|
296
274
|
|
275
|
+
class StateTo:
|
276
|
+
def __init__(self, to_s: str, comeback_token: str = None, comeback_state: str = None):
|
277
|
+
self.to_s = to_s
|
278
|
+
self.comeback_token = comeback_token
|
279
|
+
self.comeback_state = comeback_state
|
280
|
+
|
281
|
+
def __str__(self):
|
282
|
+
return f'{self.to_s} comeback[{self.comeback_token} {self.comeback_state}]'
|
283
|
+
|
297
284
|
class StateMachine:
|
298
|
-
def __init__(self, indent=0, lp_level = 0,
|
299
|
-
self.states: dict[str,
|
285
|
+
def __init__(self, indent=0, lp_level = 0, debug = False):
|
286
|
+
self.states: dict[str, StateTo] = {}
|
300
287
|
self.suggestions: dict[str, str] = {}
|
301
288
|
|
302
|
-
def add_whitespace_transition(from_s: str):
|
303
|
-
# add whitespace transition if a state with trailing whitespace is found from from states, for example, select > _ > select_
|
304
|
-
if from_s.endswith('_') and not from_s.endswith('_comma_') and not from_s.endswith('_lp_') and not from_s.endswith('_rp_'):
|
305
|
-
if self.debug:
|
306
|
-
print(f'{from_s[:-1]} > _ = {to_s}')
|
307
|
-
self.states[f'{from_s[:-1]} > _'] = from_s
|
308
|
-
|
309
289
|
self.indent = indent
|
310
290
|
self.lp_level = lp_level
|
311
|
-
self.
|
312
|
-
self.lb_levels_to_match = lb_levels_to_match
|
291
|
+
self.comebacks: dict[int, str] = {}
|
313
292
|
self.debug = debug
|
314
293
|
|
315
294
|
from_ss_to_add = []
|
316
295
|
from_ss = ['']
|
317
|
-
token = None
|
318
|
-
tokens = []
|
319
|
-
to_s = None
|
320
296
|
words: str = None
|
321
297
|
for l in SPEC:
|
322
298
|
t_and_w = l.split('^')
|
@@ -326,68 +302,72 @@ class StateMachine:
|
|
326
302
|
words = None
|
327
303
|
|
328
304
|
tks = t_and_w[0].strip(' ').split('>')
|
329
|
-
if l.startswith('-'):
|
330
|
-
token = tks[1].strip(' ')
|
331
|
-
if len(tks) > 2:
|
332
|
-
to_s = tks[2].strip(' ')
|
333
|
-
for from_s in from_ss:
|
334
|
-
tokens = [token]
|
335
|
-
if '|' in token:
|
336
|
-
tokens = token.strip(' ').split('|')
|
337
|
-
|
338
|
-
for t in tokens:
|
339
|
-
if self.debug:
|
340
|
-
print(f'{from_s} > {t} = {to_s}')
|
341
|
-
self.states[f'{from_s} > {t}'] = to_s
|
342
|
-
else:
|
305
|
+
if not l.startswith('-'):
|
343
306
|
if words:
|
344
307
|
self.suggestions[tks[0].strip(' ')] = words
|
345
308
|
|
346
309
|
if len(tks) == 1:
|
347
|
-
|
348
|
-
add_whitespace_transition(from_s)
|
349
|
-
from_ss_to_add.append(f'{from_s}')
|
310
|
+
from_ss_to_add.append(tks[0].strip(' '))
|
350
311
|
continue
|
351
312
|
|
352
313
|
from_ss = []
|
353
314
|
from_ss.extend(from_ss_to_add)
|
354
315
|
from_ss_to_add = []
|
355
316
|
from_ss.append(tks[0].strip(' '))
|
317
|
+
|
318
|
+
self.add_transitions(from_ss, tks)
|
319
|
+
|
320
|
+
def add_transitions(self, from_ss: list[str], tks: list[str]):
|
321
|
+
token = tks[1].strip(' ')
|
322
|
+
if len(tks) > 2:
|
323
|
+
to_s = tks[2].strip(' ')
|
324
|
+
for from_s in from_ss:
|
325
|
+
self.add_whitespace_transition(from_s, to_s)
|
326
|
+
self.add_transition(from_s, token, to_s)
|
327
|
+
elif '<' in tks[0]:
|
328
|
+
from_and_token = tks[0].split('<')
|
329
|
+
if len(from_and_token) > 1:
|
356
330
|
for from_s in from_ss:
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
331
|
+
self.add_comeback_transition(from_s, from_and_token[1], tks[1].strip(' '))
|
332
|
+
|
333
|
+
def add_whitespace_transition(self, from_s: str, to_s: str):
|
334
|
+
# add whitespace transition if a state with trailing whitespace is found from from states, for example, select > _ > select_
|
335
|
+
if from_s.endswith('_') and not from_s.endswith('_comma_') and not from_s.endswith('_lp_') and not from_s.endswith('_rp_'):
|
336
|
+
if self.debug:
|
337
|
+
print(f'{from_s[:-1]} > _ = {to_s}')
|
338
|
+
self.states[f'{from_s[:-1]} > _'] = StateTo(from_s)
|
339
|
+
|
340
|
+
def add_transition(self, from_s: str, token: str, to_s: str):
|
341
|
+
tokens = [token]
|
342
|
+
if '|' in token:
|
343
|
+
tokens = token.split('|')
|
344
|
+
|
345
|
+
for t in tokens:
|
346
|
+
if self.debug:
|
347
|
+
print(f'{from_s} > {t} = {to_s}')
|
348
|
+
self.states[f'{from_s} > {t}'] = StateTo(to_s)
|
349
|
+
|
350
|
+
def add_comeback_transition(self, from_s: str, token: str, to_s: str):
|
351
|
+
orig = self.states[f'{from_s} > (']
|
352
|
+
orig.comeback_token = token
|
353
|
+
orig.comeback_state = to_s
|
354
|
+
self.states[f'{from_s} > ('] = orig
|
355
|
+
|
356
|
+
def traverse_tokens(self, tokens: list[Token], state: StateTo = StateTo('')):
|
357
|
+
def handle_opening_parenthesis():
|
358
|
+
if f'{state.to_s} > {it}' in self.states:
|
359
|
+
state_test = self.states[f'{state.to_s} > {it}']
|
360
|
+
if state_test.comeback_token:
|
361
|
+
self.comebacks[self.lp_level] = state_test.comeback_state
|
362
|
+
|
363
|
+
def handle_closing_parenthesis():
|
364
|
+
if self.lp_level in self.comebacks:
|
365
|
+
try:
|
366
|
+
return StateTo(self.comebacks[self.lp_level])
|
367
|
+
finally:
|
368
|
+
del self.comebacks[self.lp_level]
|
369
|
+
|
370
|
+
return None
|
391
371
|
|
392
372
|
for token in tokens:
|
393
373
|
if self.debug:
|
@@ -407,6 +387,8 @@ class StateMachine:
|
|
407
387
|
if token.is_group:
|
408
388
|
state = self.traverse_tokens(token.tokens, state)
|
409
389
|
else:
|
390
|
+
comeback_state = None
|
391
|
+
|
410
392
|
it = ''
|
411
393
|
if (t := token.value.lower()) in KEYWORDS:
|
412
394
|
it = t
|
@@ -421,21 +403,24 @@ class StateMachine:
|
|
421
403
|
elif token.ttype == T.Wildcard:
|
422
404
|
it = '*'
|
423
405
|
elif token.ttype == T.Punctuation:
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
406
|
+
it = token.value
|
407
|
+
|
408
|
+
if it == '(':
|
409
|
+
handle_opening_parenthesis()
|
428
410
|
self.lp_level += 1
|
429
|
-
elif
|
411
|
+
elif it == ')':
|
430
412
|
self.lp_level -= 1
|
431
|
-
|
413
|
+
comeback_state = handle_closing_parenthesis()
|
432
414
|
|
433
415
|
elif token.ttype == T.Operator.Comparison:
|
434
416
|
it = 'comparison'
|
435
417
|
|
436
418
|
try:
|
437
|
-
# print(f'{state} > {it} > ', end='')
|
438
|
-
|
419
|
+
# print(f'\n{state.to_s} > {it} > ', end='')
|
420
|
+
if comeback_state:
|
421
|
+
state = comeback_state
|
422
|
+
else:
|
423
|
+
state = self.states[f'{state.to_s} > {it}']
|
439
424
|
# print(state)
|
440
425
|
except:
|
441
426
|
pass
|
adam/version.py
CHANGED
@@ -14,7 +14,7 @@ adam/repl_commands.py,sha256=WA90Rl27Juctzr3U3kfCDk5N-oYMKlfWbZeafUgk7k0,4723
|
|
14
14
|
adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
|
15
15
|
adam/repl_state.py,sha256=nZO5CucSIGz68f4JreadGphRzMXPUzkTn-4XcoJJOug,8643
|
16
16
|
adam/utils.py,sha256=2DoWsrcaioFFH0-RjT30qelVRPUJqCGTfz_ucfE7F8g,7406
|
17
|
-
adam/version.py,sha256=
|
17
|
+
adam/version.py,sha256=q-waQEXjbODc4PBlZ6eQ56lWK7XVwitWu091zPvCpx8,139
|
18
18
|
adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
|
20
20
|
adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
|
@@ -164,8 +164,8 @@ adam/k8s_utils/services.py,sha256=EOJJGACVbbRvu5T3rMKqIJqgYic1_MSJ17EA0TJ6UOk,31
|
|
164
164
|
adam/k8s_utils/statefulsets.py,sha256=5g7KxGRHgEewT8rnZneDTaJDylUf-dHH2edWJEoorr8,4667
|
165
165
|
adam/k8s_utils/volumes.py,sha256=RIBmlOSWM3V3QVXLCFT0owVOyh4rGG1ETp521a-6ndo,1137
|
166
166
|
adam/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
167
|
-
adam/sql/sql_completer.py,sha256=
|
168
|
-
adam/sql/state_machine.py,sha256=
|
167
|
+
adam/sql/sql_completer.py,sha256=R5boj_bdHlzeJkGEy7XQDz_qtE-VF1yjg8pXn5zYGJA,2510
|
168
|
+
adam/sql/state_machine.py,sha256=hsXLGZPI5d4umvaC6QZa0EJLBfh2sXBXLN0HjBgscJY,23029
|
169
169
|
adam/sql/term_completer.py,sha256=bNnHAVf9NZl52xS_BQpikbOK39gDBJADnT9gSvG0iqI,2539
|
170
170
|
adam/sso/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
171
171
|
adam/sso/authenticator.py,sha256=BCm16L9zf5aLU47-sTCnudn2zLPwd8M2wwRminJfsqw,615
|
@@ -177,8 +177,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
|
|
177
177
|
adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
|
178
178
|
adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
|
179
179
|
adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
|
180
|
-
kaqing-2.0.
|
181
|
-
kaqing-2.0.
|
182
|
-
kaqing-2.0.
|
183
|
-
kaqing-2.0.
|
184
|
-
kaqing-2.0.
|
180
|
+
kaqing-2.0.73.dist-info/METADATA,sha256=0lcp8slRkjT5wD41HwP8RWmwO6tVbK7RYeXl7iJVvvE,132
|
181
|
+
kaqing-2.0.73.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
182
|
+
kaqing-2.0.73.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
|
183
|
+
kaqing-2.0.73.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
|
184
|
+
kaqing-2.0.73.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|