Date: Wed, 11 Aug 2021 10:41:18 +0800
Subject: [PATCH] backend/parser: use regular expressions to simplify
 less_greater and not_equals

   we can use regular expressions (<>|!=) to cover "<>" and "!=", so there is no
need to have two definitions less_greater and not_equals, it will confuse developer.
So, we can use only not_equals to cover this operator set. 

Signed-off-by: Shihao Sun <sunshihao.ssh@alibabab-inc.com>
Signed-off-by: Xiaojian Fan <funnyxj.fxj@alibaba-inc.com>
---
 src/backend/parser/scan.l         | 9 +--------
 src/fe_utils/psqlscan.l           | 7 +------
 src/interfaces/ecpg/preproc/pgc.l | 8 +-------
 3 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 6e6824faeb..0297270ed4 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -363,8 +363,7 @@ colon_equals	":="
 equals_greater	"=>"
 less_equals		"<="
 greater_equals	">="
-less_greater	"<>"
-not_equals		"!="
+not_equals		(<>|!=)
 
 /*
  * "self" is the set of chars that should be returned as single-character
@@ -842,12 +841,6 @@ other			.
 					return GREATER_EQUALS;
 				}
 
-{less_greater}	{
-					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
-					SET_YYLLOC();
-					return NOT_EQUALS;
-				}
-
 {not_equals}	{
 					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
 					SET_YYLLOC();
diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l
index 0fab48a382..3e73c967ab 100644
--- a/src/fe_utils/psqlscan.l
+++ b/src/fe_utils/psqlscan.l
@@ -301,8 +301,7 @@ colon_equals	":="
 equals_greater	"=>"
 less_equals		"<="
 greater_equals	">="
-less_greater	"<>"
-not_equals		"!="
+not_equals		(<>|!=)
 
 /*
  * "self" is the set of chars that should be returned as single-character
@@ -618,10 +617,6 @@ other			.
 					ECHO;
 				}
 
-{less_greater}	{
-					ECHO;
-				}
-
 {not_equals}	{
 					ECHO;
 				}
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 7a0356638d..7c8821b569 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -329,8 +329,7 @@ colon_equals	":="
 equals_greater	"=>"
 less_equals		"<="
 greater_equals	">="
-less_greater	"<>"
-not_equals		"!="
+not_equals		(<>|!=)
 
 /*
  * "self" is the set of chars that should be returned as single-character
@@ -783,11 +782,6 @@ cppline			{space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
 					return GREATER_EQUALS;
 				}
 
-{less_greater}	{
-					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
-					return NOT_EQUALS;
-				}
-
 {not_equals}	{
 					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
 					return NOT_EQUALS;
-- 
2.32.0

