Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This provides a bunch of improvements to expressions.
The most visible difference is that expression input fields are now displayed as multiline:
![image](https://private-user-images.githubusercontent.com/1327476/332585505-621a71dc-585e-48fd-b5de-acda6632815c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTE1MTUsIm5iZiI6MTczOTUxMTIxNSwicGF0aCI6Ii8xMzI3NDc2LzMzMjU4NTUwNS02MjFhNzFkYy01ODVlLTQ4ZmQtYjVkZS1hY2RhNjYzMjgxNWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDUzMzM1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmVjODJhNWRkY2Y1NDMyODg3ZTA1OTZkZjc0ODA5OGMzODdhMWMzNzlhOWZlMGQ4ZDBkYmM1M2Y4ZTY1NzM0MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.U-7xwjaLO2YqIcr9BbCiMOVlfR4feSsClJIjr-wWR_Q)
Expression input fields will now validate their expression in the ui, and will show as red when it failed to parse (execution is not tested)
Additionally, to make this more friendly, it includes some new syntax:
//
and/* ... */
return
is a supported operation. Not exactly useful right now, but this can be nice to make an expression more readable in what the output value isa = 1 ; return a + 2
is now valid and will compute a value of3
. The values of these are not persisted outside of the execution the expression.+=
, and++
Combine all of these, and you can now break up long complex expressions into multiple stages, with comments and intermediary variables.
The value of the last statement is taken as the output. eg
10 20 30
is 3 statements, and the result will be30
.The statement parsing isn't perfect js, the parser is allowing multiple statements on a single line separated by only a space. I worry that this could result in the parsing being more brittle, but I'm not sure if we should be worried about that.
Maybe next could be support for full if statements, or loops, but not as part of this PR.