void () { final RegExpLexer lexer = new RegExpLexer(EnumSet.of(NESTED_CHARACTER_CLASSES)); doTest("[]]", """ CLASS_BEGIN ('[') CHARACTER (']') CLASS_END (']')""", lexer); doTest("[\\]]", """ CLASS_BEGIN ('[') REDUNDANT_ESCAPE ('\\]') CLASS_END (']')""", lexer); doTest("[[]]]", """ CLASS_BEGIN ('[') CLASS_BEGIN ('[') CHARACTER (']') CLASS_END (']') CLASS_END (']')""", lexer); doTest("[ \\]]", """ CLASS_BEGIN ('[') CHARACTER (' ') ESC_CHARACTER ('\\]') CLASS_END (']')""", lexer); doTest("[\\Q\\E]]", """ CLASS_BEGIN ('[') QUOTE_BEGIN ('\\Q') QUOTE_END ('\\E') CHARACTER (']') CLASS_END (']')""", lexer); doTest("[\\Q+\\E]]", """ CLASS_BEGIN ('[') QUOTE_BEGIN ('\\Q') CHARACTER ('+') QUOTE_END ('\\E') CLASS_END (']') CHARACTER (']')""", lexer); doTest("[^\\Q\\E]]", """ CLASS_BEGIN ('[') CARET ('^') QUOTE_BEGIN ('\\Q') QUOTE_END ('\\E') CHARACTER (']') CLASS_END (']')""", lexer); doTest("[^\\Q+\\E]]", """ CLASS_BEGIN ('[') CARET ('^') QUOTE_BEGIN ('\\Q') CHARACTER ('+') QUOTE_END ('\\E') CLASS_END (']') CHARACTER (']')""", lexer); final RegExpLexer lexer2 = new RegExpLexer(EnumSet.of(COMMENT_MODE, WHITESPACE_IN_CLASS)); doTest("[ \t\n]]", """ CLASS_BEGIN ('[') WHITE_SPACE (' ') WHITE_SPACE ('\t') WHITE_SPACE ('\\n') CHARACTER (']') CLASS_END (']')""", lexer2); doTest("[\\ ]", """ CLASS_BEGIN ('[') ESC_CTRL_CHARACTER ('\\ ') CLASS_END (']')""", lexer2); doTest("[#comment\nabc]", """ CLASS_BEGIN ('[') COMMENT ('#comment') WHITE_SPACE ('\\n') CHARACTER ('a') CHARACTER ('b') CHARACTER ('c') CLASS_END (']')""", lexer2); doTest("[ ^]]", """ CLASS_BEGIN ('[') WHITE_SPACE (' ') CHARACTER ('^') CLASS_END (']') CHARACTER (']')""", lexer2); doTest("[\\", "CLASS_BEGIN ('[')\n" + "INVALID_CHARACTER_ESCAPE_TOKEN ('\\')", lexer2); final RegExpLexer lexer3 = new RegExpLexer(EnumSet.of(ALLOW_EMPTY_CHARACTER_CLASS)); doTest("[]]", """ CLASS_BEGIN ('[') CLASS_END (']') CHARACTER (']')""", lexer3); doTest("[[]]]", """ CLASS_BEGIN ('[') CHARACTER ('[') CLASS_END (']') CHARACTER (']') CHARACTER (']')""", lexer3); doTest("[\\]]", """ CLASS_BEGIN ('[') ESC_CHARACTER ('\\]') CLASS_END (']')""", lexer3); doTest("[ \\]]", """ CLASS_BEGIN ('[') CHARACTER (' ') ESC_CHARACTER ('\\]') CLASS_END (']')""", lexer3); final RegExpLexer lexer4 = new RegExpLexer(EnumSet.of(COMMENT_MODE)); doTest("[ ]", """ CLASS_BEGIN ('[') CHARACTER (' ') CLASS_END (']')""", lexer4); doTest("[#]", """ CLASS_BEGIN ('[') CHARACTER ('#') CLASS_END (']')""", lexer4); doTest("[\\ ]", """ CLASS_BEGIN ('[') REDUNDANT_ESCAPE ('\\ ') CLASS_END (']')""", lexer4); }