-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsetab.py
70 lines (63 loc) · 10.3 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
# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftORleftANDleftISEQUALleftLTLEGTGEleftPLUSMINUSleftMULTIPLYDIVIDEleftPOWERrightNOTAND BOOL CHAR COMMA DECREMENT DIVIDE DOT DOUBLE EQUAL GE GT IDENTIFIER INCREMENT INT ISEQUAL LBRACE LE LPARAN LT MINUS MODULO MULTIPLY NOT NOTEQUAL OR PLUS POWER PRINT RBRACE RPARAN SEMICOLON STRING STRUCT VARTYPEline : stmtsstmts : stmt SEMICOLON\n | stmt SEMICOLON stmts\n \n stmt : IDENTIFIER IDENTIFIER\n \n stmt : IDENTIFIER DOT IDENTIFIER EQUAL exp\n \n stmt : STRUCT IDENTIFIER LBRACE assignments RBRACE\n \n assignments : VARTYPE IDENTIFIER SEMICOLON\n | VARTYPE IDENTIFIER SEMICOLON assignments\n stmt : expstmt : VARTYPE IDENTIFIER EQUAL expstmt : IDENTIFIER EQUAL expstmt : PRINT LPARAN exps RPARANstmt : PRINT LPARAN IDENTIFIER DOT IDENTIFIER RPARANexps : exp\n | exp COMMA exps\n stmt : IDENTIFIER INCREMENTstmt : IDENTIFIER DECREMENTexp : MINUS IDENTIFIER\n exp : exp PLUS exp\n | exp MINUS exp\n | exp MULTIPLY exp\n | exp DIVIDE exp\n | exp MODULO exp\n | exp POWER exp\n | exp LE exp\n | exp GE exp\n | exp ISEQUAL exp\n | exp NOTEQUAL exp\n | exp LT exp\n | exp GT exp\n | exp AND exp\n | exp OR expexp : LPARAN exp RPARANexp : NOT expexp : INTexp : DOUBLEexp : CHARexp : STRINGexp : BOOLexp : IDENTIFIER'
_lr_action_items = {'IDENTIFIER':([0,4,6,7,9,10,11,17,19,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,69,72,73,],[4,18,37,38,41,42,41,4,45,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,64,41,41,76,77,41,]),'STRUCT':([0,17,],[6,6,]),'VARTYPE':([0,17,61,79,],[7,7,69,69,]),'PRINT':([0,17,],[8,8,]),'MINUS':([0,4,5,9,11,12,13,14,15,16,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,64,65,66,67,70,73,74,],[10,-40,24,10,10,-35,-36,-37,-38,-39,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,24,-40,-18,-34,24,-19,-20,-21,-22,24,-24,24,24,24,24,24,24,24,24,10,-40,24,-33,10,24,10,24,]),'LPARAN':([0,8,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[9,39,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,]),'NOT':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,]),'INT':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,]),'DOUBLE':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,]),'CHAR':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,]),'STRING':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,]),'BOOL':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,]),'$end':([1,2,17,44,],[0,-1,-2,-3,]),'SEMICOLON':([3,4,5,12,13,14,15,16,18,21,22,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,66,70,71,74,75,76,80,],[17,-40,-9,-35,-36,-37,-38,-39,-4,-16,-17,-40,-18,-34,-11,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-10,-12,-5,-6,79,-13,]),'DOT':([4,64,],[19,72,]),'EQUAL':([4,38,45,],[20,62,67,]),'INCREMENT':([4,],[21,]),'DECREMENT':([4,],[22,]),'PLUS':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,23,-35,-36,-37,-38,-39,23,-40,-18,-34,23,-19,-20,-21,-22,23,-24,23,23,23,23,23,23,23,23,-40,23,-33,23,23,]),'MULTIPLY':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,25,-35,-36,-37,-38,-39,25,-40,-18,-34,25,25,25,-21,-22,25,-24,25,25,25,25,25,25,25,25,-40,25,-33,25,25,]),'DIVIDE':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,26,-35,-36,-37,-38,-39,26,-40,-18,-34,26,26,26,-21,-22,26,-24,26,26,26,26,26,26,26,26,-40,26,-33,26,26,]),'MODULO':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,27,-35,-36,-37,-38,-39,27,-40,-18,-34,27,-19,-20,-21,-22,27,-24,-25,-26,-27,27,-29,-30,-31,-32,-40,27,-33,27,27,]),'POWER':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,28,-35,-36,-37,-38,-39,28,-40,-18,-34,28,28,28,28,28,28,-24,28,28,28,28,28,28,28,28,-40,28,-33,28,28,]),'LE':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,29,-35,-36,-37,-38,-39,29,-40,-18,-34,29,-19,-20,-21,-22,29,-24,-25,-26,29,29,-29,-30,29,29,-40,29,-33,29,29,]),'GE':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,30,-35,-36,-37,-38,-39,30,-40,-18,-34,30,-19,-20,-21,-22,30,-24,-25,-26,30,30,-29,-30,30,30,-40,30,-33,30,30,]),'ISEQUAL':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,31,-35,-36,-37,-38,-39,31,-40,-18,-34,31,-19,-20,-21,-22,31,-24,-25,-26,-27,31,-29,-30,31,31,-40,31,-33,31,31,]),'NOTEQUAL':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,32,-35,-36,-37,-38,-39,32,-40,-18,-34,32,-19,-20,-21,-22,32,-24,-25,-26,-27,32,-29,-30,-31,-32,-40,32,-33,32,32,]),'LT':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,33,-35,-36,-37,-38,-39,33,-40,-18,-34,33,-19,-20,-21,-22,33,-24,-25,-26,33,33,-29,-30,33,33,-40,33,-33,33,33,]),'GT':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,34,-35,-36,-37,-38,-39,34,-40,-18,-34,34,-19,-20,-21,-22,34,-24,-25,-26,34,34,-29,-30,34,34,-40,34,-33,34,34,]),'AND':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,35,-35,-36,-37,-38,-39,35,-40,-18,-34,35,-19,-20,-21,-22,35,-24,-25,-26,-27,35,-29,-30,-31,35,-40,35,-33,35,35,]),'OR':([4,5,12,13,14,15,16,40,41,42,43,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,70,74,],[-40,36,-35,-36,-37,-38,-39,36,-40,-18,-34,36,-19,-20,-21,-22,36,-24,-25,-26,-27,36,-29,-30,-31,-32,-40,36,-33,36,36,]),'RPARAN':([12,13,14,15,16,40,41,42,43,47,48,49,50,51,52,53,54,55,56,57,58,59,60,63,64,65,66,77,78,],[-35,-36,-37,-38,-39,66,-40,-18,-34,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,71,-40,-14,-33,80,-15,]),'COMMA':([12,13,14,15,16,41,42,43,47,48,49,50,51,52,53,54,55,56,57,58,59,60,64,65,66,],[-35,-36,-37,-38,-39,-40,-18,-34,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-40,73,-33,]),'LBRACE':([37,],[61,]),'RBRACE':([68,79,81,],[75,-7,-8,]),}
_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 = {'line':([0,],[1,]),'stmts':([0,17,],[2,44,]),'stmt':([0,17,],[3,3,]),'exp':([0,9,11,17,20,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,62,67,73,],[5,40,43,5,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,65,70,74,65,]),'exps':([39,73,],[63,78,]),'assignments':([61,79,],[68,81,]),}
_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' -> line","S'",1,None,None,None),
('line -> stmts','line',1,'p_stmt_multiline','parser.py',57),
('stmts -> stmt SEMICOLON','stmts',2,'p_stmt_end','parser.py',62),
('stmts -> stmt SEMICOLON stmts','stmts',3,'p_stmt_end','parser.py',63),
('stmt -> IDENTIFIER IDENTIFIER','stmt',2,'p_struct_variable','parser.py',72),
('stmt -> IDENTIFIER DOT IDENTIFIER EQUAL exp','stmt',5,'p_struct_members_init','parser.py',78),
('stmt -> STRUCT IDENTIFIER LBRACE assignments RBRACE','stmt',5,'p_struct','parser.py',84),
('assignments -> VARTYPE IDENTIFIER SEMICOLON','assignments',3,'p_struct_initialisation','parser.py',91),
('assignments -> VARTYPE IDENTIFIER SEMICOLON assignments','assignments',4,'p_struct_initialisation','parser.py',92),
('stmt -> exp','stmt',1,'p_stmt_exp','parser.py',100),
('stmt -> VARTYPE IDENTIFIER EQUAL exp','stmt',4,'p_stmt_assign','parser.py',104),
('stmt -> IDENTIFIER EQUAL exp','stmt',3,'p_stmt_change','parser.py',108),
('stmt -> PRINT LPARAN exps RPARAN','stmt',4,'p_stmt_print','parser.py',112),
('stmt -> PRINT LPARAN IDENTIFIER DOT IDENTIFIER RPARAN','stmt',6,'p_struct_print','parser.py',116),
('exps -> exp','exps',1,'p_stmt_many_exps','parser.py',120),
('exps -> exp COMMA exps','exps',3,'p_stmt_many_exps','parser.py',121),
('stmt -> IDENTIFIER INCREMENT','stmt',2,'p_stmt_increment','parser.py',129),
('stmt -> IDENTIFIER DECREMENT','stmt',2,'p_stmt_decrement','parser.py',133),
('exp -> MINUS IDENTIFIER','exp',2,'p_exp_neg_number','parser.py',137),
('exp -> exp PLUS exp','exp',3,'p_exp_binop','parser.py',142),
('exp -> exp MINUS exp','exp',3,'p_exp_binop','parser.py',143),
('exp -> exp MULTIPLY exp','exp',3,'p_exp_binop','parser.py',144),
('exp -> exp DIVIDE exp','exp',3,'p_exp_binop','parser.py',145),
('exp -> exp MODULO exp','exp',3,'p_exp_binop','parser.py',146),
('exp -> exp POWER exp','exp',3,'p_exp_binop','parser.py',147),
('exp -> exp LE exp','exp',3,'p_exp_binop','parser.py',148),
('exp -> exp GE exp','exp',3,'p_exp_binop','parser.py',149),
('exp -> exp ISEQUAL exp','exp',3,'p_exp_binop','parser.py',150),
('exp -> exp NOTEQUAL exp','exp',3,'p_exp_binop','parser.py',151),
('exp -> exp LT exp','exp',3,'p_exp_binop','parser.py',152),
('exp -> exp GT exp','exp',3,'p_exp_binop','parser.py',153),
('exp -> exp AND exp','exp',3,'p_exp_binop','parser.py',154),
('exp -> exp OR exp','exp',3,'p_exp_binop','parser.py',155),
('exp -> LPARAN exp RPARAN','exp',3,'p_exp_paran','parser.py',159),
('exp -> NOT exp','exp',2,'p_exp_not','parser.py',163),
('exp -> INT','exp',1,'p_exp_int','parser.py',167),
('exp -> DOUBLE','exp',1,'p_exp_double','parser.py',171),
('exp -> CHAR','exp',1,'p_exp_char','parser.py',175),
('exp -> STRING','exp',1,'p_exp_string','parser.py',179),
('exp -> BOOL','exp',1,'p_exp_bool','parser.py',183),
('exp -> IDENTIFIER','exp',1,'p_exp_identifier','parser.py',187),
]