开源数学表达式解析器?

编程入门 行业动态 更新时间:2024-10-18 22:37:03
本文介绍了开源数学表达式解析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我GOOGLE了,来到空白 - 所以它的时间在SO再次测试好乡亲! :?)

I googled and came up blank - so it's time to test the good folks at SO again! :)

任何人都可以建议分析和计算数学表达式的开源库(PREF为.NET)

Can anyone recommend an open source library (pref for .NET) that parses and calculates mathematical expressions?

例如:输入表达式= 2 +(N-1)* 4,参数的键/值 N = 2 ,输出= 6 。

e.g. input expression = "2+(n-1)*4", parameter key/value n=2, output = 6.

推荐答案

我会看看的 NCalc 。下面是该项目的描述:

I would take a look at NCalc. Here is a description of the project:

NCalc在.NET中的数学表达式求值。 NCalc可以解析任何言论和评价结果,包括静态或动态参数和自定义函数。有关该技术的更多信息,我们用来建立这个框架,请阅读这篇文章:的http:// www.codeproject/KB/recipes/sota_expression_evaluator.aspx

NCalc is a mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions. For additional information on the technique we used to create this framework please read this article: www.codeproject/KB/recipes/sota_expression_evaluator.aspx

如果这是你的目的过于复杂,你可以看看在任何解析器生成为C#。这些工具允许您指定表达式的语法和生成的代码,将解析它。写作NUMERICA表达式解析器应该是相当简单的。例如,见

If this is too complex for your purpose, you can take a look at any "parser generator" for C#. These tools allow you to specify the grammar of your expression and generate code that will parse it. Writing parser for numerica expressions should be pretty straightforward. See for example

  • 的五分钟的介绍ANTLR
  • 您也可以尝试使用F#,这是这种伟大的语言的问题。结果例如见的 FsLex由克里斯·史密斯

更多推荐

开源数学表达式解析器?

本文发布于:2023-11-10 16:13:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575854.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   开源   数学

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!