Is there a math parser for petitparser?

半世苍凉 提交于 2019-12-11 11:58:22

问题


is there a dart lib that can parse math strings such as (3+4)/4.5? I tried to build a basic parser with petitparser, but I am in over my head and its just trial and error right now :) Is there an petitparser (Dart or any other language) implementation of a simple math parser somewhere?


回答1:


The introductory tutorial of PetitParser for Dart explains building a simple expression grammar in the section "Writing a More Complicated Grammar".

There is a more complicated expression grammar in the test suite of PetitParser for Dart, that can help you get started.

The Smalltalk implementation of PetitParser has even more examples. Also it includes a factory object that helps you building expression grammars. Unfortunately this code hasn't been ported yet.

Update: As of version 1.1.0 PetitParser includes a factory for building expression grammars.



来源:https://stackoverflow.com/questions/18924498/is-there-a-math-parser-for-petitparser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!