Yeah, Trino actually does something interesting (that I tried to replicate). ANTLR essentially throws exceptions at the last evaluated rule, but it doesn't throw the exception in the "deepest" rule. So, Trino, upon receiving a SyntaxError, creates some state machine to try to figure out the "deepest" rule to find the most precise location where the syntax error is really coming from.
I tried to replicate their state machine, but it didn't end up working for me. Decided to also just punt it because it seemed that it would add complexity to this PR when what we really need is to understand parse errors happening as a whole.
So, yeah, I'll create an issue and reference this and the Trino implementation. Linking soon.
Yeah, Trino actually does something interesting (that I tried to replicate). ANTLR essentially throws exceptions at the last evaluated rule, but it doesn't throw the exception in the "deepest" rule. So, Trino, upon receiving a SyntaxError, creates some state machine to try to figure out the "deepest" rule to find the most precise location where the syntax error is really coming from.
I tried to replicate their state machine, but it didn't end up working for me. Decided to also just punt it because it seemed that it would add complexity to this PR when what we really need is to understand parse errors happening as a whole.
So, yeah, I'll create an issue and reference this and the Trino implementation. Linking soon.
_Originally posted by @johnedquinn in https://github.com/partiql/partiql-lang-kotlin/pull/718#discussion_r959813844_