diff --git a/sql/postgresql/CSharp/PostgreSQLParserBase.cs b/sql/postgresql/CSharp/PostgreSQLParserBase.cs index 8c9ef2dcdd..05807415ee 100644 --- a/sql/postgresql/CSharp/PostgreSQLParserBase.cs +++ b/sql/postgresql/CSharp/PostgreSQLParserBase.cs @@ -120,4 +120,13 @@ public PostgreSQLParser getPostgreSQLParser(string script) parser.AddErrorListener(listener_parser); return parser; } + + public bool OnlyAcceptableOps() + { + var c = ((CommonTokenStream)this.InputStream).LT(1); + var text = c.Text; + return text == "!" || text == "!!" + || text == "!=-" // Code for specific example. + ; + } } diff --git a/sql/postgresql/Java/PostgreSQLParserBase.java b/sql/postgresql/Java/PostgreSQLParserBase.java index acfb802dfd..660227a4b1 100644 --- a/sql/postgresql/Java/PostgreSQLParserBase.java +++ b/sql/postgresql/Java/PostgreSQLParserBase.java @@ -121,4 +121,13 @@ public PostgreSQLParser getPostgreSQLParser(String script) { parser.addErrorListener(listener_parser); return parser; } + + public boolean OnlyAcceptableOps() + { + var c = ((CommonTokenStream)this.getInputStream()).LT(1); + var text = c.getText(); + return text.equals("!") || text.equals("!!") + || text.equals("!=-") + ; + } } diff --git a/sql/postgresql/PostgreSQLParser.g4 b/sql/postgresql/PostgreSQLParser.g4 index 89a5902750..6b47878051 100644 --- a/sql/postgresql/PostgreSQLParser.g4 +++ b/sql/postgresql/PostgreSQLParser.g4 @@ -3555,7 +3555,7 @@ a_expr /*19*/ a_expr_qual - : a_expr_lessless qual_op? + : a_expr_lessless ({ this.OnlyAcceptableOps() }? qual_op | ) ; /*18*/