SimplyExpress New Mini Parser

Recently, I've been feeling like my C# skills have been slipping. So, I decided to implement a very "computer science-y" library. It's very simple and I've been trying to implement it for about 2 years now. Now has just been the only time where I could think straight and figure it out it seems like.

But, basically it's probably pretty close to being an operator-precedence parser. My reason for making it is that I have some beginning source code to a scripting engine lying around, but I never could get expression parsing such as x=5+10 implemented in a clean way.

Well, now I have it implemented. What it does is takes a stream of tokens. These tokens have either operations or values tied to them. SimplyExpress will tie all of these into a tree. And then, using given operator precedence and associativity values, it will reduce the tree 1 operation at a time. The tree is reduced by condensing a value(s) and an operation into just one value.

I wouldn't consider it advanced, but it does the hard part of parsing into a tree and then reducing that tree into a series of instructions with appropriate values. I'm also sure it's not too fast. I see some obvious ways to optimize it, but I just wanted a programming exercise :)

Anyway, this will probably part of another project I build, so I won't bother putting it into SVN. Here is a pastebin of the BSD licensed code though:

Posted: 6/14/2012 1:35:48 AM