henrib commented on code in PR #398:
URL: https://github.com/apache/commons-jexl/pull/398#discussion_r2807779022


##########
src/main/java/org/apache/commons/jexl3/parser/Parser.jjt:
##########
@@ -288,27 +297,36 @@ TOKEN_MGR_DECLS : {
 {
   < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>|<ESCAPE>)* >
   {
-      matchedToken.image = StringParser.unescapeIdentifier(matchedToken.image);
-      final int length = matchedToken.image.length();
-      if (comparatorNames && length == 2) {
-          switch (matchedToken.image) {
-             case "ne" : matchedToken.kind = NE; break;
-             case "eq" : matchedToken.kind = EQ; break;
-             case "lt" : matchedToken.kind = LT; break;
-             case "le" : matchedToken.kind = LE; break;
-             case "gt" : matchedToken.kind = GT; break;
-             case "ge" : matchedToken.kind = GE; break;
-          }
-      } else if (jexl331 && length >= 3 && length <= 10) {
-          switch (matchedToken.image) {
-             case "try" : matchedToken.kind = TRY; break;
-             case "catch" : matchedToken.kind = CATCH; break;
-             case "finally" : matchedToken.kind = FINALLY; break;
-             case "throw" : matchedToken.kind = THROW; break;
-             case "instanceof": matchedToken.kind = ISA; break;
-             case "!instanceof": matchedToken.kind = NISA; break;
-          }
-      }
+    matchedToken.image = StringParser.unescapeIdentifier(matchedToken.image);
+    final int length = matchedToken.image.length();
+    if (ignoredTokens.contains(matchedToken.image)) {
+        // ignore by getting next token instead
+        Token n = getNextToken();
+        matchedToken.kind = n.kind;
+        matchedToken.image = n.image;
+        matchedToken.beginLine = n.beginLine;
+        matchedToken.endLine = n.endLine;
+        matchedToken.beginColumn = n.beginColumn;
+        matchedToken.endColumn = n.endColumn;

Review Comment:
   The feature is already a 'Hail Mary' ; it is meant to ease migration for 
templates that exploited a bug where the template prefix is on a new line 
(eventually after whitespaces). Its robustness is not the primary concern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to