Is there a math parser for petitparser?

2019-08-04 09:51发布

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条回答
Melony?
2楼-- · 2019-08-04 10:22

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.

查看更多
登录 后发表回答