├── requirements.txt ├── README.md ├── .idea └── vcs.xml ├── test1.txt ├── main.py ├── test2.txt ├── test3.txt ├── .gitignore ├── lexer.py ├── parser.py └── parsetab.py /requirements.txt: -------------------------------------------------------------------------------- 1 | ply -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compiler Design Project 2 | Compiler design using PLY (Python Lex-Yacc)
3 | Developers :
4 | Mohammad Sami & Mahan Ahmadvand 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test1.txt: -------------------------------------------------------------------------------- 1 | i,j,k[50]:int; 2 | res2:float; 3 | 4 | main() { 5 | k[0]=1 ; 6 | k[1]=1 ; 7 | for (i=2;k[0]c) 6 | { 7 | w=b[a-c]:int; 8 | print(w); 9 | } 10 | elseif(a==c) 11 | print (a) ; 12 | else 13 | amir(a,b,c-a) ; 14 | } 15 | fun mohammad(a:int,t_b:int,c:int):int 16 | { 17 | b[t_b]:int ; 18 | b[0]=1 ; 19 | b[1]=1 ; 20 | for (i=2;i= y >= z; 5 | } 6 | 7 | fun number_of_even_integers(arr[]:int):int 8 | { 9 | result = 0:int; 10 | for(i in arr) 11 | if(i % 2 == 0) 12 | result = result + 1; 13 | return result; 14 | } 15 | 16 | fun a_void_sample_use_on_where(x:int) 17 | { 18 | on(x * x) 19 | { 20 | where 1: 21 | a1 = a1 + 1; 22 | 73; 23 | 24 | where 4: 25 | a4 = a4 + 1; 26 | 27 | where 9: 28 | a9 = a9 + 1; 29 | 30 | where 0: 31 | print(a9); 32 | 33 | }; 34 | } 35 | 36 | fun a_void_sample_use_if_else(x:int) 37 | { 38 | long_live_the_queen:bool; 39 | 40 | if(x * x == 0) 41 | print(a9); 42 | elseif(x * x == 1) 43 | a1 = a1 + 1; 44 | elseif(x * x == 4) 45 | a4 = a4 + 1; 46 | else 47 | { 48 | a9 = a9 + 1; 49 | long_live_the_queen; 50 | } 51 | } 52 | 53 | main() 54 | { 55 | x5,y5,x3,x2,x1:float ; 56 | x5=y5=2+x3=1+x2=2*x1=0.3+0.7; 57 | 58 | a[x5 + x3 + 0.1],i:int; 59 | for(i=0;i<8;i=i+1) 60 | a[i] = i + (i % 3 == 2) ; 61 | long_live_the_king=True:bool; 62 | result=a_void_sample_use_on_where(a):int; 63 | if(result<10) 64 | if(result<1) 65 | print(long_live_the_king); 66 | else 67 | print(result); 68 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | env/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *,cover 48 | .hypothesis/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | 58 | # Flask stuff: 59 | instance/ 60 | .webassets-cache 61 | 62 | # Scrapy stuff: 63 | .scrapy 64 | 65 | # Sphinx documentation 66 | docs/_build/ 67 | 68 | # PyBuilder 69 | target/ 70 | 71 | # IPython Notebook 72 | .ipynb_checkpoints 73 | 74 | # pyenv 75 | .python-version 76 | 77 | # celery beat schedule file 78 | celerybeat-schedule 79 | 80 | # dotenv 81 | .env 82 | 83 | # virtualenv 84 | venv/ 85 | ENV/ 86 | 87 | # Spyder project settings 88 | .spyderproject 89 | 90 | # Rope project settings 91 | .ropeproject 92 | ### VirtualEnv template 93 | # Virtualenv 94 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ 95 | .Python 96 | [Bb]in 97 | [Ii]nclude 98 | [Ll]ib 99 | [Ll]ib64 100 | [Ll]ocal 101 | [Ss]cripts 102 | pyvenv.cfg 103 | .venv 104 | pip-selfcheck.json 105 | ### JetBrains template 106 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 107 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 108 | 109 | # User-specific stuff: 110 | .idea/workspace.xml 111 | .idea/tasks.xml 112 | .idea/dictionaries 113 | .idea/vcs.xml 114 | .idea/jsLibraryMappings.xml 115 | 116 | # Sensitive or high-churn files: 117 | .idea/dataSources.ids 118 | .idea/dataSources.xml 119 | .idea/dataSources.local.xml 120 | .idea/sqlDataSources.xml 121 | .idea/dynamic.xml 122 | .idea/uiDesigner.xml 123 | 124 | # Gradle: 125 | .idea/gradle.xml 126 | .idea/libraries 127 | 128 | # Mongo Explorer plugin: 129 | .idea/mongoSettings.xml 130 | 131 | .idea/ 132 | 133 | ## File-based project format: 134 | *.iws 135 | 136 | ## Plugin-specific files: 137 | 138 | # IntelliJ 139 | /out/ 140 | 141 | # mpeltonen/sbt-idea plugin 142 | .idea_modules/ 143 | 144 | # JIRA plugin 145 | atlassian-ide-plugin.xml 146 | 147 | # Crashlytics plugin (for Android Studio and IntelliJ) 148 | com_crashlytics_export_strings.xml 149 | crashlytics.properties 150 | crashlytics-build.properties 151 | fabric.properties 152 | -------------------------------------------------------------------------------- /lexer.py: -------------------------------------------------------------------------------- 1 | from ply import lex 2 | 3 | 4 | class Lexer: 5 | tokens = [ 6 | 'ID', 'INTEGERNUMBER', 'FLOATNUMBER', 'INTEGER', 'FLOAT', 7 | 'BOOLEAN', 'FUNCTION', 'TRUE', 'FALSE', 'PRINT', 'RETURN', 8 | 'MAIN', 'IF', 'ELSE', 'ELSEIF', 'WHILE', 'ON', 'WHERE', 'FOR', 9 | 'AND', 'OR', 'NOT', 'IN', 'ASSIGN', 'SUM', 'SUB', 'MUL', 'DIV', 10 | 'MOD', 'GT', 'GE', 'LT', 'LE', 'EQ', 'NE', 'LCB', 'RCB', 11 | 'LRB', 'RRB', 'LSB', 'RSB', 'SEMICOLON', 'COLON', 'COMMA', 'ERROR' 12 | ] 13 | reserved = { 14 | # Conditional 15 | 'if': 'IF', 16 | 'then': 'THEN', 17 | 'else': 'ELSE', 18 | 'elseif': 'ELSEIF', 19 | # Loops 20 | 'for': 'FOR', 21 | 'while': 'WHILE', 22 | # Types 23 | 'int': 'INTEGER', 24 | 'float': 'FLOAT', 25 | 'bool': 'BOOLEAN', 26 | # Other Keywords 27 | 'print': 'PRINT', 28 | 'True': 'TRUE', 29 | 'False': 'FALSE', 30 | 'return': 'RETURN', 31 | 'fun': 'FUNCTION', 32 | 'main': 'MAIN', 33 | 'on': 'ON', 34 | 'and': 'AND', 35 | 'or': 'OR', 36 | 'not': 'NOT', 37 | 'in': 'IN', 38 | 'where': 'WHERE' 39 | } 40 | # Colons 41 | t_SEMICOLON = r';' 42 | t_COLON = r':' 43 | t_COMMA = r',' 44 | # Operators 45 | t_MUL = r'\*' 46 | t_DIV = r'/' 47 | t_SUM = r'\+' 48 | t_SUB = r'\-' 49 | t_MOD = r'%' 50 | t_ASSIGN = r'=' 51 | t_GT = r'>' 52 | t_GE = r'>=' 53 | t_LT = r'<' 54 | t_LE = r'<=' 55 | t_EQ = r'==' 56 | t_NE = r'!=' 57 | # Brackets 58 | t_LCB = r'{' 59 | t_RCB = r'}' 60 | t_LRB = r'\(' 61 | t_RRB = r'\)' 62 | t_LSB = r'\[' 63 | t_RSB = r'\]' 64 | 65 | def t_TRUE(self, t): 66 | r'True' 67 | return t 68 | 69 | def t_FALSE(self, t): 70 | r'False' 71 | return t 72 | 73 | def t_ERROR(self, t): 74 | r"""([0-9]{10,})(\.[0-9]+) 75 | |([0-9]{10,}) 76 | |([0-9]+)(\.[0-9]+){2,} 77 | |([A-Z])+[a-zA-Z_0-9]+ 78 | |[0-9]+[a-z_A-Z][a-zA-Z_0-9]* 79 | |[\+\-\%\/\*](\s*[\+\-\%\/\*]+)+ 80 | |ERROR 81 | """ 82 | return t 83 | 84 | def t_newline(self, t): 85 | r""""\n+""" 86 | t.lexer.lineno += len(t.value) 87 | 88 | t_ignore = '\n \t \r ' 89 | 90 | def t_FLOATNUMBER(self, t): 91 | r"""[0-9]{1,9}\.[0-9]+""" 92 | t.value = float(t.value) 93 | return t 94 | 95 | def t_INTEGERNUMBER(self, t): 96 | r"""[0-9]{1,9}""" 97 | t.value = int(t.value) 98 | return t 99 | 100 | def t_ID(self, t): 101 | r"""[_a-z][a-zA-Z_0-9]*""" 102 | if t.value in self.reserved: 103 | t.type = self.reserved[t.value] 104 | return t 105 | 106 | def t_error(self, t): 107 | raise Exception('Error at', t.value) 108 | 109 | def build(self, **kwargs): 110 | """ 111 | build the lexer 112 | """ 113 | self.lexer = lex.lex(module=self, **kwargs) 114 | return self.lexer 115 | -------------------------------------------------------------------------------- /parser.py: -------------------------------------------------------------------------------- 1 | from ply import yacc 2 | from lexer import Lexer 3 | 4 | 5 | class Parser: 6 | tokens = Lexer().tokens 7 | 8 | precedence = ( 9 | 10 | # Braces 11 | ('left', "LCB", "RCB"), 12 | ('left', "LSB", "RSB"), 13 | ('left', "LRB", "RRB"), 14 | 15 | # Statements 16 | # ('left', "WHILE", "FOR", "ON"), 17 | # ('left', "IN"), 18 | ('left', "ELSEIF", "ELSE"), 19 | ('left', "IF"), 20 | # ('left', "WHERE"), 21 | # ('left', "PRINT"), 22 | # ('left', "RETURN"), 23 | 24 | # High-level Boolean Operators 25 | ('left', "OR"), 26 | ('left', "AND"), 27 | ('left', "NOT"), 28 | 29 | # Low-level Boolean Operators & Assignment 30 | ('left', "GT", "LT", "NE", "EQ", "LE", "GE"), 31 | 32 | # Numeric Operators 33 | ('left', "MOD"), 34 | ('left', "SUM", "SUB"), 35 | ('left', "MUL", "DIV"), 36 | 37 | # Atoms 38 | ('left', "INTEGERNUMBER"), 39 | ('left', "FLOATNUMBER"), 40 | ('left', "TRUE", "FALSE"), 41 | 42 | # Type Identifiers 43 | # ('left', "INTEGER"), 44 | # ('left', "FLOAT"), 45 | # ('left', "BOOLEAN"), 46 | 47 | # Identifier 48 | ('left', "ID"), 49 | ('right', "ASSIGN"), 50 | 51 | # ('left', "FUNCTION"), 52 | # ('left', "MAIN"), 53 | 54 | # Low-level Misc 55 | # ("left", "SEMICOLON", "COLON"), 56 | 57 | # Error 58 | ("left", "ERROR") 59 | ) 60 | 61 | def __init__(self): 62 | pass 63 | 64 | def p_program(self, p): 65 | """program : declist MAIN LRB RRB block 66 | | MAIN LRB RRB block""" 67 | print("declist MAIN LRB RRB block| MAIN LRB RRB block") 68 | 69 | def p_declist(self, p): 70 | """declist : dec 71 | | declist dec""" 72 | print("dec| declist dec") 73 | 74 | def p_dec(self, p): 75 | """dec : vardec 76 | | funcdec""" 77 | 78 | print("vardec| funcdec") 79 | 80 | def p_type(self, p): 81 | """type : INTEGER 82 | | FLOAT 83 | | BOOLEAN""" 84 | print("INTEGER| FLOAT| BOOLEAN") 85 | 86 | def p_iddec(self, p): 87 | """iddec : lvalue 88 | | lvalue ASSIGN exp""" 89 | print("ID| ID LSB exp RSB| ID ASSIGN exp") 90 | 91 | def p_idlist(self, p): 92 | """idlist : iddec 93 | | idlist COMMA iddec""" 94 | print("iddec| idlist COMMA iddec") 95 | 96 | def p_vardec(self, p): 97 | """vardec : idlist COLON type SEMICOLON""" 98 | print("idlist COLON type SEMICOLON") 99 | 100 | def p_funcdec(self, p): 101 | """funcdec : FUNCTION ID LRB paramdecs RRB COLON type block 102 | | FUNCTION ID LRB paramdecs RRB block""" 103 | print("FUNCTION ID LRB paramdecs RRB COLON type block| FUNCTION ID LRB paramdecs RRB block") 104 | 105 | def p_paramdecs(self, p): 106 | """paramdecs : paramdecslist 107 | | empty""" 108 | print("paramdecslist| empty") 109 | 110 | def p_paramdecslist(self, p): 111 | """paramdecslist : paramdec 112 | | paramdecslist COMMA paramdec""" 113 | print("paramdec| paramdecslist COMMA paramdec") 114 | 115 | def p_paramdec(self, p): 116 | """ paramdec : ID COLON type 117 | | ID LSB RSB COLON type""" 118 | print("ID COLON type| ID LSB RSB COLON type") 119 | 120 | def p_block(self, p): 121 | """block : LCB stmtlist RCB""" 122 | print("LCB stmtlist RCB") 123 | 124 | def p_stmtlist(self, p): 125 | """stmtlist : stmtlist stmt 126 | | empty""" 127 | print("stmtlist stmt| empty") 128 | 129 | def p_lvalue(self, p): 130 | """lvalue : ID 131 | | ID LSB exp RSB""" 132 | print("ID| ID LSB exp RSB") 133 | 134 | def p_case(self, p): 135 | """case : WHERE const COLON stmtlist""" 136 | print("WHERE const COLON stmtlist") 137 | 138 | def p_cases(self, p): 139 | """cases : cases case 140 | | empty""" 141 | print("cases case| empty") 142 | 143 | def p_stmt(self, p): 144 | """stmt : RETURN exp SEMICOLON 145 | | exp SEMICOLON 146 | | block 147 | | vardec 148 | | WHILE LRB exp RRB stmt 149 | | ON LRB exp RRB LCB cases RCB SEMICOLON 150 | | FOR LRB exp SEMICOLON exp SEMICOLON exp RRB stmt 151 | | FOR LRB ID IN ID RRB stmt 152 | | IF LRB exp RRB stmt elseiflist 153 | | IF LRB exp RRB stmt elseiflist ELSE stmt 154 | | PRINT LRB ID RRB SEMICOLON""" 155 | print( 156 | "RETURN exp SEMICOLON| exp SEMICOLON| block| vardec| WHILE LRB exp RRB stmt| ON LRB exp RRB LCB cases RCB SEMICOLON| FOR LRB exp SEMICOLON exp SEMICOLON exp RRB stmt| FOR LRB ID IN ID RRB stmt| IF LRB exp RRB stmt elseiflist| IF LRB exp RRB stmt elseiflist ELSE stmt| PRINT LRB ID RRB") 157 | 158 | def p_elseiflist(self, p): 159 | """elseiflist : elseiflist ELSEIF LRB exp RRB stmt 160 | | empty""" 161 | print("elseiflist ELSEIF LRB exp RRB stmt| empty") 162 | 163 | def p_exp(self, p): 164 | """exp : lvalue ASSIGN exp 165 | | exp GT exp 166 | | exp LT exp 167 | | exp NE exp 168 | | exp EQ exp 169 | | exp LE exp 170 | | exp GE exp 171 | | exp AND exp 172 | | exp OR exp 173 | | exp SUM exp 174 | | exp SUB exp 175 | | exp MUL exp 176 | | exp DIV exp 177 | | exp MOD exp 178 | | const 179 | | lvalue 180 | | lvalue LRB explist RRB 181 | | LRB exp RRB 182 | | lvalue LRB RRB 183 | | SUB exp 184 | | NOT exp""" 185 | print( 186 | "lvalue ASSIGN exp| exp GT exp| exp LT exp| exp NE exp| exp EQ exp| exp LE exp| exp GE exp| exp AND exp| exp OR exp| exp SUM exp| exp SUB exp| exp MUL exp| exp DIV exp| exp MOD exp| const| lvalue| ID LRB explist RRB| LRB exp RRB| ID LRB RRB| SUB exp| NOT exp") 187 | 188 | def p_const(self, p): 189 | """const : INTEGERNUMBER 190 | | FLOATNUMBER 191 | | TRUE 192 | | FALSE""" 193 | print("INTEGERNUMBER| FLOATNUMBER| TRUE| FALSE") 194 | 195 | def p_explist(self, p): 196 | """explist : exp 197 | | explist COMMA exp""" 198 | print("exp| explist COMMA exp") 199 | 200 | def p_empty(self, p): 201 | """empty :""" 202 | print("empty") 203 | pass 204 | 205 | def p_error(self, p): 206 | print("Error", p.type, p.lexpos) 207 | 208 | # raise Exception('ParsingError: invalid grammar at ', p) 209 | 210 | def build(self, **kwargs): 211 | self.parser = yacc.yacc(module=self, **kwargs) 212 | return self.parser 213 | 214 | 215 | lexer = Lexer().build() 216 | file = open('test3.txt') 217 | text_input = file.read() 218 | file.close() 219 | lexer.input(text_input) 220 | 221 | parser = Parser() 222 | parser.build().parse(text_input, lexer, False) 223 | -------------------------------------------------------------------------------- /parsetab.py: -------------------------------------------------------------------------------- 1 | 2 | # parsetab.py 3 | # This file is automatically generated. Do not edit. 4 | # pylint: disable=W,C,R 5 | _tabversion = '3.10' 6 | 7 | _lr_method = 'LALR' 8 | 9 | _lr_signature = 'leftLCBRCBleftLSBRSBleftLRBRRBleftELSEIFELSEleftIFleftORleftANDleftNOTleftGTLTNEEQLEGEleftMODleftSUMSUBleftMULDIVleftINTEGERNUMBERleftFLOATNUMBERleftTRUEFALSEleftIDrightASSIGNleftERRORAND ASSIGN BOOLEAN COLON COMMA DIV ELSE ELSEIF EQ ERROR FALSE FLOAT FLOATNUMBER FOR FUNCTION GE GT ID IF IN INTEGER INTEGERNUMBER LCB LE LRB LSB LT MAIN MOD MUL NE NOT ON OR PRINT RCB RETURN RRB RSB SEMICOLON SUB SUM TRUE WHERE WHILEprogram : declist MAIN LRB RRB block\n | MAIN LRB RRB blockdeclist : dec\n | declist decdec : vardec\n | funcdectype : INTEGER\n | FLOAT\n | BOOLEANiddec : lvalue\n | lvalue ASSIGN expidlist : iddec\n | idlist COMMA iddecvardec : idlist COLON type SEMICOLONfuncdec : FUNCTION ID LRB paramdecs RRB COLON type block\n | FUNCTION ID LRB paramdecs RRB blockparamdecs : paramdecslist\n | emptyparamdecslist : paramdec\n | paramdecslist COMMA paramdec paramdec : ID COLON type\n | ID LSB RSB COLON typeblock : LCB stmtlist RCBstmtlist : stmtlist stmt\n | emptylvalue : ID\n | ID LSB exp RSBcase : WHERE const COLON stmtlistcases : cases case\n | emptystmt : RETURN exp SEMICOLON\n | exp SEMICOLON\n | block\n | vardec\n | WHILE LRB exp RRB stmt\n | ON LRB exp RRB LCB cases RCB SEMICOLON\n | FOR LRB exp SEMICOLON exp SEMICOLON exp RRB stmt\n | FOR LRB ID IN ID RRB stmt\n | IF LRB exp RRB stmt elseiflist\n | IF LRB exp RRB stmt elseiflist ELSE stmt\n | PRINT LRB ID RRB SEMICOLONelseiflist : elseiflist ELSEIF LRB exp RRB stmt\n | emptyexp : lvalue ASSIGN exp\n | exp GT exp\n | exp LT exp\n | exp NE exp\n | exp EQ exp\n | exp LE exp\n | exp GE exp\n | exp AND exp\n | exp OR exp\n | exp SUM exp\n | exp SUB exp\n | exp MUL exp\n | exp DIV exp\n | exp MOD exp\n | const\n | lvalue\n | lvalue LRB explist RRB\n | LRB exp RRB\n | lvalue LRB RRB\n | SUB exp\n | NOT expconst : INTEGERNUMBER\n | FLOATNUMBER\n | TRUE\n | FALSEexplist : exp\n | explist COMMA expempty :' 10 | 11 | _lr_action_items = {'MAIN':([0,2,4,5,6,13,42,92,107,131,],[3,12,-3,-5,-6,-4,-14,-23,-16,-15,]),'FUNCTION':([0,2,4,5,6,13,42,92,107,131,],[8,8,-3,-5,-6,-4,-14,-23,-16,-15,]),'ID':([0,2,4,5,6,8,13,16,18,19,27,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,73,92,93,94,96,97,107,110,112,113,114,115,116,117,118,122,131,132,134,135,136,138,142,143,146,147,148,149,154,155,157,159,160,161,162,163,165,166,167,],[9,9,-3,-5,-6,17,-4,9,9,9,43,9,9,9,-71,-14,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,-25,43,-23,-24,9,-33,-34,-16,9,-32,9,9,126,9,128,9,-31,-15,9,9,141,9,-35,-71,-41,9,9,-39,-43,-38,9,-36,9,-40,9,-71,-37,9,9,-42,]),'$end':([1,40,67,92,],[0,-2,-1,-23,]),'LRB':([3,9,12,17,18,19,29,30,32,33,41,42,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,98,99,100,101,102,103,110,112,113,114,115,116,118,122,126,132,134,136,138,142,143,146,147,148,149,154,155,156,157,159,160,161,162,163,165,166,167,],[14,-26,20,27,32,32,63,32,32,32,-71,-14,-27,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,-25,-23,-24,32,-33,-34,113,114,115,116,117,63,32,-32,32,32,32,32,32,-31,-26,32,32,32,-35,-71,-41,32,32,-39,-43,-38,32,161,-36,32,-40,32,-71,-37,32,32,-42,]),'COLON':([7,9,10,11,26,29,31,34,35,36,37,38,43,48,64,66,72,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,91,103,105,109,129,158,],[15,-26,-12,-10,-13,-59,-58,-65,-66,-67,-68,-11,70,-27,-63,-64,106,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,-62,-61,-10,119,-60,-11,162,]),'COMMA':([7,9,10,11,23,24,25,26,29,31,34,35,36,37,38,45,47,48,64,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,103,104,108,109,121,129,130,],[16,-26,-12,-10,-7,-8,-9,-13,-59,-58,-65,-66,-67,-68,-11,73,-19,-27,-63,-64,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,110,-62,-69,-61,-10,-21,-20,-60,-70,-11,-22,]),'ASSIGN':([9,11,29,48,103,126,],[-26,19,62,-27,118,-26,]),'RSB':([9,28,29,31,34,35,36,37,48,64,66,71,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,91,109,],[-26,48,-59,-58,-65,-66,-67,-68,-27,-63,-64,105,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,-62,-61,-60,]),'GT':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,49,-59,-58,-65,-66,-67,-68,49,-27,-63,49,49,-45,-46,-47,-48,-49,-50,49,49,-53,-54,-55,-56,-57,-44,-62,49,-61,49,-59,-60,49,49,49,49,49,-26,49,-44,49,49,49,]),'LT':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,50,-59,-58,-65,-66,-67,-68,50,-27,-63,50,50,-45,-46,-47,-48,-49,-50,50,50,-53,-54,-55,-56,-57,-44,-62,50,-61,50,-59,-60,50,50,50,50,50,-26,50,-44,50,50,50,]),'NE':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,51,-59,-58,-65,-66,-67,-68,51,-27,-63,51,51,-45,-46,-47,-48,-49,-50,51,51,-53,-54,-55,-56,-57,-44,-62,51,-61,51,-59,-60,51,51,51,51,51,-26,51,-44,51,51,51,]),'EQ':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,52,-59,-58,-65,-66,-67,-68,52,-27,-63,52,52,-45,-46,-47,-48,-49,-50,52,52,-53,-54,-55,-56,-57,-44,-62,52,-61,52,-59,-60,52,52,52,52,52,-26,52,-44,52,52,52,]),'LE':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,53,-59,-58,-65,-66,-67,-68,53,-27,-63,53,53,-45,-46,-47,-48,-49,-50,53,53,-53,-54,-55,-56,-57,-44,-62,53,-61,53,-59,-60,53,53,53,53,53,-26,53,-44,53,53,53,]),'GE':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,54,-59,-58,-65,-66,-67,-68,54,-27,-63,54,54,-45,-46,-47,-48,-49,-50,54,54,-53,-54,-55,-56,-57,-44,-62,54,-61,54,-59,-60,54,54,54,54,54,-26,54,-44,54,54,54,]),'AND':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,55,-59,-58,-65,-66,-67,-68,55,-27,-63,55,-64,-45,-46,-47,-48,-49,-50,-51,55,-53,-54,-55,-56,-57,-44,-62,55,-61,55,-59,-60,55,55,55,55,55,-26,55,-44,55,55,55,]),'OR':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,56,-59,-58,-65,-66,-67,-68,56,-27,-63,56,-64,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,-62,56,-61,56,-59,-60,56,56,56,56,56,-26,56,-44,56,56,56,]),'SUM':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,57,-59,-58,-65,-66,-67,-68,57,-27,-63,57,57,57,57,57,57,57,57,57,57,-53,-54,-55,-56,57,-44,-62,57,-61,57,-59,-60,57,57,57,57,57,-26,57,-44,57,57,57,]),'SUB':([9,18,19,28,29,30,31,32,33,34,35,36,37,38,41,42,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,68,69,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,92,93,94,95,96,97,103,109,110,111,112,113,114,115,116,118,121,122,123,124,125,126,127,129,132,134,136,138,140,142,143,146,147,148,149,153,154,155,157,159,160,161,162,163,164,165,166,167,],[-26,30,30,58,-59,30,-58,30,30,-65,-66,-67,-68,58,-71,-14,-27,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,-63,58,58,30,-25,58,58,58,58,58,58,58,58,-53,-54,-55,-56,58,-44,-62,58,-61,-23,-24,30,58,-33,-34,-59,-60,30,58,-32,30,30,30,30,30,58,-31,58,58,58,-26,58,-44,30,30,30,-35,58,-71,-41,30,30,-39,-43,58,-38,30,-36,30,-40,30,-71,-37,58,30,30,-42,]),'MUL':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,59,-59,-58,-65,-66,-67,-68,59,-27,59,59,59,59,59,59,59,59,59,59,59,59,59,-55,-56,59,-44,-62,59,-61,59,-59,-60,59,59,59,59,59,-26,59,-44,59,59,59,]),'DIV':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,60,-59,-58,-65,-66,-67,-68,60,-27,60,60,60,60,60,60,60,60,60,60,60,60,60,-55,-56,60,-44,-62,60,-61,60,-59,-60,60,60,60,60,60,-26,60,-44,60,60,60,]),'MOD':([9,28,29,31,34,35,36,37,38,48,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,95,103,109,111,121,123,124,125,126,127,129,140,153,164,],[-26,61,-59,-58,-65,-66,-67,-68,61,-27,-63,61,61,61,61,61,61,61,61,61,61,-53,-54,-55,-56,-57,-44,-62,61,-61,61,-59,-60,61,61,61,61,61,-26,61,-44,61,61,61,]),'RRB':([9,14,20,23,24,25,27,29,31,34,35,36,37,44,45,46,47,48,63,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,104,108,109,121,123,124,127,128,130,141,153,164,],[-26,21,39,-7,-8,-9,-71,-59,-58,-65,-66,-67,-68,72,-17,-18,-19,-27,89,-63,91,-64,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,109,-62,-69,-61,-21,-20,-60,-70,132,133,136,137,-22,147,159,166,]),'SEMICOLON':([9,22,23,24,25,29,31,34,35,36,37,48,64,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,91,95,103,109,111,125,126,129,137,140,150,],[-26,42,-7,-8,-9,-59,-58,-65,-66,-67,-68,-27,-63,-64,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-44,-62,-61,112,-59,-60,122,134,-26,-44,143,146,157,]),'LSB':([9,43,126,],[18,71,18,]),'INTEGER':([15,70,106,119,],[23,23,23,23,]),'FLOAT':([15,70,106,119,],[24,24,24,24,]),'BOOLEAN':([15,70,106,119,],[25,25,25,25,]),'NOT':([18,19,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,110,112,113,114,115,116,118,122,132,134,136,138,142,143,146,147,148,149,154,155,157,159,160,161,162,163,165,166,167,],[33,33,33,33,33,-71,-14,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,-25,-23,-24,33,-33,-34,33,-32,33,33,33,33,33,-31,33,33,33,-35,-71,-41,33,33,-39,-43,-38,33,-36,33,-40,33,-71,-37,33,33,-42,]),'INTEGERNUMBER':([18,19,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,110,112,113,114,115,116,118,122,132,134,136,138,142,143,146,147,148,149,152,154,155,157,159,160,161,162,163,165,166,167,],[34,34,34,34,34,-71,-14,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,-25,-23,-24,34,-33,-34,34,-32,34,34,34,34,34,-31,34,34,34,-35,-71,-41,34,34,-39,-43,34,-38,34,-36,34,-40,34,-71,-37,34,34,-42,]),'FLOATNUMBER':([18,19,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,110,112,113,114,115,116,118,122,132,134,136,138,142,143,146,147,148,149,152,154,155,157,159,160,161,162,163,165,166,167,],[35,35,35,35,35,-71,-14,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,-25,-23,-24,35,-33,-34,35,-32,35,35,35,35,35,-31,35,35,35,-35,-71,-41,35,35,-39,-43,35,-38,35,-36,35,-40,35,-71,-37,35,35,-42,]),'TRUE':([18,19,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,110,112,113,114,115,116,118,122,132,134,136,138,142,143,146,147,148,149,152,154,155,157,159,160,161,162,163,165,166,167,],[36,36,36,36,36,-71,-14,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,-25,-23,-24,36,-33,-34,36,-32,36,36,36,36,36,-31,36,36,36,-35,-71,-41,36,36,-39,-43,36,-38,36,-36,36,-40,36,-71,-37,36,36,-42,]),'FALSE':([18,19,30,32,33,41,42,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,69,92,93,94,96,97,110,112,113,114,115,116,118,122,132,134,136,138,142,143,146,147,148,149,152,154,155,157,159,160,161,162,163,165,166,167,],[37,37,37,37,37,-71,-14,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,-25,-23,-24,37,-33,-34,37,-32,37,37,37,37,37,-31,37,37,37,-35,-71,-41,37,37,-39,-43,37,-38,37,-36,37,-40,37,-71,-37,37,37,-42,]),'LCB':([21,23,24,25,39,41,42,68,69,72,92,93,96,97,112,120,122,132,133,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[41,-7,-8,-9,41,-71,-14,41,-25,41,-23,-24,-33,-34,-32,41,-31,41,139,41,-35,-71,-41,41,-39,-43,-38,41,-36,41,-40,-71,-37,41,41,-42,]),'RCB':([41,42,68,69,92,93,96,97,112,122,138,139,142,143,144,145,148,149,151,154,157,160,162,163,165,167,],[-71,-14,92,-25,-23,-24,-33,-34,-32,-31,-35,-71,-71,-41,150,-30,-39,-43,-29,-38,-36,-40,-71,-37,-28,-42,]),'RETURN':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,94,-25,-23,-24,-33,-34,-32,-31,94,94,-35,-71,-41,94,-39,-43,-38,94,-36,94,-40,-71,-37,94,94,-42,]),'WHILE':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,98,-25,-23,-24,-33,-34,-32,-31,98,98,-35,-71,-41,98,-39,-43,-38,98,-36,98,-40,-71,-37,98,98,-42,]),'ON':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,99,-25,-23,-24,-33,-34,-32,-31,99,99,-35,-71,-41,99,-39,-43,-38,99,-36,99,-40,-71,-37,99,99,-42,]),'FOR':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,100,-25,-23,-24,-33,-34,-32,-31,100,100,-35,-71,-41,100,-39,-43,-38,100,-36,100,-40,-71,-37,100,100,-42,]),'IF':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,101,-25,-23,-24,-33,-34,-32,-31,101,101,-35,-71,-41,101,-39,-43,-38,101,-36,101,-40,-71,-37,101,101,-42,]),'PRINT':([41,42,68,69,92,93,96,97,112,122,132,136,138,142,143,147,148,149,154,155,157,159,160,162,163,165,166,167,],[-71,-14,102,-25,-23,-24,-33,-34,-32,-31,102,102,-35,-71,-41,102,-39,-43,-38,102,-36,102,-40,-71,-37,102,102,-42,]),'ELSE':([42,92,96,97,112,122,138,142,143,148,149,154,157,160,163,167,],[-14,-23,-33,-34,-32,-31,-35,-71,-41,155,-43,-38,-36,-40,-37,-42,]),'ELSEIF':([42,92,96,97,112,122,138,142,143,148,149,154,157,160,163,167,],[-14,-23,-33,-34,-32,-31,-35,-71,-41,156,-43,-38,-36,-40,-37,-42,]),'WHERE':([42,69,92,93,96,97,112,122,138,139,142,143,144,145,148,149,151,154,157,160,162,163,165,167,],[-14,-25,-23,-24,-33,-34,-32,-31,-35,-71,-71,-41,152,-30,-39,-43,-29,-38,-36,-40,-71,-37,-28,-42,]),'IN':([126,],[135,]),} 12 | 13 | _lr_action = {} 14 | for _k, _v in _lr_action_items.items(): 15 | for _x,_y in zip(_v[0],_v[1]): 16 | if not _x in _lr_action: _lr_action[_x] = {} 17 | _lr_action[_x][_k] = _y 18 | del _lr_action_items 19 | 20 | _lr_goto_items = {'program':([0,],[1,]),'declist':([0,],[2,]),'dec':([0,2,],[4,13,]),'vardec':([0,2,68,132,136,147,155,159,165,166,],[5,5,97,97,97,97,97,97,97,97,]),'funcdec':([0,2,],[6,6,]),'idlist':([0,2,68,132,136,147,155,159,165,166,],[7,7,7,7,7,7,7,7,7,7,]),'iddec':([0,2,16,68,132,136,147,155,159,165,166,],[10,10,26,10,10,10,10,10,10,10,10,]),'lvalue':([0,2,16,18,19,30,32,33,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,94,110,113,114,115,116,118,132,134,136,146,147,155,159,161,165,166,],[11,11,11,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,103,29,29,29,29,29,29,29,103,29,103,29,103,103,103,29,103,103,]),'type':([15,70,106,119,],[22,104,120,130,]),'exp':([18,19,30,32,33,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,94,110,113,114,115,116,118,132,134,136,146,147,155,159,161,165,166,],[28,38,64,65,66,74,75,76,77,78,79,80,81,82,83,84,85,86,87,90,95,111,121,123,124,125,127,129,95,140,95,153,95,95,95,164,95,95,]),'const':([18,19,30,32,33,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,68,94,110,113,114,115,116,118,132,134,136,146,147,152,155,159,161,165,166,],[31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,158,31,31,31,31,31,]),'block':([21,39,68,72,120,132,136,147,155,159,165,166,],[40,67,96,107,131,96,96,96,96,96,96,96,]),'paramdecs':([27,],[44,]),'paramdecslist':([27,],[45,]),'empty':([27,41,139,142,162,],[46,69,145,149,69,]),'paramdec':([27,73,],[47,108,]),'stmtlist':([41,162,],[68,165,]),'explist':([63,],[88,]),'stmt':([68,132,136,147,155,159,165,166,],[93,138,142,154,160,163,93,167,]),'cases':([139,],[144,]),'elseiflist':([142,],[148,]),'case':([144,],[151,]),} 21 | 22 | _lr_goto = {} 23 | for _k, _v in _lr_goto_items.items(): 24 | for _x, _y in zip(_v[0], _v[1]): 25 | if not _x in _lr_goto: _lr_goto[_x] = {} 26 | _lr_goto[_x][_k] = _y 27 | del _lr_goto_items 28 | _lr_productions = [ 29 | ("S' -> program","S'",1,None,None,None), 30 | ('program -> declist MAIN LRB RRB block','program',5,'p_program','parser.py',65), 31 | ('program -> MAIN LRB RRB block','program',4,'p_program','parser.py',66), 32 | ('declist -> dec','declist',1,'p_declist','parser.py',70), 33 | ('declist -> declist dec','declist',2,'p_declist','parser.py',71), 34 | ('dec -> vardec','dec',1,'p_dec','parser.py',75), 35 | ('dec -> funcdec','dec',1,'p_dec','parser.py',76), 36 | ('type -> INTEGER','type',1,'p_type','parser.py',81), 37 | ('type -> FLOAT','type',1,'p_type','parser.py',82), 38 | ('type -> BOOLEAN','type',1,'p_type','parser.py',83), 39 | ('iddec -> lvalue','iddec',1,'p_iddec','parser.py',87), 40 | ('iddec -> lvalue ASSIGN exp','iddec',3,'p_iddec','parser.py',88), 41 | ('idlist -> iddec','idlist',1,'p_idlist','parser.py',92), 42 | ('idlist -> idlist COMMA iddec','idlist',3,'p_idlist','parser.py',93), 43 | ('vardec -> idlist COLON type SEMICOLON','vardec',4,'p_vardec','parser.py',97), 44 | ('funcdec -> FUNCTION ID LRB paramdecs RRB COLON type block','funcdec',8,'p_funcdec','parser.py',101), 45 | ('funcdec -> FUNCTION ID LRB paramdecs RRB block','funcdec',6,'p_funcdec','parser.py',102), 46 | ('paramdecs -> paramdecslist','paramdecs',1,'p_paramdecs','parser.py',106), 47 | ('paramdecs -> empty','paramdecs',1,'p_paramdecs','parser.py',107), 48 | ('paramdecslist -> paramdec','paramdecslist',1,'p_paramdecslist','parser.py',111), 49 | ('paramdecslist -> paramdecslist COMMA paramdec','paramdecslist',3,'p_paramdecslist','parser.py',112), 50 | ('paramdec -> ID COLON type','paramdec',3,'p_paramdec','parser.py',116), 51 | ('paramdec -> ID LSB RSB COLON type','paramdec',5,'p_paramdec','parser.py',117), 52 | ('block -> LCB stmtlist RCB','block',3,'p_block','parser.py',121), 53 | ('stmtlist -> stmtlist stmt','stmtlist',2,'p_stmtlist','parser.py',125), 54 | ('stmtlist -> empty','stmtlist',1,'p_stmtlist','parser.py',126), 55 | ('lvalue -> ID','lvalue',1,'p_lvalue','parser.py',130), 56 | ('lvalue -> ID LSB exp RSB','lvalue',4,'p_lvalue','parser.py',131), 57 | ('case -> WHERE const COLON stmtlist','case',4,'p_case','parser.py',135), 58 | ('cases -> cases case','cases',2,'p_cases','parser.py',139), 59 | ('cases -> empty','cases',1,'p_cases','parser.py',140), 60 | ('stmt -> RETURN exp SEMICOLON','stmt',3,'p_stmt','parser.py',144), 61 | ('stmt -> exp SEMICOLON','stmt',2,'p_stmt','parser.py',145), 62 | ('stmt -> block','stmt',1,'p_stmt','parser.py',146), 63 | ('stmt -> vardec','stmt',1,'p_stmt','parser.py',147), 64 | ('stmt -> WHILE LRB exp RRB stmt','stmt',5,'p_stmt','parser.py',148), 65 | ('stmt -> ON LRB exp RRB LCB cases RCB SEMICOLON','stmt',8,'p_stmt','parser.py',149), 66 | ('stmt -> FOR LRB exp SEMICOLON exp SEMICOLON exp RRB stmt','stmt',9,'p_stmt','parser.py',150), 67 | ('stmt -> FOR LRB ID IN ID RRB stmt','stmt',7,'p_stmt','parser.py',151), 68 | ('stmt -> IF LRB exp RRB stmt elseiflist','stmt',6,'p_stmt','parser.py',152), 69 | ('stmt -> IF LRB exp RRB stmt elseiflist ELSE stmt','stmt',8,'p_stmt','parser.py',153), 70 | ('stmt -> PRINT LRB ID RRB SEMICOLON','stmt',5,'p_stmt','parser.py',154), 71 | ('elseiflist -> elseiflist ELSEIF LRB exp RRB stmt','elseiflist',6,'p_elseiflist','parser.py',159), 72 | ('elseiflist -> empty','elseiflist',1,'p_elseiflist','parser.py',160), 73 | ('exp -> lvalue ASSIGN exp','exp',3,'p_exp','parser.py',164), 74 | ('exp -> exp GT exp','exp',3,'p_exp','parser.py',165), 75 | ('exp -> exp LT exp','exp',3,'p_exp','parser.py',166), 76 | ('exp -> exp NE exp','exp',3,'p_exp','parser.py',167), 77 | ('exp -> exp EQ exp','exp',3,'p_exp','parser.py',168), 78 | ('exp -> exp LE exp','exp',3,'p_exp','parser.py',169), 79 | ('exp -> exp GE exp','exp',3,'p_exp','parser.py',170), 80 | ('exp -> exp AND exp','exp',3,'p_exp','parser.py',171), 81 | ('exp -> exp OR exp','exp',3,'p_exp','parser.py',172), 82 | ('exp -> exp SUM exp','exp',3,'p_exp','parser.py',173), 83 | ('exp -> exp SUB exp','exp',3,'p_exp','parser.py',174), 84 | ('exp -> exp MUL exp','exp',3,'p_exp','parser.py',175), 85 | ('exp -> exp DIV exp','exp',3,'p_exp','parser.py',176), 86 | ('exp -> exp MOD exp','exp',3,'p_exp','parser.py',177), 87 | ('exp -> const','exp',1,'p_exp','parser.py',178), 88 | ('exp -> lvalue','exp',1,'p_exp','parser.py',179), 89 | ('exp -> lvalue LRB explist RRB','exp',4,'p_exp','parser.py',180), 90 | ('exp -> LRB exp RRB','exp',3,'p_exp','parser.py',181), 91 | ('exp -> lvalue LRB RRB','exp',3,'p_exp','parser.py',182), 92 | ('exp -> SUB exp','exp',2,'p_exp','parser.py',183), 93 | ('exp -> NOT exp','exp',2,'p_exp','parser.py',184), 94 | ('const -> INTEGERNUMBER','const',1,'p_const','parser.py',189), 95 | ('const -> FLOATNUMBER','const',1,'p_const','parser.py',190), 96 | ('const -> TRUE','const',1,'p_const','parser.py',191), 97 | ('const -> FALSE','const',1,'p_const','parser.py',192), 98 | ('explist -> exp','explist',1,'p_explist','parser.py',196), 99 | ('explist -> explist COMMA exp','explist',3,'p_explist','parser.py',197), 100 | ('empty -> ','empty',0,'p_empty','parser.py',201), 101 | ] 102 | --------------------------------------------------------------------------------