数学解析器 [英] Math parser

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

问题描述

你好,


有没有人知道是否有一个库或一个示例项目可以使用数学表达式解析字符串中的字符串?


例如。 string math ="(23 + 48)^ 2 - (7.76 * 3.14)" ;;

解析器应​​该计算出这个结果。


Atm我有自己的解析器,但它只能处理非常简单的带有2个操作数的
表达式,例如。 (34 * 89),我试图扩展

功能,但它变得很丑陋(子串的负载)。


任何指针?


谢谢,


Janiek

Hello,

Does anyone know if there is a library or a sample project that can
parse strings with mathematical expressions inside ?

eg. string math = "(23 + 48) ^ 2 - (7.76 * 3.14)";
parser should calculate the result of this.

Atm I have my own parser, but it can only handle very simple
expressions with 2 operands eg. (34 * 89), I tried to expand the
functionality, but it''s getting ugly (loads of substrings).

Any pointers ?

Thanks,

Janiek

推荐答案




你应该能够在小组中找到一些东西

这是几乎所有计算机科学职业的作业:)


我通过数学解析器进行了搜索。在Google中找到了这个:
http: //www.c-sharpcorner.com/Code/20...hExpParser.asp


这是搜索的链接
http://groups.google。 com.my/groups?q...ublic.dotnet.*

干杯,


-

Ignacio Machin,

ignacio.machin at dot.state.fl.us

佛罗里达州交通局


" Janiek Buysrogge" < J。********* @ Televic.com>在留言中写道

新闻:2j ******************************** @ 4ax.com ...
Hi,

You should be able to find something in the groups
This is a homework in almost all computer sciences careers :)

I did a search by "math parser" in google and found this:
http://www.c-sharpcorner.com/Code/20...hExpParser.asp

this is the link of the search
http://groups.google.com.my/groups?q...ublic.dotnet.*
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Janiek Buysrogge" <J.*********@Televic.com> wrote in message
news:2j********************************@4ax.com...
你好,

有谁知道是否有一个库或一个示例项目可以解析内部带有数学表达式的字符串?

例如。 string math ="(23 + 48)^ 2 - (7.76 * 3.14)" ;;
解析器应该计算出它的结果。
我有自己的解析器,但它只能用2个操作数处理非常简单的表达式,例如。 (34 * 89),我试图扩展
功能,但它变得越来越难看(负载的子串)。

任何指针?

谢谢,

Janiek
Hello,

Does anyone know if there is a library or a sample project that can
parse strings with mathematical expressions inside ?

eg. string math = "(23 + 48) ^ 2 - (7.76 * 3.14)";
parser should calculate the result of this.

Atm I have my own parser, but it can only handle very simple
expressions with 2 operands eg. (34 * 89), I tried to expand the
functionality, but it''s getting ugly (loads of substrings).

Any pointers ?

Thanks,

Janiek



谢谢,链接非常有帮助。


Janiek


星期五,2005年10月28日09:25:50 -0400,Ignacio Machin \(.NET / C#MVP

\) < ignacio.machin AT dot.state.fl.us>写道:
Thank you, the links are very helpful.

Janiek

On Fri, 28 Oct 2005 09:25:50 -0400, "Ignacio Machin \( .NET/ C# MVP
\)" <ignacio.machin AT dot.state.fl.us> wrote:


你应该能够在小组中找到一些东西
这是几乎所有计算机科学职业的作业:)

我通过数学解析器进行了搜索。在Google中找到了这个:
http: //www.c-sharpcorner.com/Code/20...hExpParser.asp

这是搜索的链接
http://groups.google.com.my/小组?q ... ublic.dotnet。*

欢呼,
Hi,

You should be able to find something in the groups
This is a homework in almost all computer sciences careers :)

I did a search by "math parser" in google and found this:
http://www.c-sharpcorner.com/Code/20...hExpParser.asp

this is the link of the search
http://groups.google.com.my/groups?q...ublic.dotnet.*
cheers,






wouldn'最好先做数学然后把答案换成字符串吗?


double math = Math.Pow((23 + 48),2) - (7.76 * 3.14) ;

Console.WriteLine(Convert.ToString(math));

" Janiek Buysrogge"写道:
wouldn''t it just be best to do the math then convert the answer to string?

double math = Math.Pow((23 + 48) , 2) - (7.76 * 3.14);
Console.WriteLine (Convert.ToString(math));
"Janiek Buysrogge" wrote:
你好,

有没有人知道是否有一个库或一个示例项目可以解析内部带有数学表达式的字符串?

例如。 string math ="(23 + 48)^ 2 - (7.76 * 3.14)" ;;
解析器应该计算出它的结果。
我有自己的解析器,但它只能用2个操作数处理非常简单的表达式,例如。 (34 * 89),我试图扩展
功能,但它变得越来越难看(负载的子串)。

任何指针?

谢谢,

Janiek
Hello,

Does anyone know if there is a library or a sample project that can
parse strings with mathematical expressions inside ?

eg. string math = "(23 + 48) ^ 2 - (7.76 * 3.14)";
parser should calculate the result of this.

Atm I have my own parser, but it can only handle very simple
expressions with 2 operands eg. (34 * 89), I tried to expand the
functionality, but it''s getting ugly (loads of substrings).

Any pointers ?

Thanks,

Janiek



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

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