Skip to content

Commit 5c4dc7a

Browse files
committed
Requested changes.
1 parent d309908 commit 5c4dc7a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

core/src/main/kotlin/org/evomaster/core/parser/RegexHandler.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ object RegexHandler {
5353

5454
/**
5555
* This function handles comments and whitespace for Java regex, striping them when the "x" flag is on.
56+
*
57+
* This cannot be handled at the ANTLR level because the flag can be enabled and disabled
58+
* mid-pattern via inline flag groups like `(?x:...)` and `(?-x:...)`, which are only known
59+
* at parse time. Lexer modes cannot react to parser-level flag state.
60+
*
61+
* The visitor cannot handle this either, as some constructs (character classes, quantifier bounds, etc.)
62+
* are tokenised before the visitor sees them.
63+
*
64+
* This function therefore performs a linear scan of the raw string before ANTLR, tracking
65+
* flag state across inline scopes, producing a cleaned string that requires no special
66+
* handling in the lexer or visitor.
5667
*/
5768
private fun preprocessCommentsForJavaRegex(regex: String, externalRegexFlags: RegexFlags): String {
5869
val result = StringBuilder(regex.length)

0 commit comments

Comments
 (0)