-
Notifications
You must be signed in to change notification settings - Fork 6
feat: implement support for operator precedence #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…stead of extending them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, but main concern is if the breaking changes are really necessary?
…o lowest precedence
…nts.ts` to `regexps.ts`
Ok I've thought about it and I think it's best to go for the user friendly API (see #17 (comment)), I've now merged the So now there is only a breaking change in the |
…d more consistent
@lateapexearlyspeed I would love to hear your opinion on this PR improving operator support, since you've implemented a version of JSON Query in .Net. What do you think? |
@josdejong I agree to support operator precedence in json query language, the operators chain is easier to be used by user, thanks . Just personal opinion: I think all operators should support "chain", not only those "+-*/ and or ..." operators. It will give user max freedom to write as general program languages, for example user can also write The 'var arg' concept in specific operators is beneficial to json format and model only, it should not limit other operators' chain in language level, like Also I notice the pipe operator is defined with highest precedence now. I just feel it should be lowest precedence because it is used as result transition :) |
Thanks for your feedback, very helpful! I'm glad you see this as a valuable improvement too :) About chaining support: I have been thinking about this. Thing is, for operators like Pipe operator precedence: wow, you're right, it should be lowest indeed. Thanks for spotting this. Fixed via 4a6ad69 |
Got your point now, thanks. |
# Conflicts: # README.md # reference/functions.md
@josdejong Just confirm: because |
That is correct, |
On a side note, some programming languages support |
Corresponding PR's: |
🎉 This PR is included in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #16
This is a work in progress to see where we end up when implementing full support for operators and operator precedence.
Changes
and
, andor
to support a variable number of arguments, likeand(true, true, true)
.Breaking changes
operators
option changes from an object like{ aboutEq: '~=', ... }
into an array with custom operators with name and precedence, like[{ name: 'aboutEq', op: '~=', at: '==', vararg: false, leftAssociative: true }, ...]
.To do
["add", 1, 2, 3]
. Makepipe
a regular operator.parse.test.json
andstringify.test.json
?