Skip to content

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

Merged
texodus merged 13 commits intomasterfrom
computed-fix
Jun 24, 2020
Merged

Computed expressions respect left-to-right associativity and operator precedence#1090
texodus merged 13 commits intomasterfrom
computed-fix

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

Development

Successfully merging this pull request may close these issues.

Expressions do not support associativity as expected

3 participants