Skip to content
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

Computed expressions respect left-to-right associativity and operator precedence #1090

Merged
merged 13 commits into from
Jun 24, 2020

Conversation

sc1f
Copy link
Contributor

@sc1f sc1f commented Jun 18, 2020

This PR fixes #1072 by rewriting the expression parser to allow arbitary operator associativity without parentheses, as well as correct operator and function precedence: a + b * c ^ d / e, for example, evaluates to a + (b * ((c ^ d) / e)). This allows expressions to be much more complex and arbitrary than previously possible:

newcomputedexpressions

Changes

  • Expressions respect left to right associativity and operator precedence
  • Functions can have arbitary expressions inside them without additional parentheses
  • Expression editor no longer destroys already-rendered tokens when an error occurs - so text no longer moves under the cursor while typing
  • Adds parser + autocomplete tests
  • Adds invariant tests for the parser
  • Cleans and refactors the expression editor/parser

@sc1f sc1f added enhancement Feature requests or improvements JS labels Jun 18, 2020
Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@texodus
Copy link
Member

texodus commented Jun 24, 2020

Thanks for the PR!

@texodus texodus merged commit ae1dce8 into master Jun 24, 2020
@texodus texodus deleted the computed-fix branch June 24, 2020 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or improvements JS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expressions do not support associativity as expected
3 participants