This project is read-only.
Project Description
Following project contains a class library with simple Reverse Polish Notation implementation.

I decide to write this RPN because of problems with other parsers on sharepoint sandbox solution. This class library contains nothing but c# code. No other external libraries are required. So sandbox famous exception like untrusted code etc shouldn't happen here. Currently library is under construction but RPN works and process simple expressions. Also custom function processing is available. I'm using this class as a part of core for KPI calculation.

How to use it:

RPN expressionPareser = new RPN();
expressionPareser.ProcessFunction = ProcessFunction; // <= delegate for custom function processing

// that delegate can be null when you dont wanna use custom function
resultDecimal = expressionPareser.Eval("3+(-4)*(521/3)-(CustomFunction(4)/3)");
Token result = expressionPareser.Eval("3+(-4)*(521/3)-(CustomFunction(4)/3)");

2013-02-21 Important changes!

Eval function returns not decimal but Token instance, so calculation value is stored into 'Content' property. Also support for multi-character operators has been added. So now you can use +- == >= operators. Token.cs file contains examples of operators implementation. Operators implementation now is fully OOP. StringTokenizer has been simplified, and now uses regular expressions.

Last edited Feb 21, 2013 at 8:14 AM by elpako, version 8