-
Notifications
You must be signed in to change notification settings - Fork 5
fix: parsing of d2:condition arg0 into root AST #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| */ | ||
| object ExpressionGrammar { | ||
|
|
||
| private val STRING_PARSED = Fragment {expr, ctx -> run { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the run function is not necessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.