Rebased the patch to trunk. I also verified that all unit tests pass.
In terms of the fix, here is the summary of what I did.
When constructing antlr trees from case/in syntax, I used to collapse expressions into a flat list and assume that the first element is the lhs.
i.e. expr IN ( expr, expr* ) -> ^( IN expr+ )
But now I construct a list of sub-trees instead.
i.e. lhs IN ( rhs, rhs* ) -> ^( IN ^( LHS lhs ) ^( RHS rhs )+ )
This way it is clear where the boundaries between expressions are, so I no longer need to assume anything.