I found the problem and fixed it.
The parsing code was incorrect and implemented right associativity instead of left. I am surprised we did not find this before now. I guess we do not usually use complicated expressions in queries.
The code for parsing expressions in the language was correct, but I did not keep the two version consistent 🙁
jSuneido does not have this problem because it shares the expression parsing code with both the language and queries.
I will post a new snapshot but if you need the fix right away, let me know.