The keywords LEFT and RIGHT were being allowed as identifiers in the grammar. They are in fact hard keywords and must be [escaped] to be used as column names.
However, SQL parsers are often hand crafted and can do special checks in context. Should we encounter an input set that uses LEFT or RIGHT as a column name without escaping, we can implement semantic predicates (which are generally avoided), as so (note, that this is for illustration purposes, and would actually be a call to a member function where we can explore the lookahead more exactly):
asAlias: { !(_input.LA(1) == LEFT && _input.LA(2) == OUTER) }? AS? alias ;
The keywords LEFT and RIGHT were being allowed as identifiers in the grammar. They are in fact hard keywords and must be [escaped] to be used as column names.
However, SQL parsers are often hand crafted and can do special checks in context. Should we encounter an input set that uses LEFT or RIGHT as a column name without escaping, we can implement semantic predicates (which are generally avoided), as so (note, that this is for illustration purposes, and would actually be a call to a member function where we can explore the lookahead more exactly):