DSL rule load failure on latest snapshot

This snippet of my rule worked before installing the latest snapshot 5380.

    var int value = (Miio_Vacuum_Status_StateId.state as Number).intValue
    var String message

    switch (value) {
        case 9: {
            message = "Vacuum has reported a charging error"
        }
        case 10: {
            message = "Vacuum is paused"
        }
    }

Now I’m seeing an error when the rule loads.

2026-05-19 12:02:26.165 [WARN ] [el.core.internal.ModelRepositoryImpl] - DSL model 'TestRule.rules' has errors, therefore ignoring it: [32,14]: mismatched character ' ' expecting set '0'..'5'
[35,5]: no viable alternative at input '}'

If I comment out the case 10 portion of the rule it loads fine. Seems like anything more than a single digit will cause the problem.

@Lolodomo I know there have been numerous changes to DSL grammar. Any idea what might be causing this? Is the problem already known?

Hello, until what snapshot did it work for you ?

It was working on 5191. I hadn’t upgraded to anything more recent than that because I was away for a while.

I started looking through the closed PRs for things that touched the grammar. I would assume this is an issue with the grammar but I don’t really know for sure.

This works in DSL Scripts, but not in DSL Rules. You can mitigate by setting

var i = 10 …
case i : …

or with

case 5 + 5:

As a matter of fact for a number 10 it does not work, but for 90, 70, 32 or 9 it works.

rule a
when
  System reached start level 100
then
    var String message
    switch (10) {
        case 10: messege = "ten"
    }
    logError("E", message)
end

For 10 the error message is:

mismatched character ’ ’ expecting set ‘0’..‘5’

My guess is:

terminal TIME:
        (('0'..'1') ('0'..'9') ':' ('0'..'5') ('0'..'9')) | ('2' ('0'..'3') ':' ('0'..'5') ('0'..'9'))
;

because the digit 5 does not appear on other places in the grammar, in a way that it makes it distinct from the digit 6, to justify this error message. So the parser (I guess) tries to fill TIME after seeing ('0'..'1') ('0'..'9') ':'.

And indeed, with a space before the colon it works:

case 10 : …

I have however no idea how this should be fixed.

That’s a very good bit of discovery work sir!

Adding the space before the colon is a golden workaround!!

So then this commit would be the cause?

Same for me!

But your analysis seems to be very good, it is certainly due to this added “TIME”.

PS: “TIME” is the unique terminal that was added.

Edit: I believe I used “terminal” because it was not compiling without.

@Lolodomo would you like me to open an issue on GH, or are you ok with just this?

An issue in GitHub would be better.

Opened… I can add more details to the issue from this post if you want. Just let me know.

By the way, from

var int value = (Miio_Vacuum_Status_StateId.state as Number).intValue
switch (value) {

int at the beginnig of the first line and the parentheses around value on the second line can be removed - they do not make a difference execution-wise:

var value = (Miio_Vacuum_Status_StateId.state as Number).intValue
switch value {

Yes, thank you. :wink:

A fix is now proposed:

Fix is merged