Closed DDarby-Lewis closed 4 months ago
Turns out this can be done by simply replacing the test pattern with:
!?test_pattern: or_pattern ["if" or_pattern "else" test_pattern] ["when" expr]
I'm not sure if this is the "right" way to do this but it does seem to work.
Duplicate of https://github.com/Scony/godot-gdscript-toolkit/issues/258
The implementation will require handling in formatter and linter + adding tests to cover that. But no worries - I'll handle that soon.
Match statement cases accept a guard condition which is currently not recognised by the parser/formatter... As per the docs here: https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#pattern-guards
I have looked at implementing this myself in the
gdscript.lark
by adding this to thepattern
for thematch_branch
and:
and adding to the expression_to_str method this extra key:
Which didn't quite get ut working. Does anyone know how this can be added?