goxiaoy / flutter_survey_js

Flutter client library for parsing and display surveyjs.io survey
https://goxiaoy.github.io/flutter_survey_js/
MIT License
16 stars 17 forks source link

Support for expression #90

Closed goxiaoy closed 1 year ago

goxiaoy commented 1 year ago

The surveyjs javascript use pegjs to parse expression, and use condition runner to provide logic features

original codes : https://github.com/surveyjs/survey-library/tree/master/src/expressions https://github.com/surveyjs/survey-library/blob/master/src/conditions.ts https://github.com/surveyjs/survey-library/blob/master/src/conditionsParser.ts https://github.com/surveyjs/survey-library/blob/master/src/conditionProcessValue.ts

Paths to achieve this Index Path Desc Implement difficulty Maintain difficulty
1 Fully rewrite with dart 💪 ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐
2 Use js engine in dart Build tools to convert original js codes to single file. and run as js in dart ⭐⭐⭐⭐ ⭐⭐
3 Rewrite with antlr4 rewrite expression parser with antlr4, ⭐⭐⭐⭐ ⭐⭐⭐
4 Use WebAssembly (WASM) compile js into WASM and embed it into Flutter Unknown Unknown
laogao commented 1 year ago

Is it possible to take advantage of existing dart parsers out there such as https://pub.dev/packages/expressions or something more fundamental like https://pub.dev/packages/petitparser ?

goxiaoy commented 1 year ago

@laogao Thanks for your reference. We need more time to investigate those packages, and they might help us to reduce the implementation and maintainance difficulty of path 1

ChopinDavid commented 1 year ago

I've researched PEG a bit. petitparser came up during my research. From my investigation, there didn't seem to be many good dart PEG parsers. But finding one would make implementing conditions pretty seamless.

goxiaoy commented 1 year ago

implemented with js engine. would close via 3b6eb9a8274a16876dfcdac3ad6e4254f20b97ee