Article Preview
Buy Now
COLUMN
An RPN Interpreter
"Hello World" For Compilers
Issue: 5.6 (September/October 2007)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at http://www.declareSub.com/
Article Description: No description available.
Article Length (in bytes): 16,774
Starting Page Number: 42
Article Number: 5616
Related Web Link(s):
http://www.declareSub.com/
Excerpt of article text...
Writing an RPN interpreter is a standard five-finger exercise for computer science students. We will see why in this and several subsequent columns. But, first, what is RPN?
RPN stands for "reverse Polish notation", and is a syntax for writing mathematical expressions involving operators. The usual form of a mathematical expression is in the form operand - operator - operand; 2 + 3, for example. This is called "infix" notation. In postfix notation, an expression is written in the form operator - operator - operand. In postfix, 2 + 3 is written as 2 3 +. An example of posfix with which you may be familiar is the factorial operator -- N!.
There is also prefix notation, in which the operator comes first: + 2 3. This is also called "Polish notation", in honor of the mathematician Jan Łukasiewicz. Prefix notation came before postfix, so postfix is known as reverse Polish notation, or RPN.
...End of Excerpt. Please purchase the magazine to read the full article.