Hi Will:
The expression parser is found in Chapter 2 of the book. It is a
numeric expression parser. This means that it parses and evaluates strings that contain numeric expressions, such as
(10 - 5) * 3
x = y / 17
w % 3
The parser can be used whenever you need to evaluate a numeric expression that is represented in its human-readable
string form. For example, you could use it as the basis for a calculator utility that you might build into a larger app. It can also be used to add a level of convenience to many numeric input chores. For example, consider an application that asks the user to enter the number of copies of a document to print. Normally, you would simply display a text field, wait for input, and then convert that text into its binary numeric format. This simple approach would allow the user to enter a value, such as 100. However, what if the user wanted to print 72 copies for each of 9 departments? The user would need to manually compute that product and then enter the value 648 into the text field. However, if you use the parser to compute the input obtained from the text field, then the user could enter 9*72, and no manual computation is required. The ability to parse and evaluate a numeric expression can add a sophisticated, professional feel to even the simplest application.
The parser also forms the backbone of the language interpreter found in Chapter 3.