公式解析库C ++ [英] Equation Parsing Library C++

查看:134
本文介绍了公式解析库C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定某个地方一定有类似的东西,但是我似乎在这里或Google找不到任何有用的东西.我曾希望Boost可以有一些东西,但可惜没有.

I'm sure there must be something like this somewhere but I can't seem to find anything useful on here or Google. I had hoped Boost might have something but alas not.

我想要的是一个轻量级的库,它可以从用户那里获取一个字符串,例如"y=2x+3"并对其进行解析,以返回一个对象或函数,当给定x时该对象或函数将返回y.

What I'm after is a lightweight library that can take a string from the user, for example "y=2x+3" and parse it returning an object or function which returns y when given x.

有人可以为此推荐一些东西吗? (最糟糕的情况是我可以自己写一个,但毫无意义地重新发明轮子和所有东西.)

Can anybody recommend something for this? (Worst case I could write one myself but no point reinventing the wheel and all.)

必要时可以假定的事情

  • 预设变量名
  • 固定变量数

推荐答案

MuParser 是您所希望的为了.您甚至可以定义自定义运算符,以二进制形式存储和评估表达式,等等...用C ++编写,用于C和C#(甚至可能是其他语言)的绑定.

MuParser is all you ever could wish for. You can even define custom operators, store and evaluate the expressions in binary form, etc... Written in C++, bindings for C and C# (and maybe even other languages).

这篇关于公式解析库C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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