reuse this parsertryself lex scan(get first token self goal(parse sentence except syntaxerrorprint('syntax error at column:'self lex startself lex showerror(except lexicalerrorprint('lexical error at column:'self lex startself lex showerror(except undefinederror as ename args[ print("'%sis undefined at column:nameself lex startself lex showerror(def goal(self)if self lex token in ['num''var''(']val self expr(self lex match('\ 'print(valelif self lex token ='set'self assign(self lex match('\ 'elseraise syntaxerror(def assign(self)self lex match('set'var self lex match('var'val self expr(self vars[varval expressionset commandassign name in dict def expr(self)left self factor(while trueif self lex token in ['\ '')']return left elif self lex token ='+'self lex scan(left left self factor(elif self lex token ='-'self lex scan(left left self factor(elseraise syntaxerror(def factor(self)left self term(while trueif self lex token in ['+''-''\ '')']return left elif self lex token ='*'self lex scan(left left self term(elif self lex token ='/' text and language