Article Preview
Buy Now
COLUMN
An RPN Interpreter
Installment Two
Issue: 6.1 (November/December 2007)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at
Article Description: No description available.
Article Length (in bytes): 15,837
Starting Page Number: 40
Article Number: 6117
Related Web Link(s):
http://www.declareSub.com/
Excerpt of article text...
In the last installment of this column, I presented a naive implementation of an RPN interpreter. Now, we rewrite that code. The goal is to decouple parsing and evaluation of the arithmetic expression, with an eye toward greater things. We begin with the evaluation of an RPN expression.
As discussed previously, reverse Polish notation (RPN), also called postfix notation, is a notation for writing mathematical expressions in which the operands for a function or operator precede the function. We can translate this more or less directly into REALbasic.
We introduce classes RPNOperator and RPNOperand to correspond to operators and operands, respectively. Since they are both pieces of an RPN expression, we define a superclass RPNToken from which they inherit.
...End of Excerpt. Please purchase the magazine to read the full article.