KlausSchaefers / quant-ux

Quant-UX - Prototype, Test and Learn
GNU General Public License v3.0
1.91k stars 195 forks source link

Feature: complete parser for data-binding #103

Open Equilibrier opened 2 years ago

Equilibrier commented 2 years ago

Currently, it seems I cannot use some expressions like this (in "camerea image"): categories["legume"].img (but categories.legume.img works, although instead of "legume" you would want to bring an abstract expression, so the [] should work too) or neither this _categories[pages.prod_categories.pages[pages.prodcategories.cpage][0]].img

So the data structure I have is this: image

I assume QuantUX has a very plain parser, parsing only arrays and simple key references, with no multi-level referencing and so on. It would be extremely useful if it could do complex expressions in here, it would considerably simplify the logic you have to bring into the <> (script) components.

PS: I'm developing a pretty complex prototype, with multi-language support and multiple-demos available for different clients, with dynamic images and UI texts, with complete functionality over the app-state, which I'm trying to store it in the data-binding system of QuantUX. So my observations could be the thing that is left QuantUX to become maybe (I would personally think) the most powerful prototyping software out there. And I can think it is kind of 95% already complete on that road, as it has the main killing features already in it, it's outstanding...

KlausSchaefers commented 2 years ago

The data-binding in Quant-UX is rather simple. It's simple JSON paths, not expressions. You can see the limitations in here:

https://github.com/KlausSchaefers/quant-ux/blob/master/src/core/JSONPath.js

For more advanced expressions, I have just introduced the scripts. In there you have all the freedom of JS.

Equilibrier commented 2 years ago

Shuntyard algorithm could be used for this, I think: https://youtu.be/Wz85Hiwi5MY Implemented this once, and it provided the possibility to parse very complicated (oneline) math expressions, with a very simple logic, with no lexical&syntactical analyzers, very simple abstract-semantic-tree built intuitively with recursion. If sometimes I will have the time, I will gladly help you on this, but unfortunately this period, this year, I can't. Sorry for this. Maybe someone will follow with support until then... ! Hopefully !