C#/ Python / Ruby的表达式求值器 [英] Expression evaluator for C#/Python/Ruby

查看:198
本文介绍了C#/ Python / Ruby的表达式求值器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有以下格式的半复杂表达式:

25 + [Variable1]> [Variable2]



我们需要一个表达式求值程序来解析表达式并使用回调来请求变量值,并计算出表达式的总体结果。它必须是一个回调,因为有数千个变量。



我们需要通常的数学运算符,但也需要if等等。语言越丰富。



我们可以使用我们想要的任何语言。任何人都有任何建议?

解决方案

查看 NCalc 。它是.NET,应该支持您的要求。


We have semi-complicated expressions in the format:
"25 + [Variable1] > [Variable2]"

We need an expression evaluator to parse the expression and use a callback to ask for the variable values and work out the overall result of the expression. It has to be a callback as there are thousands of variables.

We need the usual math operators but also things like "if" etc. The richer the language the better.

We can use any language we want. Anyone have any suggestions?

解决方案

Check out NCalc. It's .NET and should support your requirements.

这篇关于C#/ Python / Ruby的表达式求值器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆