Question: python code: Given the lexical analyzer implemented in assignment #1, add the parsing code using PLY to recognize the following grammar rules: ( begin{array}{ll}text {

python code:


Given the lexical analyzer implemented in assignment \#1, add the parsing code using PLY to recognize the following grammar rules: \( \begin{array}{ll}\text { block } & \text { BLOCK ID ASSIGN LPARENTH attributes RPARENTH } \\ & \text { ADD ID ASSIGN LPARENTH new_atts RPARENTH } \\ & \text { PRINT ID } \\ & \text { RUN ID } \\ & \text { MINE ID } \\ \text { IXPORT ID } \\ \text { | } & \text { VIEW ID }\end{array} \) type STR | INT | LONG I FLOAT | LIST I TUPLE DICT attribute ID TYPEASSIGN type attributes > attribute lattributes SEPARATOR attribute new_att ID TYPEASSIGN STRING | ID TYPEASSIGN NUMBER new_atts new_att |new_aEts SEPARATOR new_att expr term expr expr PLUS term expr expr MINUS term term factor term term STAR factor term term SLASH factor term term PCT factor factor ID factor NUM factor LPAREN expr RPAREN factor factor LPAREN argsopt RPAREN test expr NE expr test expr LT expr test expr LE expr test expr GE expr test expr GT expr argsopt args argsopt args expr SEPARATOR args args expr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
