Evaluate

by Yota
Evaluate
An expression parser that supplies reusable machines, similar to Regex. [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Yota.Evaluate##version=4

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Yota.Evaluate##version=4

91 downloads
Version 5
Date added: Oct 21 2006
Last updated: Mar 2 2011
1 fan

[Extras] [Bonus features]

This evaluation library is intended for games that have to reuse a single expression many times with changing variables.

Full documentation is included. (Unless I forgot something.)

Operations supported:
( ) ?: + - * ** / \ % & | ^ ~ ! && || < > = == != <= >= d e (Multiplication may be implicit.)
'd' is a dice roll operator, 'e' is a scientific notation operator.
= is the same as ==.

There are a number of basic functions pre-packaged with the library, and you can add your own.

So in closing, please report any and all bugs or problems on the forum. Thank you!


A quick example of the Evaluate procedures in code.

var/expr = expr_Parse("(\[strength]+\[weaponBonus]+3d6)*\[pi]") // Parse the expression.
expr = expr_Optimize(expr, commonVars) // Optimize the expression.
return expr_Evaluate(expr, myVars) // Evaluate the expression.

var/expr = expr_ParseOptimize("...", commonVars) // Shorthand procedures.

return expr_ParseEvaluate("...", myVars) // Evaluate a one-time expression.


Each of these procedures have multiple types of return values, so I highly suggest you read through EvaluateHelp.htm (included) before you implement anything so you don't get caught off guard.