The Evaluator Back End
The MathPaper back end, which we’ll call Evaluator, is a program that reads a stream of mathematical expressions and displays the result of evaluating them. If you give the back end the following input, line by line:
1+2*3+4 2+5*sin(3) 9/4 3+ (8-76+32) / 3.2
it will return this output:
11 2.7056 2.25 Syntax Error -11.25
The Evaluator will write its output directly to standard output, and we’ll demonstrate it in a Terminal window. Later, when we run the Evaluator as a subprocess from MathPaper, the Evaluator’s standard output will be returned to the MathPaper application, which will, in turn, display the contents in an on-screen window.
In the rest of this section and the next section, we’ll discuss how to build the Evaluator back end. These sections use hardcore Unix development tools that are not essential to understanding Cocoa programming, and you can skip them if you want to download the source code from our web site ( http://www.oreilly.com/catalog/buildcocoa/). You can also download a working copy of the Evaluator program from our web site. However, we recommend that you follow the steps in the next section, even if you don’t fully understand what’s going on. All you really have to know to continue with MathPaper is that the Evaluator will perform the actual calculations for MathPaper and that it will run as a separate Unix process. So, if you plan to just download the source files, you can skip ahead to Section 10.4.
The task of the Evaluator back end ...
Get Building Cocoa Applications: A Step by Step Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.