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.