You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The REPL attempts to determine if a line continuation is needed to
create a valid formula. Today, it does this by using the Power Fx parser
and attempting to interpret the error messages, which turns out doesn't
work so well. It also isn't very smart about operators and doesn't
handle named formulas or UDFs.
For example, these would not continue:
- `IsMatch( "asdf", "(?x)` long regex best started on the next line
- `NamedFormula =` long named formula best started on the next line
- `Func( x: Number ): Text =` long udf, best started on the next line
- `1 + ` long operand, best started on the next line
The new logic is written by hand specifically to answer this
continuation question and does a much better job. It is always a best
guess and only determines when to send the formula to the parser/eval
loop - annoyance either being too conservative or liberal is all that
this controls. Even if a continuation is detected where there should not
be one, the user can always enter a blank line to conclude the
continuation. Not detecting a continuation will be annoying and should
result an issue being raised, but the user can always remove the extra
newline.
Yes, we'll need to add logic in two places if the parser changes
significantly, although that is not anticipated anytime soon. If this
becomes a burden long term, we can look at enhancing the mainline parser
to detect continuation situations, but at this point that feels like the
REPL tail wagging the Power Fx dog.
In the process of learning how identifiers were being parsed, I found
the error messages were very poor for an identifier parser error. I
didn't change the logic, just updated the messages and added some more
tests.
// Recursively parses a formula to see if there are any open (, {, [, comments, strings, or if the formula ends with a unary prefix or binary operator
29
+
// Recursion happens for string interoplation
30
+
// An earlier version of this routine attempted to use the Power Fx parser directly, but interpreting erorr messages to determine continuation situations was not accurate enough
<value>Ensure you have text for your identifier. This error occurs when the identifier is all blanks or spaces.</value>
3724
+
<value>Ensure you have valid text in your your identifier. This error occurs when the identifier is blank, only has spaces, or contains a tab or newline.</value>
0 commit comments