fix: parsing of d2:condition arg0 into root AST#89
Conversation
| */ | ||
| object ExpressionGrammar { | ||
|
|
||
| private val STRING_PARSED = Fragment {expr, ctx -> run { |
There was a problem hiding this comment.
I think the run function is not necessary here.
There was a problem hiding this comment.
IDK kotlin well enough, this was a suggestion by the IDE to add it. Do you think I should remove it?
There was a problem hiding this comment.
I think it has no effect in this particular case, but maybe there is something else I don't see. The run method executes a block of code as an expression (check the last paragraph in this section). In this case, this part of the code builds a Fragment object by implementing the abstract method in the interface, which is this lambda function. So I don't see any difference in adding run in the body. It is fine to leave it if we want.
|
|
||
| private val STRING_PARSED = Fragment {expr, ctx -> run { | ||
| val nestedExpr = Literals.parseString(expr); // consumes the literal in parent expr | ||
| Expr.parse(nestedExpr, ctx, false); |
There was a problem hiding this comment.
The ending ; are not incorrect, but not strictly necessary in kotlin.
|
Added a small description just for the record. This PR looks good to me. The only missing thing is the version upgrade, it should be updated if we want a new release for this. |
|



The function
d2:conditionwas defined in the parser but not implemented. This function is very similar to theiffunction with the difference that the condition is quoted (for exampled2:condition('((1 == 1) && (2 == 2))',1,0)). The implementation uses the same evaluation as for theiffunction after the condition expression is unquoted.Related ticket.