Problem DescriptionThe previous assignment assumes its input includes spaces between every token in an expression, but many programmers tend not to use so many spaces, if the expression is unambiguous. For example, both of the following expressions would be considered to be equivalent: 1 + 2 * 3 1 + 2*3
If the expression on the right was provided as input to the first homework assignment, the lack of spaces would cause the Β2*3Β to be interpreted as a single token, so it would not perform any multiplication, and might not make any sense of the token at all.Of course, it is a simple concept to imagine adding functionality to take a full character string, and then to create a new version that has all the spaces included. However, that requires both the time to create that new version, but also the memory to hold it. Any programmer intending for maximal efficiency and minimal time should like to eliminate that extra step.In fact, the previous
homework itself had an intermediate step creating a new variable Β it took a single character string, and created a list of shorter character strings, and then used a subscript variable to visit each element of that list.This goal of this assignment is to eliminate all of those middle steps and to interpret the numeric expression directly from the original character string, without taking any time allocating new variables.Identifying TokensThe first phase of this project is to take the input string and divide it up into tokens (individual numbers and operators). The goal here is to let a caller ask for each token in turn and to supply it on demand.The simplest approach is one presented in a recitation assignment that only requires implementing a single function Β a generator that yields one token at a time as it finds it in the input string.Here is an intentionally incomplete illustration from the instructorΒs solution, as it stands at this time of writing:(in newsplit.py)