-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsetab.py
84 lines (77 loc) · 10.6 KB
/
parsetab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'AND AS ASC BY COMA COMILLA COUNT DESC DESIGUAL DISTINCT FROM GROUP HAVING IGUAL IN INNER JOIN LEFT MAX MAYOR_IZQ MAY_IGUAL_IZQ MENOR_IZQ MEN_IGUAL_IZQ MIN NUMERO ON OR ORDER PALABRA PAREN_DER PAREN_IZQ PUNTO SELECT WHERE\n consulta : SELECT distinct campos FROM tablas join where grupos order_by\n distinct : DISTINCT\n distinct :\n campos : columna\n campos : funcion\n campos : columna COMA campos\n campos : funcion COMA campos\n tablas : tabla\n tablas : tabla COMA tablas\n columnas : columna\n columnas : columna COMA columnas\n funcion : MIN PAREN_IZQ columna PAREN_DER\n funcion : MAX PAREN_IZQ columna PAREN_DER\n funcion : COUNT PAREN_IZQ columna PAREN_DER\n funcion : COUNT PAREN_IZQ DISTINCT columna PAREN_DER\n join : INNER JOIN tabla ON condicion join\n join : LEFT JOIN tabla ON condicion join\n join :\n where : WHERE condiciones\n where :\n grupos : group_by\n grupos : group_by having\n grupos :\n group_by : GROUP BY columnas\n having : HAVING condiciones_having\n condiciones_having : funcion operador valor\n condiciones_having : funcion operador valor COMA condiciones_having\n order_by : ORDER BY condiciones_orderby\n order_by :\n condiciones_orderby : columna orden\n condiciones_orderby : columna orden COMA condiciones_orderby\n condiciones : condicion\n condiciones : condicion booleano condiciones\n condicion : columna operador valor\n condicion : columna operador columna\n condicion : columna IN PAREN_IZQ consulta PAREN_DER\n valor : NUMERO\n valor : COMILLA PALABRA COMILLA\n operador : IGUAL\n operador : DESIGUAL\n operador : MENOR_IZQ\n operador : MEN_IGUAL_IZQ\n operador : MAYOR_IZQ\n operador : MAY_IGUAL_IZQ\n booleano : AND\n booleano : OR\n orden : ASC\n orden : DESC\n orden :\n \n tabla : PALABRA\n tabla : PALABRA AS PALABRA\n tabla : PALABRA PALABRA\n \n columna : PALABRA PUNTO PALABRA\n columna : PALABRA PUNTO PALABRA AS PALABRA\n '
_lr_action_items = {'SELECT':([0,84,],[2,2,]),'$end':([1,19,20,21,24,29,33,40,44,45,46,48,49,51,52,56,58,75,77,78,79,80,81,82,85,86,87,88,93,94,95,96,97,98,99,100,101,104,105,],[0,-18,-8,-50,-53,-20,-52,-23,-9,-51,-54,-29,-21,-19,-32,-1,-22,-25,-24,-10,-33,-35,-34,-37,-18,-18,-28,-49,-16,-17,-30,-47,-48,-26,-11,-38,-36,-31,-27,]),'DISTINCT':([2,18,],[4,28,]),'PALABRA':([2,3,4,12,13,14,15,16,17,18,21,28,32,34,35,41,42,43,60,61,62,63,64,66,67,68,69,70,71,72,73,74,83,90,102,],[-3,8,-2,21,8,8,24,8,8,8,33,8,21,45,46,8,21,21,8,8,-45,-46,8,-39,-40,-41,-42,-43,-44,8,8,8,91,8,8,]),'MIN':([2,3,4,13,14,59,103,],[-3,9,-2,9,9,9,9,]),'MAX':([2,3,4,13,14,59,103,],[-3,10,-2,10,10,10,10,]),'COUNT':([2,3,4,13,14,59,103,],[-3,11,-2,11,11,11,11,]),'FROM':([5,6,7,22,23,24,36,37,38,46,47,],[12,-4,-5,-6,-7,-53,-12,-13,-14,-54,-15,]),'COMA':([6,7,20,21,24,33,36,37,38,45,46,47,78,82,88,95,96,97,98,100,],[13,14,32,-50,-53,-52,-12,-13,-14,-51,-54,-15,90,-37,-49,102,-47,-48,103,-38,]),'PUNTO':([8,],[15,]),'PAREN_IZQ':([9,10,11,65,],[16,17,18,84,]),'INNER':([19,20,21,24,33,44,45,46,80,81,82,85,86,100,101,],[30,-8,-50,-53,-52,-9,-51,-54,-35,-34,-37,30,30,-38,-36,]),'LEFT':([19,20,21,24,33,44,45,46,80,81,82,85,86,100,101,],[31,-8,-50,-53,-52,-9,-51,-54,-35,-34,-37,31,31,-38,-36,]),'WHERE':([19,20,21,24,29,33,44,45,46,80,81,82,85,86,93,94,100,101,],[-18,-8,-50,-53,41,-52,-9,-51,-54,-35,-34,-37,-18,-18,-16,-17,-38,-36,]),'GROUP':([19,20,21,24,29,33,40,44,45,46,51,52,79,80,81,82,85,86,93,94,100,101,],[-18,-8,-50,-53,-20,-52,50,-9,-51,-54,-19,-32,-33,-35,-34,-37,-18,-18,-16,-17,-38,-36,]),'ORDER':([19,20,21,24,29,33,40,44,45,46,48,49,51,52,58,75,77,78,79,80,81,82,85,86,93,94,98,99,100,101,105,],[-18,-8,-50,-53,-20,-52,-23,-9,-51,-54,57,-21,-19,-32,-22,-25,-24,-10,-33,-35,-34,-37,-18,-18,-16,-17,-26,-11,-38,-36,-27,]),'PAREN_DER':([19,20,21,24,25,26,27,29,33,39,40,44,45,46,48,49,51,52,56,58,75,77,78,79,80,81,82,85,86,87,88,92,93,94,95,96,97,98,99,100,101,104,105,],[-18,-8,-50,-53,36,37,38,-20,-52,47,-23,-9,-51,-54,-29,-21,-19,-32,-1,-22,-25,-24,-10,-33,-35,-34,-37,-18,-18,-28,-49,101,-16,-17,-30,-47,-48,-26,-11,-38,-36,-31,-27,]),'ON':([21,33,45,54,55,],[-50,-52,-51,72,73,]),'AS':([21,24,],[34,35,]),'IN':([24,46,53,],[-53,-54,65,]),'IGUAL':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,66,66,]),'DESIGUAL':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,67,67,]),'MENOR_IZQ':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,68,68,]),'MEN_IGUAL_IZQ':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,69,69,]),'MAYOR_IZQ':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,70,70,]),'MAY_IGUAL_IZQ':([24,36,37,38,46,47,53,76,],[-53,-12,-13,-14,-54,-15,71,71,]),'HAVING':([24,46,49,77,78,99,],[-53,-54,59,-24,-10,-11,]),'AND':([24,46,52,80,81,82,100,101,],[-53,-54,62,-35,-34,-37,-38,-36,]),'OR':([24,46,52,80,81,82,100,101,],[-53,-54,63,-35,-34,-37,-38,-36,]),'ASC':([24,46,88,],[-53,-54,96,]),'DESC':([24,46,88,],[-53,-54,97,]),'JOIN':([30,31,],[42,43,]),'BY':([50,57,],[60,74,]),'NUMERO':([64,66,67,68,69,70,71,89,],[82,-39,-40,-41,-42,-43,-44,82,]),'COMILLA':([64,66,67,68,69,70,71,89,91,],[83,-39,-40,-41,-42,-43,-44,83,100,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'consulta':([0,84,],[1,92,]),'distinct':([2,],[3,]),'campos':([3,13,14,],[5,22,23,]),'columna':([3,13,14,16,17,18,28,41,60,61,64,72,73,74,90,102,],[6,6,6,25,26,27,39,53,78,53,80,53,53,88,78,88,]),'funcion':([3,13,14,59,103,],[7,7,7,76,76,]),'tablas':([12,32,],[19,44,]),'tabla':([12,32,42,43,],[20,20,54,55,]),'join':([19,85,86,],[29,93,94,]),'where':([29,],[40,]),'grupos':([40,],[48,]),'group_by':([40,],[49,]),'condiciones':([41,61,],[51,79,]),'condicion':([41,61,72,73,],[52,52,85,86,]),'order_by':([48,],[56,]),'having':([49,],[58,]),'booleano':([52,],[61,]),'operador':([53,76,],[64,89,]),'condiciones_having':([59,103,],[75,105,]),'columnas':([60,90,],[77,99,]),'valor':([64,89,],[81,98,]),'condiciones_orderby':([74,102,],[87,104,]),'orden':([88,],[95,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> consulta","S'",1,None,None,None),
('consulta -> SELECT distinct campos FROM tablas join where grupos order_by','consulta',9,'p_consulta','grupo99.py',80),
('distinct -> DISTINCT','distinct',1,'p_consulta','grupo99.py',81),
('distinct -> <empty>','distinct',0,'p_consulta','grupo99.py',82),
('campos -> columna','campos',1,'p_consulta','grupo99.py',83),
('campos -> funcion','campos',1,'p_consulta','grupo99.py',84),
('campos -> columna COMA campos','campos',3,'p_consulta','grupo99.py',85),
('campos -> funcion COMA campos','campos',3,'p_consulta','grupo99.py',86),
('tablas -> tabla','tablas',1,'p_consulta','grupo99.py',87),
('tablas -> tabla COMA tablas','tablas',3,'p_consulta','grupo99.py',88),
('columnas -> columna','columnas',1,'p_consulta','grupo99.py',89),
('columnas -> columna COMA columnas','columnas',3,'p_consulta','grupo99.py',90),
('funcion -> MIN PAREN_IZQ columna PAREN_DER','funcion',4,'p_consulta','grupo99.py',91),
('funcion -> MAX PAREN_IZQ columna PAREN_DER','funcion',4,'p_consulta','grupo99.py',92),
('funcion -> COUNT PAREN_IZQ columna PAREN_DER','funcion',4,'p_consulta','grupo99.py',93),
('funcion -> COUNT PAREN_IZQ DISTINCT columna PAREN_DER','funcion',5,'p_consulta','grupo99.py',94),
('join -> INNER JOIN tabla ON condicion join','join',6,'p_consulta','grupo99.py',95),
('join -> LEFT JOIN tabla ON condicion join','join',6,'p_consulta','grupo99.py',96),
('join -> <empty>','join',0,'p_consulta','grupo99.py',97),
('where -> WHERE condiciones','where',2,'p_consulta','grupo99.py',98),
('where -> <empty>','where',0,'p_consulta','grupo99.py',99),
('grupos -> group_by','grupos',1,'p_consulta','grupo99.py',100),
('grupos -> group_by having','grupos',2,'p_consulta','grupo99.py',101),
('grupos -> <empty>','grupos',0,'p_consulta','grupo99.py',102),
('group_by -> GROUP BY columnas','group_by',3,'p_consulta','grupo99.py',103),
('having -> HAVING condiciones_having','having',2,'p_consulta','grupo99.py',104),
('condiciones_having -> funcion operador valor','condiciones_having',3,'p_consulta','grupo99.py',105),
('condiciones_having -> funcion operador valor COMA condiciones_having','condiciones_having',5,'p_consulta','grupo99.py',106),
('order_by -> ORDER BY condiciones_orderby','order_by',3,'p_consulta','grupo99.py',107),
('order_by -> <empty>','order_by',0,'p_consulta','grupo99.py',108),
('condiciones_orderby -> columna orden','condiciones_orderby',2,'p_consulta','grupo99.py',109),
('condiciones_orderby -> columna orden COMA condiciones_orderby','condiciones_orderby',4,'p_consulta','grupo99.py',110),
('condiciones -> condicion','condiciones',1,'p_consulta','grupo99.py',111),
('condiciones -> condicion booleano condiciones','condiciones',3,'p_consulta','grupo99.py',112),
('condicion -> columna operador valor','condicion',3,'p_consulta','grupo99.py',113),
('condicion -> columna operador columna','condicion',3,'p_consulta','grupo99.py',114),
('condicion -> columna IN PAREN_IZQ consulta PAREN_DER','condicion',5,'p_consulta','grupo99.py',115),
('valor -> NUMERO','valor',1,'p_consulta','grupo99.py',116),
('valor -> COMILLA PALABRA COMILLA','valor',3,'p_consulta','grupo99.py',117),
('operador -> IGUAL','operador',1,'p_consulta','grupo99.py',118),
('operador -> DESIGUAL','operador',1,'p_consulta','grupo99.py',119),
('operador -> MENOR_IZQ','operador',1,'p_consulta','grupo99.py',120),
('operador -> MEN_IGUAL_IZQ','operador',1,'p_consulta','grupo99.py',121),
('operador -> MAYOR_IZQ','operador',1,'p_consulta','grupo99.py',122),
('operador -> MAY_IGUAL_IZQ','operador',1,'p_consulta','grupo99.py',123),
('booleano -> AND','booleano',1,'p_consulta','grupo99.py',124),
('booleano -> OR','booleano',1,'p_consulta','grupo99.py',125),
('orden -> ASC','orden',1,'p_consulta','grupo99.py',126),
('orden -> DESC','orden',1,'p_consulta','grupo99.py',127),
('orden -> <empty>','orden',0,'p_consulta','grupo99.py',128),
('tabla -> PALABRA','tabla',1,'p_tabla','grupo99.py',132),
('tabla -> PALABRA AS PALABRA','tabla',3,'p_tabla','grupo99.py',133),
('tabla -> PALABRA PALABRA','tabla',2,'p_tabla','grupo99.py',134),
('columna -> PALABRA PUNTO PALABRA','columna',3,'p_columa','grupo99.py',148),
('columna -> PALABRA PUNTO PALABRA AS PALABRA','columna',5,'p_columa','grupo99.py',149),
]