and it' another example of the object-oriented programming (oopcomposition relationship at workparsers embed and delegate to scanners the module in example - implements the lexical analysis task--detecting the expression' basic tokens by scanning the text string left to right on demand notice that this is all straightforward logicsuch analysis can sometimes be performed with regular expressions instead (described earlier)but the pattern needed to detect and extract tokens in this example would be too complex and fragile for my tastes if your tastes varytry recoding this module with re example - pp \lang\parser\scanner py ""##############################################################################the scanner (lexical analyser##############################################################################""import string class syntaxerror(exception)pass class lexicalerror(exception)pass local errors used to be strings class scannerdef __init__(selftext)self next self text text '\ def newtext(selftext)scanner __init__(selftextdef showerror(self)print('='self textprint('='(self start'^'def match(selftoken)if self token !tokenraise syntaxerror(tokenelsevalue self value if self token !'\ 'self scan(return value next token/value return prior value def scan(self)self value none ix self next while self text[ixin string whitespaceix + self start ix if self text[ixin ['('')''-''+''/''*''\ ']self token self text[ixix + text and language