str 'while self text[ixin string digitsstr +self text[ixix + if self text[ix='str +ix + while self text[ixin string digitsstr +self text[ixix + self token 'numself value float(strelseself token 'numself value int(strsubsumes long(in elif self text[ixin string ascii_lettersstr 'while self text[ixin (string digits string ascii_letters)str +self text[ixix + if str lower(='set'self token 'setelseself token 'varself value str elseraise lexicalerror(self next ix the parser module' class creates and embeds scanner for its lexical chores and handles interpretation of the expression grammar' rules and evaluation of the expression' resultas shown in example - example - pp \lang\parser\parser py ""###############################################################################the parser (syntax analyserevaluates during parse###############################################################################""class undefinederror(exception)pass from scanner import scannerlexicalerrorsyntaxerror class parserdef __init__(selftext='')self lex scanner(textself vars {'pi' def parse(self*text)if textembed scanner add variable main entry-point custom language parsers