用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3383|回复: 0
收起左侧

[Web] 数学表达式解析类【From PHPClass】

[复制链接]
发表于 2012-7-20 13:53:23 | 显示全部楼层 |阅读模式
本帖最后由 johnnywalkerzhu 于 2012-7-20 15:24 编辑

[原文介绍]
This package can parse, convert andevaluate math expressions.

There is a convertor class that can parse astring with a math expression with infix format (operators in the middle of theoperands) to postfix format (operators after operands), as well to expressiontree of objects.

An evaluator class can evaluate a mathexpression from a postfix string or expression or an expression tree ofobjects.

Currently the evaluation supports addition,subtraction, multiplication and division of integer operator numbers, as wellparenthesis to group expressions to be evaluated first.

翻译 】 随意随手而做,如有差错,概不负责
该类能够对数学表达式进行解析、转换以及求值操作;
首先是一个转换类能够将缀格式(即运算符号插在运算数字中间)呈现的数学表达式字符串解析为后缀格式表达式(运算符号在运算数字的后面),或是将运算对象以树形表达方式呈现;

求值类能可以为后缀型数学表达式或树形表达式进行求值操作;

当前版本支持对整数进行加减乘除的四则运算,并支持以括号方式进行优先运算;

【PHPClass链接地址】http://www.phpclasses.org/package/7589-PHP-Parse-convert-and-evaluate-math-expressions.html#groups


【演示地址】http://www.funsail.cn/phpClass/math_phaser/main.php



本版积分规则