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
As discussed in the comments of #4079, having support for inline IF constructs would shorten and also simplify cases where a single keyword or some other statement (e.g. planned RETURN (#4078) and CONTINUE/BREAK (#4079)) is to be executed conditionally. In the aforementioned comments, @ericbjones proposed an inline IF syntax that looks pretty good to me. For example,
IF $condition1
Keyword arg
END
IF $condition2
BREAK
END
could be replaced with
IF $condition1 Keyword arg
IF $condition2 BREAK
As I commented that original proposal, we probably should also support for IF ELSE and ELSE:
IF $condition1 Keyword arg ELSE IF $condition2 Another Keyword ELSE Yet another keyword
Supporting assignment could be useful as well:
${var} = IF condition Keyword arg ELSE Another Keyword
Although this is just syntactic sugar, I consider this pretty important especially if/when we add support for RETURN, BREAK and CONTINUE. I thus add this tentatively to RF 5.0 scope.
The parser can detect inline IF simply by checking is there anything after the condition on the same line. That is currently an error so adding this support is backwards compatible. We shouldn't require an END at the end, instead it should be an error.
On the parsing model (AST) inline IF may be able to use the current If node but it would need to be enhanced to support assignment. It could be that adding separate InlineIf node is cleaner.
On the execution model we most likely can use the current If class but need to add assignment support to it.
In the log file we probably can show inline IFs exactly like normal IFs, but need to figure out a way how to show possible assignment.
Activity
pekkaklarck commentedon Sep 20, 2021
The parser can detect inline
IFsimply by checking is there anything after the condition on the same line. That is currently an error so adding this support is backwards compatible. We shouldn't require anENDat the end, instead it should be an error.On the parsing model (AST) inline
IFmay be able to use the current If node but it would need to be enhanced to support assignment. It could be that adding separateInlineIfnode is cleaner.On the execution model we most likely can use the current If class but need to add assignment support to it.
In the log file we probably can show inline
IFs exactly like normalIFs, but need to figure out a way how to show possible assignment.Handle various inline IF error situations.
Handle various inline IF error situations.
Fix inline IF assignment when no branch is run. (#4093)
Inline IF tuning (#4093)
Fix parsing inline IF with empty ELSE or ELSE IF.