From 831c6c2924f483196e88b0f656f42dee6ffb643e Mon Sep 17 00:00:00 2001 From: Ben Chaplin Date: Fri, 11 Oct 2024 14:26:13 -0400 Subject: [PATCH] Make same changes for flexible parser --- .../checksums/javaccParserFlexible.json | 4 +- .../standard/parser/StandardSyntaxParser.jj | 2 +- .../StandardSyntaxParserTokenManager.java | 82 +++++++++++++------ 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json b/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json index 439480bd23c..2b364e1aaa3 100644 --- a/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json +++ b/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json @@ -1,9 +1,9 @@ { "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java": "984cd645fdbad92dd3c8811785e1d48e582bacc5", "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java": "dcf92073340d1c38d01905a307f49fc89e094e76", - "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj": "77ebf56c78a8614a82532ca6bdf69378afd44b8f", + "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj": "c8f8c491a819197643f5e224bfcf3f72994190bd", "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java": "4ad426d4f4b7577f4af4e9057de32c65c83b1812", - "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java": "c264cc500a3964751827a9567ac230eda9783d9f", + "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java": "4fab6d6f05db84083e1ab8b572844c94a6a5ecc6", "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java": "f4cb9d01587279dba30e549ce4867e4381bbd9d7", "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java": "ff4008e6f76aa09dd48ff7c35190d7326bcf9849" } \ No newline at end of file diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj index 7389ce659f0..999ffa43c3a 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj @@ -198,7 +198,7 @@ PARSER_END(StandardSyntaxParser) | : DEFAULT | : DEFAULT | - | + | } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java index fa4e2f63d13..9eda808695c 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java @@ -1786,7 +1786,7 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0){ if ((active0 & 0x8000000000000L) != 0L) { jjmatchedKind = 55; - return 6; + return 9; } return -1; default : @@ -1819,7 +1819,7 @@ private int jjMoveStringLiteralDfa1_1(long active0){ { case 79: if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_1(1, 51, 6); + return jjStartNfaWithStates_1(1, 51, 9); break; default : break; @@ -1837,7 +1837,7 @@ private int jjStartNfaWithStates_1(int pos, int kind, int state) private int jjMoveNfa_1(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 7; + jjnewStateCnt = 9; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -1852,12 +1852,20 @@ private int jjMoveNfa_1(int startState, int curPos) { switch(jjstateSet[--i]) { + case 9: + case 6: + if ((0xfffffffeffffffffL & l) == 0L) + break; + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + break; case 0: if ((0xfffffffeffffffffL & l) != 0L) { if (kind > 55) kind = 55; - { jjCheckNAdd(6); } + { jjCheckNAddTwoStates(6, 7); } } if ((0x100002600L & l) != 0L) { @@ -1883,12 +1891,10 @@ private int jjMoveNfa_1(int startState, int curPos) if (curChar == 34 && kind > 54) kind = 54; break; - case 6: - if ((0xfffffffeffffffffL & l) == 0L) - break; + case 8: if (kind > 55) kind = 55; - { jjCheckNAdd(6); } + { jjCheckNAddTwoStates(6, 7); } break; default : break; } @@ -1901,13 +1907,25 @@ private int jjMoveNfa_1(int startState, int curPos) { switch(jjstateSet[--i]) { + case 9: + if ((0xdfffffffcfffffffL & l) != 0L) + { + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + } + else if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 8; + break; case 0: - case 6: - if ((0xdfffffffdfffffffL & l) == 0L) - break; - if (kind > 55) - kind = 55; - { jjCheckNAdd(6); } + if ((0xdfffffffcfffffffL & l) != 0L) + { + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + } + else if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 8; break; case 2: { jjAddStates(26, 28); } @@ -1916,6 +1934,22 @@ private int jjMoveNfa_1(int startState, int curPos) if (curChar == 92) jjstateSet[jjnewStateCnt++] = 3; break; + case 6: + if ((0xdfffffffcfffffffL & l) == 0L) + break; + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + break; + case 7: + if (curChar == 92) + jjstateSet[jjnewStateCnt++] = 8; + break; + case 8: + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + break; default : break; } } while(i != startsAt); @@ -1931,6 +1965,15 @@ private int jjMoveNfa_1(int startState, int curPos) { switch(jjstateSet[--i]) { + case 9: + case 6: + case 8: + if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) + break; + if (kind > 55) + kind = 55; + { jjCheckNAddTwoStates(6, 7); } + break; case 0: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) { @@ -1941,20 +1984,13 @@ private int jjMoveNfa_1(int startState, int curPos) { if (kind > 55) kind = 55; - { jjCheckNAdd(6); } + { jjCheckNAddTwoStates(6, 7); } } break; case 2: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) { jjAddStates(26, 28); } break; - case 6: - if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) - break; - if (kind > 55) - kind = 55; - { jjCheckNAdd(6); } - break; default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); @@ -1966,7 +2002,7 @@ private int jjMoveNfa_1(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 9 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; }