diff --git a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java index eb81735b3553..a31729728ad8 100644 --- a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java +++ b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java @@ -1,5 +1,3 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - /* The following code was generated by JFlex 1.7.0 tweaked for IntelliJ platform */ /* It's an automatically generated code. Do not modify it. */ @@ -37,21 +35,22 @@ class _RegExLexer implements FlexLexer { public static final int QUANTIFIER = 6; public static final int NON_QUANTIFIER = 8; public static final int NEGATED_CLASS = 10; - public static final int QUOTED_CLASS1 = 12; + public static final int QUOTED_CLASS = 12; public static final int CLASS1 = 14; - public static final int CLASS2 = 16; - public static final int PROP = 18; - public static final int NAMED = 20; - public static final int OPTIONS = 22; - public static final int COMMENT = 24; - public static final int NAMED_GROUP = 26; - public static final int QUOTED_NAMED_GROUP = 28; - public static final int PY_NAMED_GROUP_REF = 30; - public static final int PY_COND_REF = 32; - public static final int BRACKET_EXPRESSION = 34; - public static final int MYSQL_CHAR_EXPRESSION = 36; - public static final int MYSQL_CHAR_EQ_EXPRESSION = 38; - public static final int EMBRACED_HEX = 40; + public static final int OPTIONS = 16; + public static final int COMMENT = 18; + public static final int NAMED_GROUP = 20; + public static final int QUOTED_NAMED_GROUP = 22; + public static final int PY_NAMED_GROUP_REF = 24; + public static final int BRACKET_EXPRESSION = 26; + public static final int MYSQL_CHAR_EXPRESSION = 28; + public static final int MYSQL_CHAR_EQ_EXPRESSION = 30; + public static final int EMBRACED_HEX = 32; + public static final int CONDITIONAL1 = 34; + public static final int CONDITIONAL2 = 36; + public static final int CLASS2 = 38; + public static final int PROP = 40; + public static final int NAMED = 42; /** * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l @@ -62,7 +61,7 @@ class _RegExLexer implements FlexLexer { private static final int ZZ_LEXSTATE[] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, - 16, 16, 17, 17, 18, 18, 19, 19, 20, 20 + 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21 }; /** @@ -200,30 +199,36 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\14\0\1\1\10\0\1\2\1\3\1\4\1\5\1\6"+ + "\11\0\1\1\14\0\1\2\1\3\1\4\1\5\1\6"+ "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+ "\1\17\1\20\1\21\1\22\1\23\1\2\1\24\1\25"+ "\1\26\1\27\1\30\1\31\1\0\1\32\2\33\1\34"+ - "\1\35\1\36\1\34\1\37\1\40\1\41\1\12\1\42"+ - "\1\43\1\44\1\2\1\45\1\46\1\24\1\47\1\50"+ - "\1\51\1\52\1\53\1\54\1\26\1\55\1\56\1\57"+ - "\1\60\3\57\1\26\1\57\1\26\1\57\1\61\1\62"+ - "\3\0\1\63\1\64\1\65\1\66\1\67\1\70\1\71"+ - "\1\72\1\73\1\12\1\73\1\74\2\75\1\76\1\77"+ - "\1\12\1\100\1\101\1\102\1\103\1\104\1\105\1\106"+ - "\1\12\1\107\1\110\1\111\1\112\1\113\1\114\1\115"+ - "\1\116\1\117\1\120\1\121\1\122\1\12\1\123\1\124"+ - "\1\0\1\125\2\26\1\126\2\61\1\127\1\130\1\0"+ - "\1\131\1\132\1\133\1\134\1\135\1\0\1\136\1\137"+ - "\1\140\1\141\2\0\1\142\6\0\1\143\1\144\1\145"+ - "\1\146\2\147\1\101\1\150\1\151\1\152\1\153\1\154"+ - "\1\155\1\156\1\157\1\160\1\161\1\162\1\163\1\0"+ - "\1\164\1\165\1\166\1\0\1\167\1\0\1\170\4\0"+ - "\1\143\2\147\1\101\1\171\1\153\1\172\1\173\1\174"+ - "\1\143\1\0\1\175\1\153\1\0\1\176"; + "\1\35\1\36\1\34\1\37\1\40\1\41\1\42\1\43"+ + "\1\44\1\26\1\45\1\46\1\47\1\50\3\47\1\26"+ + "\1\47\1\26\1\47\1\51\1\52\2\12\2\40\1\53"+ + "\1\54\1\12\1\55\1\56\1\57\1\2\1\60\1\61"+ + "\1\24\1\62\1\63\3\0\1\64\1\65\1\66\1\67"+ + "\1\70\1\71\1\72\1\73\1\74\1\12\1\74\1\75"+ + "\2\76\1\77\1\100\1\12\1\101\1\102\1\103\1\104"+ + "\1\105\1\106\1\107\1\12\1\110\1\111\1\112\1\113"+ + "\1\114\1\115\1\116\1\117\1\120\1\121\1\0\1\122"+ + "\2\26\1\123\2\51\1\0\1\124\1\125\1\12\1\66"+ + "\1\65\1\71\1\73\2\12\1\75\2\76\1\77\1\100"+ + "\1\101\1\102\1\103\1\104\1\105\1\106\1\107\1\126"+ + "\1\127\1\130\1\131\1\132\1\133\1\134\1\135\1\0"+ + "\1\136\1\137\1\140\1\141\1\142\1\0\1\143\1\144"+ + "\1\145\1\146\2\0\1\147\6\0\1\150\1\151\1\152"+ + "\1\153\2\154\1\102\1\155\1\156\1\157\1\160\1\161"+ + "\1\162\1\163\1\164\1\0\1\165\1\166\1\150\1\153"+ + "\2\154\1\102\1\156\1\160\1\167\1\170\1\171\1\172"+ + "\1\0\1\173\1\174\1\175\1\0\1\176\1\0\1\177"+ + "\4\0\1\150\2\154\1\102\1\200\1\160\1\201\1\202"+ + "\1\150\2\154\1\102\1\200\1\160\1\203\1\204\1\205"+ + "\1\150\1\0\1\206\1\160\1\150\1\206\1\160\1\0"+ + "\2\207"; private static int [] zzUnpackAction() { - int [] result = new int[203]; + int [] result = new int[254]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -250,33 +255,39 @@ class _RegExLexer implements FlexLexer { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\77\0\176\0\275\0\374\0\u013b\0\u017a\0\u01b9"+ "\0\u01f8\0\u0237\0\u0276\0\u02b5\0\u02f4\0\u0333\0\u0372\0\u03b1"+ - "\0\u03f0\0\u042f\0\u046e\0\u04ad\0\u04ec\0\u052b\0\u052b\0\u056a"+ - "\0\u052b\0\u05a9\0\u052b\0\u05e8\0\u052b\0\u0627\0\u052b\0\u052b"+ - "\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u0666"+ - "\0\u052b\0\u052b\0\u06a5\0\u052b\0\u06e4\0\u052b\0\u0723\0\u052b"+ - "\0\u052b\0\u0666\0\u052b\0\u0762\0\u052b\0\u07a1\0\u052b\0\u07e0"+ - "\0\u052b\0\u081f\0\u052b\0\u052b\0\u052b\0\u085e\0\u052b\0\u052b"+ - "\0\u089d\0\u052b\0\u052b\0\u052b\0\u08dc\0\u091b\0\u052b\0\u095a"+ - "\0\u052b\0\u052b\0\u052b\0\u052b\0\u0999\0\u09d8\0\u0a17\0\u0a56"+ - "\0\u0a95\0\u0ad4\0\u0b13\0\u0b52\0\u0b91\0\u0bd0\0\u0c0f\0\u0c4e"+ - "\0\u052b\0\u052b\0\u052b\0\u0c8d\0\u052b\0\u052b\0\u052b\0\u052b"+ - "\0\u0ccc\0\u0d0b\0\u052b\0\u052b\0\u0d4a\0\u052b\0\u052b\0\u052b"+ - "\0\u052b\0\u0d89\0\u0dc8\0\u052b\0\u0e07\0\u0e46\0\u052b\0\u052b"+ - "\0\u0e85\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+ - "\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u0ec4\0\u052b\0\u052b"+ - "\0\u0f03\0\u052b\0\u0f42\0\u052b\0\u052b\0\u052b\0\u0f81\0\u052b"+ - "\0\u052b\0\u0fc0\0\u0fff\0\u052b\0\u052b\0\u052b\0\u052b\0\u103e"+ - "\0\u052b\0\u052b\0\u052b\0\u052b\0\u107d\0\u10bc\0\u052b\0\u10fb"+ - "\0\u113a\0\u1179\0\u11b8\0\u11f7\0\u1236\0\u1275\0\u052b\0\u052b"+ - "\0\u052b\0\u12b4\0\u12f3\0\u1332\0\u052b\0\u1371\0\u052b\0\u13b0"+ - "\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b\0\u052b"+ - "\0\u13ef\0\u052b\0\u052b\0\u052b\0\u142e\0\u052b\0\u146d\0\u052b"+ - "\0\u14ac\0\u14eb\0\u152a\0\u1569\0\u15a8\0\u15e7\0\u052b\0\u052b"+ - "\0\u052b\0\u1626\0\u052b\0\u052b\0\u052b\0\u052b\0\u1665\0\u052b"+ - "\0\u16a4\0\u16e3\0\u052b"; + "\0\u03f0\0\u042f\0\u046e\0\u04ad\0\u04ec\0\u052b\0\u056a\0\u056a"+ + "\0\u05a9\0\u056a\0\u05e8\0\u056a\0\u0627\0\u056a\0\u0666\0\u056a"+ + "\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a"+ + "\0\u06a5\0\u056a\0\u056a\0\u06e4\0\u056a\0\u0723\0\u056a\0\u0762"+ + "\0\u056a\0\u056a\0\u06a5\0\u056a\0\u07a1\0\u056a\0\u07e0\0\u056a"+ + "\0\u056a\0\u056a\0\u081f\0\u085e\0\u056a\0\u089d\0\u056a\0\u056a"+ + "\0\u056a\0\u056a\0\u08dc\0\u091b\0\u095a\0\u0999\0\u09d8\0\u0a17"+ + "\0\u0a56\0\u0a95\0\u0ad4\0\u0b13\0\u0b52\0\u0b91\0\u0bd0\0\u0c0f"+ + "\0\u056a\0\u0c4e\0\u056a\0\u056a\0\u056a\0\u0c8d\0\u056a\0\u056a"+ + "\0\u0b13\0\u056a\0\u0ccc\0\u0d0b\0\u0d4a\0\u0d89\0\u056a\0\u056a"+ + "\0\u056a\0\u0dc8\0\u056a\0\u056a\0\u056a\0\u056a\0\u0e07\0\u0e46"+ + "\0\u056a\0\u056a\0\u0e85\0\u056a\0\u056a\0\u056a\0\u056a\0\u0ec4"+ + "\0\u0f03\0\u056a\0\u0f42\0\u0f81\0\u056a\0\u056a\0\u0fc0\0\u056a"+ + "\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a"+ + "\0\u056a\0\u0fff\0\u056a\0\u103e\0\u056a\0\u056a\0\u056a\0\u107d"+ + "\0\u10bc\0\u056a\0\u056a\0\u10fb\0\u089d\0\u089d\0\u089d\0\u089d"+ + "\0\u089d\0\u113a\0\u089d\0\u1179\0\u089d\0\u089d\0\u089d\0\u11b8"+ + "\0\u11f7\0\u089d\0\u1236\0\u1275\0\u089d\0\u089d\0\u056a\0\u056a"+ + "\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u056a\0\u12b4\0\u12f3"+ + "\0\u056a\0\u056a\0\u056a\0\u056a\0\u1332\0\u056a\0\u056a\0\u056a"+ + "\0\u056a\0\u1371\0\u13b0\0\u056a\0\u13ef\0\u142e\0\u146d\0\u14ac"+ + "\0\u14eb\0\u152a\0\u1569\0\u056a\0\u056a\0\u056a\0\u15a8\0\u15e7"+ + "\0\u1626\0\u056a\0\u1665\0\u056a\0\u16a4\0\u056a\0\u056a\0\u056a"+ + "\0\u056a\0\u16e3\0\u056a\0\u056a\0\u1722\0\u089d\0\u1761\0\u17a0"+ + "\0\u17df\0\u181e\0\u185d\0\u056a\0\u056a\0\u056a\0\u056a\0\u189c"+ + "\0\u056a\0\u056a\0\u056a\0\u18db\0\u056a\0\u191a\0\u056a\0\u1959"+ + "\0\u1998\0\u19d7\0\u1a16\0\u1a55\0\u1a94\0\u056a\0\u056a\0\u056a"+ + "\0\u1ad3\0\u056a\0\u056a\0\u1b12\0\u1b51\0\u089d\0\u089d\0\u089d"+ + "\0\u1b90\0\u056a\0\u056a\0\u056a\0\u056a\0\u1bcf\0\u056a\0\u1c0e"+ + "\0\u089d\0\u089d\0\u1c4d\0\u1c8c\0\u056a\0\u089d"; private static int [] zzUnpackRowMap() { - int [] result = new int[203]; + int [] result = new int[254]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -299,115 +310,159 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\35"+ - "\1\36\3\26\1\37\1\26\1\40\1\41\1\42\1\43"+ - "\1\44\1\45\35\26\1\46\10\26\1\47\3\26\1\46"+ - "\10\26\1\50\66\26\5\51\1\52\3\51\1\53\11\51"+ - "\1\45\23\53\2\51\3\53\3\51\2\53\1\51\1\53"+ - "\2\51\2\53\1\54\3\51\1\53\10\51\1\52\7\51"+ - "\1\55\31\51\2\55\3\51\2\55\1\56\20\51\10\0"+ - "\1\57\4\0\1\26\31\0\2\26\3\0\3\26\43\0"+ - "\1\60\53\0\10\61\1\62\66\61\6\63\1\64\1\65"+ - "\1\66\3\63\1\67\44\63\1\67\14\63\1\67\6\26"+ - "\1\70\1\71\1\72\2\26\1\73\1\74\44\26\1\75"+ - "\7\26\1\76\1\77\3\26\1\75\4\51\1\100\3\51"+ - "\1\101\21\51\1\102\1\51\1\102\2\51\1\102\2\51"+ - "\1\102\1\51\1\102\13\51\1\102\5\51\1\102\14\51"+ - "\1\100\3\51\1\101\66\51\3\103\1\104\5\103\1\105"+ - "\1\103\1\106\10\103\23\105\2\103\3\105\3\103\2\105"+ - "\1\103\1\105\2\103\2\105\1\103\1\107\2\103\1\105"+ - "\3\103\76\15\1\0\10\103\3\110\3\103\1\110\5\103"+ - "\23\110\2\103\3\110\3\103\2\110\1\103\1\110\2\103"+ - "\2\110\4\103\1\110\1\111\12\103\3\110\3\103\1\110"+ - "\5\103\23\110\2\103\3\110\3\103\2\110\1\103\1\110"+ - "\1\103\1\112\2\110\4\103\1\110\6\103\1\104\4\103"+ - "\3\110\3\103\1\110\5\103\23\110\2\103\3\110\3\103"+ - "\2\110\1\103\1\110\2\103\2\110\4\103\1\110\6\103"+ - "\1\104\4\103\3\110\2\103\1\55\1\110\5\103\23\110"+ - "\2\55\3\110\2\55\1\103\2\110\1\103\1\110\2\103"+ - "\2\110\4\103\1\110\3\103\11\113\1\53\11\113\1\45"+ - "\23\53\2\113\3\53\3\113\2\53\1\113\1\53\1\114"+ - "\1\113\2\53\1\113\1\115\2\113\1\53\1\114\2\113"+ - "\1\116\1\117\7\116\1\120\12\116\23\120\2\116\3\120"+ - "\3\116\2\120\1\116\1\120\2\116\2\120\4\116\1\120"+ - "\3\116\11\121\1\122\12\121\23\122\2\121\3\122\3\121"+ - "\2\122\1\121\1\122\2\121\2\122\1\123\3\121\1\122"+ - "\3\121\4\0\1\124\210\0\1\125\67\0\1\126\4\0"+ - "\1\127\31\0\2\127\3\0\2\127\1\130\43\0\1\131"+ - "\53\0\1\132\3\133\1\134\1\135\1\133\1\135\1\133"+ - "\2\132\1\136\1\137\1\132\6\133\2\140\1\141\1\142"+ - "\3\143\3\144\1\145\2\146\2\147\3\150\1\151\1\152"+ - "\1\153\1\154\1\155\1\156\2\153\1\132\1\157\1\160"+ - "\1\137\1\161\2\132\1\144\1\151\3\132\1\162\1\151"+ - "\2\132\1\137\45\0\1\163\33\0\2\53\5\0\5\53"+ - "\6\0\32\53\1\0\2\53\1\0\1\53\2\0\2\53"+ - "\4\0\1\53\20\0\1\55\31\0\2\55\3\0\2\55"+ - "\26\0\1\164\72\0\1\165\21\0\1\166\43\0\1\165"+ - "\1\167\15\0\1\170\13\0\1\171\25\0\1\172\26\0"+ - "\1\173\21\0\1\174\43\0\2\173\6\0\6\132\3\133"+ - "\2\132\1\136\1\175\7\132\3\140\1\176\3\151\3\144"+ - "\1\145\2\146\2\147\3\150\1\151\1\152\1\153\1\154"+ - "\1\155\1\156\2\153\1\132\1\157\1\160\1\175\1\151"+ - "\2\132\2\151\3\132\1\162\1\151\2\132\1\175\71\0"+ - "\1\177\5\0\6\132\1\133\1\132\1\133\2\132\1\136"+ - "\10\132\2\140\1\151\1\176\3\151\3\144\1\145\2\146"+ - "\2\147\3\150\1\151\1\152\1\153\1\154\1\155\1\156"+ - "\2\153\1\132\1\157\1\160\1\132\1\151\2\132\2\151"+ - "\3\132\1\162\1\151\3\132\11\0\1\105\12\0\23\105"+ - "\2\0\3\105\3\0\2\105\1\0\1\105\2\0\2\105"+ - "\4\0\1\105\14\0\1\106\12\0\23\106\2\0\3\106"+ - "\3\0\2\106\1\0\1\106\2\0\2\106\4\0\1\106"+ - "\13\0\7\110\5\0\32\110\1\0\2\110\1\0\1\110"+ - "\2\0\2\110\4\0\1\110\12\0\1\200\70\0\1\201"+ - "\76\0\1\201\5\0\1\202\70\0\1\201\7\0\1\203"+ - "\1\0\1\203\1\0\1\204\6\0\23\203\2\204\3\203"+ - "\2\204\1\0\2\203\1\0\1\203\2\0\2\203\4\0"+ - "\1\203\72\0\1\201\11\0\2\53\5\0\5\53\6\0"+ - "\32\53\1\0\2\53\1\0\1\53\2\0\2\53\1\201"+ - "\3\0\1\53\12\0\1\205\57\0\1\201\14\0\1\206"+ - "\17\0\2\207\1\0\1\207\4\0\3\207\5\0\4\207"+ - "\3\0\2\207\23\0\1\210\17\0\1\211\17\0\1\212"+ - "\20\0\1\213\1\214\2\0\1\215\1\216\1\217\1\220"+ - "\1\0\1\221\1\222\6\0\1\223\76\0\1\224\2\0"+ - "\1\225\4\0\1\127\31\0\2\127\3\0\2\127\1\226"+ - "\25\0\1\227\2\0\1\230\4\0\1\231\31\0\2\231"+ - "\3\0\2\231\36\0\1\232\31\0\2\232\3\0\2\232"+ - "\1\233\24\0\1\234\76\0\1\235\43\0\1\236\3\0"+ - "\2\236\5\0\1\237\1\240\12\0\77\241\47\0\1\242"+ - "\4\0\1\243\1\242\70\0\2\244\3\0\2\244\25\0"+ - "\1\245\20\0\2\246\1\0\1\246\4\0\3\246\5\0"+ - "\4\246\3\0\2\246\25\0\1\247\20\0\2\250\1\0"+ - "\1\250\4\0\3\250\5\0\4\250\3\0\2\250\104\0"+ - "\1\251\1\252\16\0\1\235\43\0\1\236\3\0\2\236"+ - "\30\0\1\253\100\0\1\203\1\0\1\203\1\0\1\204"+ - "\6\0\23\203\2\204\3\203\2\204\1\0\2\203\1\0"+ - "\1\203\2\0\2\203\4\0\1\203\10\0\1\254\17\0"+ - "\2\207\1\0\1\207\4\0\3\207\5\0\4\207\3\0"+ - "\2\207\104\0\1\255\3\0\1\256\4\0\1\217\71\0"+ - "\1\257\5\0\1\260\1\0\3\261\1\0\73\261\5\0"+ - "\1\262\76\0\1\224\2\0\1\225\4\0\1\226\31\0"+ - "\2\226\3\0\2\226\26\0\1\263\76\0\1\264\2\0"+ - "\1\265\4\0\1\231\31\0\2\231\3\0\2\231\26\0"+ - "\1\266\7\0\1\232\31\0\2\232\3\0\2\232\1\267"+ - "\25\0\1\270\7\0\1\271\31\0\2\271\3\0\2\271"+ - "\50\0\1\272\62\0\1\273\34\0\1\274\3\0\2\274"+ - "\70\0\2\275\3\0\2\275\70\0\1\276\4\0\2\276"+ - "\70\0\1\277\4\0\2\277\70\0\2\300\3\0\2\300"+ - "\46\0\2\301\1\0\1\301\4\0\3\301\5\0\4\301"+ - "\3\0\2\301\46\0\2\302\1\0\1\302\4\0\3\302"+ - "\5\0\4\302\3\0\2\302\21\0\3\261\1\303\73\261"+ - "\5\0\1\304\76\0\1\266\7\0\1\267\31\0\2\267"+ - "\3\0\2\267\26\0\1\305\7\0\1\271\31\0\2\271"+ - "\3\0\2\271\26\0\1\143\141\0\1\274\3\0\2\274"+ - "\26\0\1\306\41\0\2\307\3\0\2\307\70\0\2\306"+ - "\3\0\2\306\70\0\1\310\4\0\2\310\46\0\2\311"+ - "\1\0\1\311\4\0\3\311\5\0\4\311\3\0\2\311"+ - "\26\0\1\306\41\0\2\312\3\0\2\312\46\0\2\313"+ - "\1\0\1\313\4\0\3\313\5\0\4\313\3\0\2\313"+ - "\26\0\1\306\71\0"; + "\1\27\1\30\1\31\1\32\1\33\1\34\1\35\1\36"+ + "\1\37\3\27\1\40\1\27\1\41\1\42\1\43\1\44"+ + "\1\45\1\46\35\27\1\47\10\27\1\50\3\27\1\47"+ + "\10\27\1\51\66\27\5\52\1\53\3\52\1\54\11\52"+ + "\1\46\23\54\2\52\3\54\3\52\2\54\1\52\1\54"+ + "\2\52\2\54\1\55\3\52\1\54\10\52\1\53\7\52"+ + "\1\56\31\52\2\56\3\52\2\56\1\57\20\52\10\0"+ + "\1\60\4\0\1\27\31\0\2\27\3\0\3\27\43\0"+ + "\1\61\53\0\10\62\1\63\66\62\6\64\1\65\1\66"+ + "\1\67\3\64\1\70\44\64\1\70\14\64\1\70\3\71"+ + "\1\72\5\71\1\73\1\71\1\74\10\71\23\73\2\71"+ + "\3\73\3\71\2\73\1\71\1\73\2\71\2\73\1\71"+ + "\1\75\2\71\1\73\3\71\76\12\1\0\10\71\3\76"+ + "\3\71\1\76\5\71\23\76\2\71\3\76\3\71\2\76"+ + "\1\71\1\76\2\71\2\76\4\71\1\76\1\77\12\71"+ + "\3\76\3\71\1\76\5\71\23\76\2\71\3\76\3\71"+ + "\2\76\1\71\1\76\1\71\1\100\2\76\4\71\1\76"+ + "\6\71\1\72\4\71\3\76\3\71\1\76\5\71\23\76"+ + "\2\71\3\76\3\71\2\76\1\71\1\76\2\71\2\76"+ + "\4\71\1\76\3\71\11\101\1\54\11\101\1\46\23\54"+ + "\2\101\3\54\3\101\2\54\1\101\1\54\1\102\1\101"+ + "\2\54\1\101\1\103\2\101\1\54\1\102\2\101\1\104"+ + "\1\105\7\104\1\106\12\104\23\106\2\104\3\106\3\104"+ + "\2\106\1\104\1\106\2\104\2\106\4\104\1\106\3\104"+ + "\11\107\1\110\12\107\23\110\2\107\3\110\3\107\2\110"+ + "\1\107\1\110\2\107\2\110\1\111\3\107\1\110\3\107"+ + "\4\0\1\112\72\0\2\27\1\113\5\27\1\114\3\27"+ + "\1\40\6\27\1\46\35\27\1\47\10\27\1\50\3\27"+ + "\1\47\3\71\1\72\4\71\1\115\2\76\2\71\1\56"+ + "\1\76\5\71\23\76\2\56\3\76\2\56\1\71\2\76"+ + "\1\71\1\76\1\71\1\116\2\76\4\71\1\76\1\117"+ + "\2\71\6\27\1\120\1\121\1\122\2\27\1\123\1\124"+ + "\44\27\1\125\7\27\1\126\1\127\3\27\1\125\4\52"+ + "\1\130\3\52\1\131\21\52\1\132\1\52\1\132\2\52"+ + "\1\132\2\52\1\132\1\52\1\132\13\52\1\132\5\52"+ + "\1\132\14\52\1\130\3\52\1\131\66\52\116\0\1\133"+ + "\67\0\1\134\4\0\1\135\31\0\2\135\3\0\2\135"+ + "\1\136\43\0\1\137\53\0\1\140\3\141\1\142\1\143"+ + "\1\141\1\143\1\141\2\140\1\144\1\145\1\140\6\141"+ + "\2\146\1\147\1\150\3\151\3\152\1\153\2\154\2\155"+ + "\3\156\1\157\1\160\1\161\1\162\1\163\1\164\2\161"+ + "\1\140\1\165\1\166\1\145\1\167\2\140\1\152\1\157"+ + "\3\140\1\170\1\157\2\140\1\145\45\0\1\171\33\0"+ + "\2\54\5\0\5\54\6\0\32\54\1\0\2\54\1\0"+ + "\1\54\2\0\2\54\4\0\1\54\20\0\1\56\31\0"+ + "\2\56\3\0\2\56\26\0\1\172\72\0\1\173\21\0"+ + "\1\174\43\0\1\173\1\175\15\0\1\176\13\0\1\177"+ + "\25\0\1\200\36\0\1\73\12\0\23\73\2\0\3\73"+ + "\3\0\2\73\1\0\1\73\2\0\2\73\4\0\1\73"+ + "\14\0\1\74\12\0\23\74\2\0\3\74\3\0\2\74"+ + "\1\0\1\74\2\0\2\74\4\0\1\74\13\0\7\76"+ + "\5\0\32\76\1\0\2\76\1\0\1\76\2\0\2\76"+ + "\4\0\1\76\12\0\1\201\70\0\1\202\76\0\1\202"+ + "\5\0\1\203\70\0\1\202\7\0\1\204\1\0\1\204"+ + "\1\0\1\205\6\0\23\204\2\205\3\204\2\205\1\0"+ + "\2\204\1\0\1\204\2\0\2\204\4\0\1\204\72\0"+ + "\1\202\11\0\2\54\5\0\5\54\6\0\32\54\1\0"+ + "\2\54\1\0\1\54\2\0\2\54\1\202\3\0\1\54"+ + "\12\0\1\206\57\0\1\202\14\0\1\207\17\0\2\210"+ + "\1\0\1\210\4\0\3\210\5\0\4\210\3\0\2\210"+ + "\40\0\1\211\43\0\1\212\1\213\12\0\6\140\1\141"+ + "\1\140\1\141\2\140\1\144\10\140\2\146\1\157\1\214"+ + "\3\157\3\152\1\153\2\154\2\155\3\156\1\157\1\160"+ + "\1\161\1\162\1\163\1\164\2\161\1\140\1\165\1\166"+ + "\1\140\1\157\2\140\2\157\3\140\1\170\1\157\11\140"+ + "\1\141\1\140\1\215\2\216\1\217\3\216\5\140\2\220"+ + "\1\221\1\222\3\221\3\223\1\224\2\225\2\226\3\227"+ + "\1\221\1\230\1\231\1\232\1\233\1\234\2\231\1\140"+ + "\1\235\1\236\1\140\1\221\2\140\2\221\3\140\1\170"+ + "\1\221\3\140\3\0\1\237\76\0\1\240\74\0\1\241"+ + "\21\0\1\242\43\0\2\241\6\0\6\140\3\141\2\140"+ + "\1\144\1\243\7\140\3\146\1\214\3\157\3\152\1\153"+ + "\2\154\2\155\3\156\1\157\1\160\1\161\1\162\1\163"+ + "\1\164\2\161\1\140\1\165\1\166\1\243\1\157\2\140"+ + "\2\157\3\140\1\170\1\157\2\140\1\243\71\0\1\244"+ + "\7\0\1\245\17\0\1\246\17\0\1\247\20\0\1\250"+ + "\1\251\2\0\1\252\1\253\1\254\1\255\1\0\1\256"+ + "\1\257\6\0\1\260\76\0\1\261\2\0\1\262\4\0"+ + "\1\135\31\0\2\135\3\0\2\135\1\263\25\0\1\264"+ + "\2\0\1\265\4\0\1\266\31\0\2\266\3\0\2\266"+ + "\36\0\1\267\31\0\2\267\3\0\2\267\1\270\24\0"+ + "\1\271\76\0\1\272\43\0\1\273\3\0\2\273\5\0"+ + "\1\274\1\275\12\0\77\276\47\0\1\277\4\0\1\300"+ + "\1\277\70\0\2\301\3\0\2\301\25\0\1\302\20\0"+ + "\2\303\1\0\1\303\4\0\3\303\5\0\4\303\3\0"+ + "\2\303\25\0\1\304\20\0\2\305\1\0\1\305\4\0"+ + "\3\305\5\0\4\305\3\0\2\305\104\0\1\306\1\307"+ + "\21\0\1\310\100\0\1\204\1\0\1\204\1\0\1\205"+ + "\6\0\23\204\2\205\3\204\2\205\1\0\2\204\1\0"+ + "\1\204\2\0\2\204\4\0\1\204\10\0\1\311\17\0"+ + "\2\210\1\0\1\210\4\0\3\210\5\0\4\210\3\0"+ + "\2\210\104\0\1\312\3\0\1\313\5\0\1\314\5\0"+ + "\1\272\43\0\1\273\3\0\2\273\25\0\1\272\3\0"+ + "\7\76\5\0\24\76\1\315\3\76\2\315\1\0\2\76"+ + "\1\0\1\76\2\0\2\76\4\0\1\76\3\0\10\276"+ + "\7\316\5\276\32\316\1\276\2\316\1\276\1\316\2\276"+ + "\2\316\4\276\1\316\3\276\10\0\7\76\5\0\23\76"+ + "\1\317\4\76\1\320\1\317\1\0\2\76\1\0\1\76"+ + "\2\0\2\76\4\0\1\76\13\0\7\76\5\0\23\76"+ + "\2\321\3\76\2\321\1\0\2\76\1\0\1\76\2\0"+ + "\2\76\4\0\1\76\7\0\1\302\3\0\7\76\5\0"+ + "\1\76\2\322\1\76\1\322\4\76\3\322\5\76\4\322"+ + "\3\76\2\322\1\0\2\76\1\0\1\76\2\0\2\76"+ + "\4\0\1\76\7\0\1\304\3\0\7\76\5\0\1\76"+ + "\2\323\1\76\1\323\4\76\3\323\5\76\4\323\3\76"+ + "\2\323\1\0\2\76\1\0\1\76\2\0\2\76\4\0"+ + "\1\76\66\0\1\324\3\0\1\325\4\0\1\254\71\0"+ + "\1\326\5\0\1\327\1\0\3\330\1\0\73\330\5\0"+ + "\1\331\76\0\1\261\2\0\1\262\4\0\1\263\31\0"+ + "\2\263\3\0\2\263\26\0\1\332\76\0\1\333\2\0"+ + "\1\334\4\0\1\266\31\0\2\266\3\0\2\266\26\0"+ + "\1\335\7\0\1\267\31\0\2\267\3\0\2\267\1\336"+ + "\25\0\1\337\7\0\1\340\31\0\2\340\3\0\2\340"+ + "\50\0\1\341\62\0\1\342\34\0\1\343\3\0\2\343"+ + "\70\0\2\344\3\0\2\344\70\0\1\345\4\0\2\345"+ + "\70\0\1\346\4\0\2\346\70\0\2\347\3\0\2\347"+ + "\46\0\2\350\1\0\1\350\4\0\3\350\5\0\4\350"+ + "\3\0\2\350\46\0\2\351\1\0\1\351\4\0\3\351"+ + "\5\0\4\351\3\0\2\351\110\0\1\352\5\0\1\353"+ + "\11\0\7\76\5\0\23\76\2\354\3\76\2\354\1\0"+ + "\2\76\1\0\1\76\2\0\2\76\4\0\1\76\13\0"+ + "\7\76\5\0\23\76\1\355\4\76\2\355\1\0\2\76"+ + "\1\0\1\76\2\0\2\76\4\0\1\76\13\0\7\76"+ + "\5\0\23\76\1\356\4\76\2\356\1\0\2\76\1\0"+ + "\1\76\2\0\2\76\4\0\1\76\13\0\7\76\5\0"+ + "\23\76\2\357\3\76\2\357\1\0\2\76\1\0\1\76"+ + "\2\0\2\76\4\0\1\76\13\0\7\76\5\0\1\76"+ + "\2\360\1\76\1\360\4\76\3\360\5\76\4\360\3\76"+ + "\2\360\1\0\2\76\1\0\1\76\2\0\2\76\4\0"+ + "\1\76\13\0\7\76\5\0\1\76\2\361\1\76\1\361"+ + "\4\76\3\361\5\76\4\361\3\76\2\361\1\0\2\76"+ + "\1\0\1\76\2\0\2\76\4\0\1\76\3\0\3\330"+ + "\1\362\73\330\5\0\1\363\76\0\1\335\7\0\1\336"+ + "\31\0\2\336\3\0\2\336\26\0\1\364\7\0\1\340"+ + "\31\0\2\340\3\0\2\340\26\0\1\151\141\0\1\343"+ + "\3\0\2\343\26\0\1\365\41\0\2\366\3\0\2\366"+ + "\70\0\2\365\3\0\2\365\70\0\1\367\4\0\2\367"+ + "\46\0\2\370\1\0\1\370\4\0\3\370\5\0\4\370"+ + "\3\0\2\370\31\0\7\76\5\0\23\76\2\371\3\76"+ + "\2\371\1\0\2\76\1\0\1\76\2\0\2\76\4\0"+ + "\1\76\13\0\7\76\5\0\23\76\1\372\4\76\2\372"+ + "\1\0\2\76\1\0\1\76\2\0\2\76\4\0\1\76"+ + "\13\0\7\76\5\0\1\76\2\373\1\76\1\373\4\76"+ + "\3\373\5\76\4\373\3\76\2\373\1\0\2\76\1\0"+ + "\1\76\2\0\2\76\4\0\1\76\10\0\1\365\41\0"+ + "\2\374\3\0\2\374\46\0\2\375\1\0\1\375\4\0"+ + "\3\375\5\0\4\375\3\0\2\375\31\0\7\76\5\0"+ + "\1\76\2\376\1\76\1\376\4\76\3\376\5\76\4\376"+ + "\3\76\2\376\1\0\2\76\1\0\1\76\2\0\2\76"+ + "\4\0\1\76\10\0\1\365\71\0"; private static int [] zzUnpackTrans() { - int [] result = new int[5922]; + int [] result = new int[7371]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -445,21 +500,22 @@ class _RegExLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\14\0\1\1\10\0\2\11\1\1\1\11\1\1\1\11"+ + "\11\0\1\1\14\0\2\11\1\1\1\11\1\1\1\11"+ "\1\1\1\11\1\1\11\11\1\1\2\11\1\1\1\11"+ "\1\1\1\11\1\0\2\11\1\1\1\11\1\1\1\11"+ - "\1\1\1\11\1\1\1\11\1\1\3\11\1\1\2\11"+ - "\1\1\3\11\2\1\1\11\1\1\4\11\11\1\3\0"+ + "\1\1\3\11\2\1\1\11\1\1\4\11\16\1\1\11"+ + "\1\1\3\11\1\1\2\11\1\1\1\11\1\1\3\0"+ "\3\11\1\1\4\11\2\1\2\11\1\1\4\11\2\1"+ - "\1\11\2\1\2\11\1\1\14\11\1\1\2\11\1\0"+ - "\1\11\1\1\3\11\1\1\2\11\1\0\1\1\4\11"+ - "\1\0\4\11\2\0\1\11\6\0\1\1\3\11\3\1"+ - "\1\11\1\1\1\11\1\1\10\11\1\0\3\11\1\0"+ - "\1\11\1\0\1\11\4\0\2\1\3\11\1\1\4\11"+ - "\1\0\1\11\1\1\1\0\1\11"; + "\1\11\2\1\2\11\1\1\12\11\1\0\1\11\1\1"+ + "\3\11\1\1\1\0\2\11\23\1\10\11\1\0\1\1"+ + "\4\11\1\0\4\11\2\0\1\11\6\0\1\1\3\11"+ + "\3\1\1\11\1\1\1\11\1\1\4\11\1\0\2\11"+ + "\7\1\4\11\1\0\3\11\1\0\1\11\1\0\1\11"+ + "\4\0\2\1\3\11\1\1\2\11\6\1\4\11\1\0"+ + "\1\11\4\1\1\0\1\11\1\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[203]; + int [] result = new int[254]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -846,326 +902,331 @@ class _RegExLexer implements FlexLexer { { yypopstate(); return RegExpTT.COMMENT; } // fall through - case 127: break; + case 136: break; case 2: { return RegExpTT.CHARACTER; } // fall through - case 128: break; + case 137: break; case 3: { return RegExpTT.DOT; } // fall through - case 129: break; + case 138: break; case 4: { capturingGroupCount++; return RegExpTT.GROUP_BEGIN; } // fall through - case 130: break; + case 139: break; case 5: { return RegExpTT.GROUP_END; } // fall through - case 131: break; + case 140: break; case 6: { if (allowDanglingMetacharacters != TRUE) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } return RegExpTT.CHARACTER; } // fall through - case 132: break; + case 141: break; case 7: { return (allowDanglingMetacharacters != FALSE) ? RegExpTT.CHARACTER : RegExpTT.RBRACE; } // fall through - case 133: break; + case 142: break; case 8: { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } // fall through - case 134: break; + case 143: break; case 9: { return allowDanglingMetacharacters == FALSE ? RegExpTT.CLASS_END : RegExpTT.CHARACTER; } // fall through - case 135: break; + case 144: break; case 10: { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } // fall through - case 136: break; + case 145: break; case 11: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; } // fall through - case 137: break; + case 146: break; case 12: { return RegExpTT.DOLLAR; } // fall through - case 138: break; + case 147: break; case 13: { return RegExpTT.QUEST; } // fall through - case 139: break; + case 148: break; case 14: { return RegExpTT.STAR; } // fall through - case 140: break; + case 149: break; case 15: { return RegExpTT.PLUS; } // fall through - case 141: break; + case 150: break; case 16: { return RegExpTT.UNION; } // fall through - case 142: break; + case 151: break; case 17: { return RegExpTT.CARET; } // fall through - case 143: break; + case 152: break; case 18: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER; } // fall through - case 144: break; + case 153: break; case 19: { if (commentMode) { yypushstate(COMMENT); } else return RegExpTT.CHARACTER; } // fall through - case 145: break; + case 154: break; case 20: { yypopstate(); yypushback(1); } // fall through - case 146: break; + case 155: break; case 21: { yypopstate(); return RegExpTT.RBRACE; } // fall through - case 147: break; + case 156: break; case 22: { return RegExpTT.NAME; } // fall through - case 148: break; + case 157: break; case 23: { return RegExpTT.EQ; } // fall through - case 149: break; + case 158: break; case 24: { return RegExpTT.NUMBER; } // fall through - case 150: break; + case 159: break; case 25: { return RegExpTT.COMMA; } // fall through - case 151: break; + case 160: break; case 26: { yybegin(CLASS1); return RegExpTT.CARET; } // fall through - case 152: break; + case 161: break; case 27: { states.set(states.size() - 1, CLASS2); return RegExpTT.CHARACTER; } // fall through - case 153: break; + case 162: break; case 28: { yypushback(1); yybegin(CLASS2); } // fall through - case 154: break; + case 163: break; case 29: { yybegin(CLASS2); if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } return RegExpTT.CHARACTER; } // fall through - case 155: break; + case 164: break; case 30: { if (allowEmptyCharacterClass) { yypopstate(); return RegExpTT.CLASS_END; } yybegin(CLASS2); return RegExpTT.CHARACTER; } // fall through - case 156: break; + case 165: break; case 31: { if (commentMode && whitespaceInClass) return com.intellij.psi.TokenType.WHITE_SPACE; yypushback(1); yybegin(CLASS2); } // fall through - case 157: break; + case 166: break; case 32: - { if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } return RegExpTT.CHARACTER; - } - // fall through - case 158: break; - case 33: - { yypopstate(); return RegExpTT.CLASS_END; - } - // fall through - case 159: break; - case 34: - { return RegExpTT.MINUS; - } - // fall through - case 160: break; - case 35: - { return (commentMode && whitespaceInClass) ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; - } - // fall through - case 161: break; - case 36: - { return (commentMode && whitespaceInClass) ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER; - } - // fall through - case 162: break; - case 37: - { if (commentMode && whitespaceInClass) yypushstate(COMMENT); else return RegExpTT.CHARACTER; - } - // fall through - case 163: break; - case 38: - { yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE; - } - // fall through - case 164: break; - case 39: - { yypopstate(); return RegExpTT.CATEGORY_SHORT_HAND; - } - // fall through - case 165: break; - case 40: { yybegin(YYINITIAL); yypushback(1); } // fall through - case 166: break; - case 41: + case 167: break; + case 33: { yybegin(YYINITIAL); return RegExpTT.GROUP_END; } // fall through - case 167: break; - case 42: + case 168: break; + case 34: { handleOptions(); return RegExpTT.OPTIONS_ON; } // fall through - case 168: break; - case 43: + case 169: break; + case 35: { handleOptions(); return RegExpTT.OPTIONS_OFF; } // fall through - case 169: break; - case 44: + case 170: break; + case 36: { yybegin(YYINITIAL); return RegExpTT.COLON; } // fall through - case 170: break; - case 45: + case 171: break; + case 37: { yybegin(YYINITIAL); return RegExpTT.GT; } // fall through - case 171: break; - case 46: + case 172: break; + case 38: { yybegin(YYINITIAL); return RegExpTT.QUOTE; } // fall through - case 172: break; - case 47: + case 173: break; + case 39: { return RegExpTT.BAD_CHARACTER; } // fall through - case 173: break; - case 48: + case 174: break; + case 40: { return allowMysqlBracketExpressions ? RegExpTT.NAME : RegExpTT.BAD_CHARACTER; } // fall through - case 174: break; - case 49: + case 175: break; + case 41: { yypopstate(); return (yycharat(-1) == 'u') ? StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN : RegExpTT.BAD_HEX_VALUE; } // fall through - case 175: break; + case 176: break; + case 42: + { yybegin(CONDITIONAL2); return RegExpTT.GROUP_BEGIN; + } + // fall through + case 177: break; + case 43: + { if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } return RegExpTT.CHARACTER; + } + // fall through + case 178: break; + case 44: + { yypopstate(); return RegExpTT.CLASS_END; + } + // fall through + case 179: break; + case 45: + { return RegExpTT.MINUS; + } + // fall through + case 180: break; + case 46: + { return (commentMode && whitespaceInClass) ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; + } + // fall through + case 181: break; + case 47: + { return (commentMode && whitespaceInClass) ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER; + } + // fall through + case 182: break; + case 48: + { if (commentMode && whitespaceInClass) yypushstate(COMMENT); else return RegExpTT.CHARACTER; + } + // fall through + case 183: break; + case 49: + { yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE; + } + // fall through + case 184: break; case 50: + { yypopstate(); return RegExpTT.CATEGORY_SHORT_HAND; + } + // fall through + case 185: break; + case 51: { yybegin(OPTIONS); return RegExpTT.SET_OPTIONS; } // fall through - case 176: break; - case 51: + case 186: break; + case 52: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yypushstate(NEGATED_CLASS); return RegExpTT.CLASS_BEGIN; } // fall through - case 177: break; - case 52: + case 187: break; + case 53: { return RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 178: break; - case 53: + case 188: break; + case 54: { return RegExpTT.ESC_CHARACTER; } // fall through - case 179: break; - case 54: + case 189: break; + case 55: { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 180: break; - case 55: + case 190: break; + case 56: { return (allowDanglingMetacharacters == FALSE) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 181: break; - case 56: + case 191: break; + case 57: { return (yystate() == CLASS2) ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 182: break; - case 57: + case 192: break; + case 58: { return commentMode ? RegExpTT.ESC_CTRL_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 183: break; - case 58: + case 193: break; + case 59: { return RegExpTT.ESC_CTRL_CHARACTER; } // fall through - case 184: break; - case 59: + case 194: break; + case 60: { return RegExpTT.BOUNDARY; } // fall through - case 185: break; - case 60: + case 195: break; + case 61: { return RegExpTT.CHAR_CLASS; } // fall through - case 186: break; - case 61: + case 196: break; + case 62: { if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } // fall through - case 187: break; - case 62: + case 197: break; + case 63: { yypushstate(PROP); return RegExpTT.PROPERTY; } // fall through - case 188: break; - case 63: + case 198: break; + case 64: { return allowTransformationEscapes ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } // fall through - case 189: break; - case 64: + case 199: break; + case 65: { return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE); } // fall through - case 190: break; - case 65: + case 200: break; + case 66: { String text = yytext().toString().substring(1); if (allowOctalNoLeadingZero) { if (Integer.parseInt(text) <= capturingGroupCount && yystate() != CLASS2) return RegExpTT.BACKREF; @@ -1208,87 +1269,122 @@ class _RegExLexer implements FlexLexer { } } // fall through - case 191: break; - case 66: + case 201: break; + case 67: { yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN; } // fall through - case 192: break; - case 67: + case 202: break; + case 68: { return RegExpTT.BAD_HEX_VALUE; } // fall through - case 193: break; - case 68: + case 203: break; + case 69: { return allowTransformationEscapes ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; } // fall through - case 194: break; - case 69: + case 204: break; + case 70: { return (allowHexDigitClass || allowHorizontalWhitespaceClass ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN); } // fall through - case 195: break; - case 70: + case 205: break; + case 71: { yypushstate(NAMED); return RegExpTT.NAMED_CHARACTER; } // fall through - case 196: break; - case 71: + case 206: break; + case 72: { return commentMode ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 197: break; - case 72: + case 207: break; + case 73: { yypopstate(); return RegExpTT.QUOTE_END; } // fall through - case 198: break; - case 73: + case 208: break; + case 74: { yypopstate(); return RegExpTT.ESC_CHARACTER; } // fall through - case 199: break; - case 74: + case 209: break; + case 75: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yybegin(CLASS2); if (allowMysqlBracketExpressions) { yypushback(1); } else if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } else { return RegExpTT.CHARACTER; } } // fall through - case 200: break; - case 75: + case 210: break; + case 76: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yybegin(CLASS2); if (allowNestedCharacterClasses) { yypushstate(NEGATED_CLASS); return RegExpTT.CLASS_BEGIN; } return RegExpTT.CHARACTER; } // fall through - case 201: break; - case 76: + case 211: break; + case 77: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yybegin(CLASS2); if (allowPosixBracketExpressions) { yypushback(1); } else if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } else { return RegExpTT.CHARACTER; } } // fall through - case 202: break; - case 77: + case 212: break; + case 78: { yybegin(CLASS2); return allowEmptyCharacterClass ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 203: break; - case 78: + case 213: break; + case 79: { yybegin(CLASS2); return RegExpTT.ESC_CHARACTER; } // fall through - case 204: break; - case 79: - { yypushstate(QUOTED_CLASS1); return RegExpTT.QUOTE_BEGIN; + case 214: break; + case 80: + { yypushstate(QUOTED_CLASS); return RegExpTT.QUOTE_BEGIN; } // fall through - case 205: break; - case 80: + case 215: break; + case 81: + { yybegin(CLASS2); return RegExpTT.BRACKET_EXPRESSION_END; + } + // fall through + case 216: break; + case 82: + { yybegin(CLASS2); return RegExpTT.MYSQL_CHAR_END; + } + // fall through + case 217: break; + case 83: + { yybegin(CLASS2); return RegExpTT.MYSQL_CHAR_EQ_END; + } + // fall through + case 218: break; + case 84: + { yybegin(CONDITIONAL2); return RegExpTT.ANGLE_BRACKET_CONDITION_BEGIN; + } + // fall through + case 219: break; + case 85: + { yybegin(CONDITIONAL2); return RegExpTT.QUOTED_CONDITION_BEGIN; + } + // fall through + case 220: break; + case 86: + { yybegin(YYINITIAL); return RegExpTT.QUOTED_CONDITION_END; + } + // fall through + case 221: break; + case 87: + { yybegin(YYINITIAL); return RegExpTT.ANGLE_BRACKET_CONDITION_END; + } + // fall through + case 222: break; + case 88: { char c = yycharat(1); if (allowPosixBracketExpressions && c == ':') { yybegin(BRACKET_EXPRESSION); @@ -1310,279 +1406,287 @@ class _RegExLexer implements FlexLexer { } } // fall through - case 206: break; - case 81: + case 223: break; + case 89: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowNestedCharacterClasses) { yypushstate(NEGATED_CLASS); return RegExpTT.CLASS_BEGIN; } return RegExpTT.CHARACTER; } // fall through - case 207: break; - case 82: + case 224: break; + case 90: { return (commentMode && whitespaceInClass) ? RegExpTT.ESC_CTRL_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 208: break; - case 83: + case 225: break; + case 91: { if (allowNestedCharacterClasses) return RegExpTT.ANDAND; else yypushback(1); return RegExpTT.CHARACTER; } // fall through - case 209: break; - case 84: - { yybegin(CLASS2); return RegExpTT.BRACKET_EXPRESSION_END; + case 226: break; + case 92: + // lookahead expression with fixed base length + zzMarkedPos = Character.offsetByCodePoints + (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); + { yybegin(CONDITIONAL1); return RegExpTT.CONDITIONAL; } // fall through - case 210: break; - case 85: - { yybegin(CLASS2); return RegExpTT.MYSQL_CHAR_END; - } - // fall through - case 211: break; - case 86: - { yybegin(CLASS2); return RegExpTT.MYSQL_CHAR_EQ_END; - } - // fall through - case 212: break; - case 87: - { yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF; - } - // fall through - case 213: break; - case 88: + case 227: break; + case 93: { return RegExpTT.PCRE_BRANCH_RESET; } // fall through - case 214: break; - case 89: + case 228: break; + case 94: { yybegin(NAMED_GROUP); capturingGroupCount++; return RegExpTT.RUBY_NAMED_GROUP; } // fall through - case 215: break; - case 90: + case 229: break; + case 95: { yybegin(QUOTED_NAMED_GROUP); capturingGroupCount++; return RegExpTT.RUBY_QUOTED_NAMED_GROUP; } // fall through - case 216: break; - case 91: + case 230: break; + case 96: { return RegExpTT.POS_LOOKAHEAD; } // fall through - case 217: break; - case 92: + case 231: break; + case 97: { return RegExpTT.NON_CAPT_GROUP; } // fall through - case 218: break; - case 93: + case 232: break; + case 98: { yybegin(NAMED_GROUP); return RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF; } // fall through - case 219: break; - case 94: + case 233: break; + case 99: { return RegExpTT.ATOMIC_GROUP; } // fall through - case 220: break; - case 95: + case 234: break; + case 100: { return RegExpTT.NEG_LOOKAHEAD; } // fall through - case 221: break; - case 96: + case 235: break; + case 101: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { return (allowDanglingMetacharacters != TRUE) ? RegExpTT.LBRACE : RegExpTT.CHARACTER; } // fall through - case 222: break; - case 97: + case 236: break; + case 102: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } // fall through - case 223: break; - case 98: + case 237: break; + case 103: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowOmitBothNumbersInQuantifiers || allowDanglingMetacharacters != TRUE) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } else return RegExpTT.CHARACTER; } // fall through - case 224: break; - case 99: + case 238: break; + case 104: { return allowPcreBackReferences ? RegExpTT.BACKREF : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } // fall through - case 225: break; - case 100: + case 239: break; + case 105: { yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP_CALL; } // fall through - case 226: break; - case 101: + case 240: break; + case 106: { yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP_CALL; } // fall through - case 227: break; - case 102: + case 241: break; + case 107: { if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL; } // fall through - case 228: break; - case 103: + case 242: break; + case 108: { return RegExpTT.OCT_CHAR; } // fall through - case 229: break; - case 104: + case 243: break; + case 109: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); { if (allowExtendedUnicodeCharacter) yypushstate(EMBRACED_HEX); else return RegExpTT.BAD_HEX_VALUE; } // fall through - case 230: break; - case 105: + case 244: break; + case 110: { if (allowOneHexCharEscape) { return RegExpTT.HEX_CHAR; } else { yypushback(1); return RegExpTT.BAD_HEX_VALUE; } } // fall through - case 231: break; - case 106: + case 245: break; + case 111: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); { if (allowExtendedUnicodeCharacter) yypushstate(EMBRACED_HEX); else return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; } // fall through - case 232: break; - case 107: + case 246: break; + case 112: { yypushback(yylength() - 2); return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; } // fall through - case 233: break; - case 108: + case 247: break; + case 113: { yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP_REF; } // fall through - case 234: break; - case 109: + case 248: break; + case 114: { yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP_REF; } // fall through - case 235: break; - case 110: + case 249: break; + case 115: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { return RegExpTT.CHARACTER; } // fall through - case 236: break; - case 111: + case 250: break; + case 116: { yypopstate(); return (yycharat(-1) == 'u') ? RegExpTT.UNICODE_CHAR : RegExpTT.HEX_CHAR; } // fall through - case 237: break; - case 112: + case 251: break; + case 117: + { yybegin(YYINITIAL); return RegExpTT.POS_LOOKAHEAD; + } + // fall through + case 252: break; + case 118: + { yybegin(YYINITIAL); return RegExpTT.NEG_LOOKAHEAD; + } + // fall through + case 253: break; + case 119: { yybegin(NAMED_GROUP); capturingGroupCount++; return RegExpTT.PYTHON_NAMED_GROUP; } // fall through - case 238: break; - case 113: + case 254: break; + case 120: { yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF; } // fall through - case 239: break; - case 114: + case 255: break; + case 121: { return RegExpTT.POS_LOOKBEHIND; } // fall through - case 240: break; - case 115: + case 256: break; + case 122: { return RegExpTT.NEG_LOOKBEHIND; } // fall through - case 241: break; - case 116: + case 257: break; + case 123: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowDanglingMetacharacters != TRUE) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } else { yypushstate(NON_QUANTIFIER); return RegExpTT.CHARACTER; } } // fall through - case 242: break; - case 117: + case 258: break; + case 124: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowDanglingMetacharacters == TRUE) { if (allowOmitBothNumbersInQuantifiers) yypushstate(NON_QUANTIFIER); return RegExpTT.CHARACTER; } else { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } } // fall through - case 243: break; - case 118: + case 259: break; + case 125: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowOmitNumbersInQuantifiers || allowDanglingMetacharacters != TRUE) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } else return RegExpTT.CHARACTER; } // fall through - case 244: break; - case 119: + case 260: break; + case 126: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); { return RegExpTT.ESC_CHARACTER; } // fall through - case 245: break; - case 120: + case 261: break; + case 127: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); { return allowOmitBothNumbersInQuantifiers ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 246: break; - case 121: + case 262: break; + case 128: { return RegExpTT.HEX_CHAR; } // fall through - case 247: break; - case 122: + case 263: break; + case 129: + { yybegin(YYINITIAL); return RegExpTT.POS_LOOKBEHIND; + } + // fall through + case 264: break; + case 130: + { yybegin(YYINITIAL); return RegExpTT.NEG_LOOKBEHIND; + } + // fall through + case 265: break; + case 131: { return RegExpTT.COMMENT; } // fall through - case 248: break; - case 123: + case 266: break; + case 132: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 1); { if (allowDanglingMetacharacters != TRUE) { yypushstate(QUANTIFIER); return RegExpTT.LBRACE; } else if (allowOmitNumbersInQuantifiers) yypushstate(NON_QUANTIFIER); return RegExpTT.CHARACTER; } // fall through - case 249: break; - case 124: + case 267: break; + case 133: // lookahead expression with fixed base length zzMarkedPos = Character.offsetByCodePoints (zzBufferL/*, zzStartRead, zzEndRead - zzStartRead*/, zzStartRead, 2); { return allowOmitNumbersInQuantifiers ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } // fall through - case 250: break; - case 125: + case 268: break; + case 134: { if (allowOctalNoLeadingZero) yypushback(1); return RegExpTT.OCT_CHAR; } // fall through - case 251: break; - case 126: + case 269: break; + case 135: { return RegExpTT.UNICODE_CHAR; } // fall through - case 252: break; + case 270: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/RegExpSupport/resources/messages/RegExpBundle.properties b/RegExpSupport/resources/messages/RegExpBundle.properties index 0e4258b5a9e2..835334cdaf0a 100644 --- a/RegExpSupport/resources/messages/RegExpBundle.properties +++ b/RegExpSupport/resources/messages/RegExpBundle.properties @@ -40,6 +40,7 @@ error.illegal.unicode.escape.sequence=Illegal unicode escape sequence error.illegal.unsupported.escape.sequence=Illegal/unsupported escape sequence error.invalid.group.name=Invalid group name error.look.behind.groups.are.not.supported.in.this.regex.dialect=Look-behind groups are not supported in this regex dialect +error.lookaround.conditions.in.conditionals.not.supported.in.this.regex.dialect=Lookaround conditions for conditionals are not supported in this regex dialect error.named.group.reference.not.allowed.inside.lookbehind=Named group reference not allowed inside lookbehind error.named.unicode.characters.are.not.allowed.in.this.regex.dialect=Named Unicode characters are not allowed in this regex dialect error.nested.quantifier.in.regexp=Nested quantifier in regexp @@ -49,6 +50,7 @@ error.redundant.group.nesting=Redundant group nesting error.repetition.value.too.large=Repetition value too large error.this.boundary.is.not.supported.in.this.regex.dialect=This boundary is not supported in this regex dialect error.this.hex.character.syntax.is.not.supported.in.this.regex.dialect=This hex character syntax is not supported in this regex dialect +error.this.kind.group.reference.condition.not.supported.in.this.regex.dialect=This kind of group reference condition is not supported in this regex dialect error.this.named.group.reference.syntax.is.not.supported.in.this.regex.dialect=This named group reference syntax is not supported in this regex dialect error.this.named.group.syntax.is.not.supported.in.this.regex.dialect=This named group syntax is not supported in this regex dialect error.unequal.min.and.max.in.counted.quantifier.not.allowed.inside.lookbehind=Unequal min and max in counted quantifier not allowed inside lookbehind diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpBraceMatcher.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpBraceMatcher.java index f06131c8883e..3ca0b091b1f1 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpBraceMatcher.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpBraceMatcher.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.lang.regexp; import com.intellij.lang.BracePair; @@ -34,7 +20,7 @@ public class RegExpBraceMatcher implements PairedBraceMatcher { new BracePair(RegExpTT.PYTHON_NAMED_GROUP, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.PYTHON_NAMED_GROUP_REF, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF, RegExpTT.GROUP_END, true), - new BracePair(RegExpTT.PCRE_COND_REF, RegExpTT.GROUP_END, true), + new BracePair(RegExpTT.CONDITIONAL, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.PCRE_BRANCH_RESET, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.RUBY_NAMED_GROUP, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.RUBY_QUOTED_NAMED_GROUP, RegExpTT.GROUP_END, true), diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java index 0cc24ee9aea3..44e73365a216 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpHighlighter.java @@ -116,8 +116,7 @@ public class RegExpHighlighter extends SyntaxHighlighterBase { ourMap.put(RegExpTT.PYTHON_NAMED_GROUP, PARENTHS); ourMap.put(RegExpTT.PYTHON_NAMED_GROUP_REF, PARENTHS); ourMap.put(RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF, PARENTHS); - ourMap.put(RegExpTT.PYTHON_COND_REF, PARENTHS); - ourMap.put(RegExpTT.PCRE_COND_REF, PARENTHS); + ourMap.put(RegExpTT.CONDITIONAL, PARENTHS); ourMap.put(RegExpTT.RUBY_NAMED_GROUP, PARENTHS); ourMap.put(RegExpTT.RUBY_QUOTED_NAMED_GROUP, PARENTHS); ourMap.put(RegExpTT.GROUP_BEGIN, PARENTHS); diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java index d4f5cc47dbd9..825d0e4a44fb 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHost.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.lang.regexp; import com.intellij.psi.PsiElement; @@ -19,7 +19,20 @@ public interface RegExpLanguageHost { boolean characterNeedsEscaping(char c); boolean supportsPerl5EmbeddedComments(); boolean supportsPossessiveQuantifiers(); + + /** + * @return true, if this dialects support conditionals, i.e. the following construct: {@code (?(1)then|else)} + */ boolean supportsPythonConditionalRefs(); + + /** + * @param condition a RegExpBackRef, RegExpNamedGroupRef or RegExpGroup instance. + * @return true, if this type of conditional condition is supported + */ + default boolean supportConditionalCondition(RegExpAtom condition) { + return true; + } + boolean supportsNamedGroupSyntax(RegExpGroup group); boolean supportsNamedGroupRefSyntax(RegExpNamedGroupRef ref); @NotNull diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHosts.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHosts.java index a3ad0f5c36ae..d9e0ca527e19 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHosts.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLanguageHosts.java @@ -123,6 +123,11 @@ public final class RegExpLanguageHosts extends ClassExtension myCapabilities; @@ -407,7 +405,7 @@ public class RegExpParser implements PsiParser, LightPsiParser { parseGroupEnd(builder); marker.done(RegExpElementTypes.GROUP); } - else if (type == RegExpTT.PYTHON_NAMED_GROUP_REF || type == PCRE_RECURSIVE_NAMED_GROUP_REF) { + else if (type == RegExpTT.PYTHON_NAMED_GROUP_REF || type == RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF) { parseNamedGroupRef(builder, marker, RegExpTT.GROUP_END); } else if (type == RegExpTT.RUBY_NAMED_GROUP_REF || type == RegExpTT.RUBY_NAMED_GROUP_CALL) { @@ -416,16 +414,17 @@ public class RegExpParser implements PsiParser, LightPsiParser { else if (type == RegExpTT.RUBY_QUOTED_NAMED_GROUP_REF || type == RegExpTT.RUBY_QUOTED_NAMED_GROUP_CALL) { parseNamedGroupRef(builder, marker, RegExpTT.QUOTE); } - else if (type == RegExpTT.PYTHON_COND_REF || type == RegExpTT.PCRE_COND_REF) { + else if (type == RegExpTT.CONDITIONAL) { builder.advanceLexer(); - parseCondRefName(builder, type); - checkMatches(builder, RegExpTT.GROUP_END, RegExpBundle.message("parse.error.unclosed.group.reference")); + parseCondition(builder); parseBranch(builder); if (builder.getTokenType() == RegExpTT.UNION) { builder.advanceLexer(); parseBranch(builder); } - checkMatches(builder, RegExpTT.GROUP_END, RegExpBundle.message("parse.error.unclosed.group")); + if (!checkMatches(builder, RegExpTT.GROUP_END, RegExpBundle.message("parse.error.unclosed.group"))) { + parseGroupEnd(builder); + } marker.done(RegExpElementTypes.CONDITIONAL); } else if (type == RegExpTT.PROPERTY) { @@ -447,12 +446,54 @@ public class RegExpParser implements PsiParser, LightPsiParser { return marker; } - protected void parseCondRefName(PsiBuilder builder, IElementType condRefType) { - if (builder.getTokenType() == RegExpTT.NAME || builder.getTokenType() == RegExpTT.NUMBER) { + private void parseCondition(PsiBuilder builder) { + final IElementType type = builder.getTokenType(); + if (RegExpTT.LOOKAROUND_GROUPS.contains(type)) { + final PsiBuilder.Marker marker = builder.mark(); builder.advanceLexer(); + parseGroupEnd(builder); + marker.done(RegExpElementTypes.GROUP); } else { + if (RegExpTT.GROUP_BEGIN == type) { + parseGroupReferenceCondition(builder, RegExpTT.GROUP_END); + } + else if (RegExpTT.QUOTED_CONDITION_BEGIN == type) { + parseGroupReferenceCondition(builder, RegExpTT.QUOTED_CONDITION_END); + } + else if (RegExpTT.ANGLE_BRACKET_CONDITION_BEGIN == type) { + parseGroupReferenceCondition(builder, RegExpTT.ANGLE_BRACKET_CONDITION_END); + } + } + } + + private void parseGroupReferenceCondition(PsiBuilder builder, IElementType endToken) { + final PsiBuilder.Marker marker = builder.mark(); + builder.advanceLexer(); + final IElementType next = builder.getTokenType(); + final Boolean named; + if (next == RegExpTT.NAME) { + builder.advanceLexer(); + named = true; + } + else if (next == RegExpTT.NUMBER) { + builder.advanceLexer(); + named = false; + } + else { + named = null; builder.error(RegExpBundle.message("parse.error.group.name.or.number.expected")); + parsePattern(builder); + } + checkMatches(builder, endToken, RegExpBundle.message("parse.error.unclosed.group.reference")); + if (named == Boolean.TRUE) { + marker.done(RegExpElementTypes.NAMED_GROUP_REF); + } + else if (named == Boolean.FALSE) { + marker.done(RegExpElementTypes.BACKREF); + } + else { + marker.drop(); } } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java index 3cad7f9382d1..93f9758d116b 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpTT.java @@ -145,10 +145,13 @@ public interface RegExpTT { IElementType PCRE_RECURSIVE_NAMED_GROUP_REF = new RegExpElementType("PCRE_RECURSIVE_NAMED_GROUP"); /** (?P=name) */ IElementType PYTHON_NAMED_GROUP_REF = new RegExpElementType("PYTHON_NAMED_GROUP_REF"); - /** (?(id/name)yes-pattern|no-pattern) */ - IElementType PYTHON_COND_REF = new RegExpElementType("PYTHON_COND_REF"); - /** (?(condition pattern)yes-pattern|no-pattern) */ - IElementType PCRE_COND_REF = new RegExpElementType("PCRE_COND_REF"); + /** (?(id/name/lookaround)yes-pattern|no-pattern) */ + IElementType CONDITIONAL = new RegExpElementType("CONDITIONAL"); + /** (' */ + IElementType QUOTED_CONDITION_BEGIN = new RegExpElementType("QUOTED_CONDITION_BEGIN"); + IElementType QUOTED_CONDITION_END = new RegExpElementType("QUOTED_CONDITION_END"); + IElementType ANGLE_BRACKET_CONDITION_BEGIN = new RegExpElementType("ANGLE_BRACKET_CONDITION_BEGIN"); + IElementType ANGLE_BRACKET_CONDITION_END = new RegExpElementType("ANGLE_BRACKET_CONDITION_END"); /** (?|regex) */ IElementType PCRE_BRANCH_RESET = new RegExpElementType("PCRE_BRANCH_RESET"); /** (?... */ @@ -181,6 +184,7 @@ public interface RegExpTT { TokenSet QUANTIFIERS = TokenSet.create(QUEST, PLUS, STAR, LBRACE); TokenSet GROUPS = TokenSet.create(GROUP_BEGIN, NON_CAPT_GROUP, ATOMIC_GROUP, POS_LOOKAHEAD, NEG_LOOKAHEAD, POS_LOOKBEHIND, NEG_LOOKBEHIND, PCRE_BRANCH_RESET); + TokenSet LOOKAROUND_GROUPS = TokenSet.create(POS_LOOKAHEAD, NEG_LOOKAHEAD, POS_LOOKBEHIND, NEG_LOOKBEHIND); TokenSet BOUNDARIES = TokenSet.create(BOUNDARY, CARET, DOLLAR); } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpConditional.java b/RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpConditional.java index 2eac96b3c87b..1810f4dbcc1f 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpConditional.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/psi/RegExpConditional.java @@ -5,4 +5,10 @@ package org.intellij.lang.regexp.psi; * @author yole */ public interface RegExpConditional extends RegExpAtom { + + /** + * Returns condition of this conditional. This can be a numeric group reference, named group reference or lookaround group. + * @return a RegExpBackRef, RegExpNamedGroupRef or RegExpGroup instance. + */ + RegExpAtom getCondition(); } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl.java b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl.java index c1fa19014005..e0fae1e9d88e 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpBackrefImpl.java @@ -23,6 +23,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; import com.intellij.psi.SyntaxTraverser; import com.intellij.util.IncorrectOperationException; +import org.intellij.lang.regexp.RegExpTT; import org.intellij.lang.regexp.psi.RegExpBackref; import org.intellij.lang.regexp.psi.RegExpElementVisitor; import org.intellij.lang.regexp.psi.RegExpGroup; @@ -46,6 +47,10 @@ public class RegExpBackrefImpl extends RegExpElementImpl implements RegExpBackre @NotNull private String getIndexNumberText() { + final ASTNode node = getNode().findChildByType(RegExpTT.NUMBER); + if (node != null) { + return node.getText(); + } final String s = getUnescapedText(); assert s.charAt(0) == '\\'; boolean pcreBackReference = s.charAt(1) == 'g'; diff --git a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpConditionalImpl.java b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpConditionalImpl.java index 711d43c75e39..b857b78408f4 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpConditionalImpl.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpConditionalImpl.java @@ -2,8 +2,8 @@ package org.intellij.lang.regexp.psi.impl; import com.intellij.lang.ASTNode; -import org.intellij.lang.regexp.psi.RegExpElementVisitor; -import org.intellij.lang.regexp.psi.RegExpConditional; +import com.intellij.psi.PsiElement; +import org.intellij.lang.regexp.psi.*; /** * @author yole @@ -17,4 +17,13 @@ public class RegExpConditionalImpl extends RegExpElementImpl implements RegExpCo public void accept(RegExpElementVisitor visitor) { visitor.visitRegExpConditional(this); } + + @Override + public RegExpAtom getCondition() { + final PsiElement sibling = getFirstChild().getNextSibling(); + if (!(sibling instanceof RegExpBackref) && !(sibling instanceof RegExpNamedGroupRef) && !(sibling instanceof RegExpGroup)) { + return null; + } + return (RegExpAtom)sibling; + } } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpGroupImpl.java b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpGroupImpl.java index 72b513faacc6..e857354af372 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpGroupImpl.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/psi/impl/RegExpGroupImpl.java @@ -128,4 +128,9 @@ public class RegExpGroupImpl extends RegExpElementImpl implements RegExpGroup { public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { throw new IncorrectOperationException(); } + + @Override + public int getTextOffset() { + return getFirstChild().getNextSibling().getTextOffset(); + } } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex index ea0da21954cb..a1172d8f55c9 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex +++ b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex @@ -109,22 +109,24 @@ import static org.intellij.lang.regexp.RegExpCapability.*; %xstate QUANTIFIER %xstate NON_QUANTIFIER %xstate NEGATED_CLASS -%xstate QUOTED_CLASS1 +%xstate QUOTED_CLASS %xstate CLASS1 -%state CLASS2 -%state PROP -%state NAMED %xstate OPTIONS %xstate COMMENT %xstate NAMED_GROUP %xstate QUOTED_NAMED_GROUP %xstate PY_NAMED_GROUP_REF -%xstate PY_COND_REF %xstate BRACKET_EXPRESSION %xstate MYSQL_CHAR_EXPRESSION %xstate MYSQL_CHAR_EQ_EXPRESSION %xstate EMBRACED_HEX +%state CONDITIONAL1 +%state CONDITIONAL2 +%state CLASS2 +%state PROP +%state NAMED + DOT="." LPAREN="(" RPAREN=")" @@ -142,7 +144,7 @@ MYSQL_CHAR_NAME=[:letter:](-|[:letter:])*[:digit:]? ANY=[^] META1 = {ESCAPE} | {LBRACKET} -META2= {DOT} | "$" | "?" | "*" | "+" | "|" | "^" | {LBRACE} | {LPAREN} | {RPAREN} +META2 = {DOT} | "$" | "?" | "*" | "+" | "|" | "^" | {LBRACE} | {LPAREN} | {RPAREN} CONTROL="t" | "n" | "r" | "f" | "a" | "e" BOUNDARY="b" | "b{g}"| "B" | "A" | "z" | "Z" | "G" | "K" @@ -335,14 +337,14 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2} "^" { yybegin(CLASS1); return RegExpTT.CARET; } } - { + { "\\E" { yypopstate(); return RegExpTT.QUOTE_END; } {ANY} { states.set(states.size() - 1, CLASS2); return RegExpTT.CHARACTER; } } { {ESCAPE} "^" { yybegin(CLASS2); return RegExpTT.ESC_CHARACTER; } - {ESCAPE} "Q" { yypushstate(QUOTED_CLASS1); return RegExpTT.QUOTE_BEGIN; } + {ESCAPE} "Q" { yypushstate(QUOTED_CLASS); return RegExpTT.QUOTE_BEGIN; } {ESCAPE} {RBRACKET} { yybegin(CLASS2); return allowEmptyCharacterClass ? RegExpTT.ESC_CHARACTER : RegExpTT.REDUNDANT_ESCAPE; } {RBRACKET} { if (allowEmptyCharacterClass) { yypopstate(); return RegExpTT.CLASS_END; } yybegin(CLASS2); return RegExpTT.CHARACTER; } {LBRACKET} / ":" { yybegin(CLASS2); if (allowPosixBracketExpressions) { yypushback(1); } else if (allowNestedCharacterClasses) { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } else { return RegExpTT.CHARACTER; } } @@ -434,8 +436,8 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2} "(?#" [^)]+ ")" { return RegExpTT.COMMENT; } "(?P<" { yybegin(NAMED_GROUP); capturingGroupCount++; return RegExpTT.PYTHON_NAMED_GROUP; } "(?P=" { yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF; } - "(?(" { yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF; } - "(?&" { yybegin(NAMED_GROUP); return RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF; } + "(?" / "(" { yybegin(CONDITIONAL1); return RegExpTT.CONDITIONAL; } + "(?&" { yybegin(NAMED_GROUP); return RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF; } "(?P>" { yybegin(NAMED_GROUP); return RegExpTT.PCRE_RECURSIVE_NAMED_GROUP_REF; } "(?|" { return RegExpTT.PCRE_BRANCH_RESET; } @@ -473,9 +475,21 @@ BACK_REFERENCES_GROUP = [1-9][0-9]{0,2} {ANY} { yybegin(YYINITIAL); yypushback(1); } } - { + { + "(?=" { yybegin(YYINITIAL); return RegExpTT.POS_LOOKAHEAD; } + "(?!" { yybegin(YYINITIAL); return RegExpTT.NEG_LOOKAHEAD; } + "(?<=" { yybegin(YYINITIAL); return RegExpTT.POS_LOOKBEHIND; } + "(? { {GROUP_NAME} { return RegExpTT.NAME; } [:digit:]+ { return RegExpTT.NUMBER; } + "')" { yybegin(YYINITIAL); return RegExpTT.QUOTED_CONDITION_END; } + ">)" { yybegin(YYINITIAL); return RegExpTT.ANGLE_BRACKET_CONDITION_END; } ")" { yybegin(YYINITIAL); return RegExpTT.GROUP_END; } {ANY} { yybegin(YYINITIAL); yypushback(1); } } diff --git a/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java b/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java index f85e105d9f72..88076fea1aaa 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java @@ -38,7 +38,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -235,21 +234,19 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot @Override public void visitRegExpGroup(RegExpGroup group) { final RegExpPattern pattern = group.getPattern(); - if (pattern != null) { - final RegExpBranch[] branches = pattern.getBranches(); - if (isEmpty(branches) && group.getNode().getLastChildNode().getElementType() == RegExpTT.GROUP_END) { - // catches "()" as well as "(|)" - myHolder.newAnnotation(HighlightSeverity.WARNING, RegExpBundle.message("error.empty.group")).create(); - } - else if (branches.length == 1) { - final RegExpAtom[] atoms = branches[0].getAtoms(); - if (atoms.length == 1 && atoms[0] instanceof RegExpGroup) { - final RegExpGroup.Type type = group.getType(); - if (type == RegExpGroup.Type.CAPTURING_GROUP || type == RegExpGroup.Type.ATOMIC || type == RegExpGroup.Type.NON_CAPTURING) { - final RegExpGroup innerGroup = (RegExpGroup)atoms[0]; - if (group.isCapturing() == innerGroup.isCapturing()) { - myHolder.newAnnotation(HighlightSeverity.WARNING, RegExpBundle.message("error.redundant.group.nesting")).create(); - } + final RegExpBranch[] branches = pattern.getBranches(); + if (isEmpty(branches) && group.getNode().getLastChildNode().getElementType() == RegExpTT.GROUP_END) { + // catches "()" as well as "(|)" + myHolder.newAnnotation(HighlightSeverity.WARNING, RegExpBundle.message("error.empty.group")).create(); + } + else if (branches.length == 1) { + final RegExpAtom[] atoms = branches[0].getAtoms(); + if (atoms.length == 1 && atoms[0] instanceof RegExpGroup) { + final RegExpGroup.Type type = group.getType(); + if (type == RegExpGroup.Type.CAPTURING_GROUP || type == RegExpGroup.Type.ATOMIC || type == RegExpGroup.Type.NON_CAPTURING) { + final RegExpGroup innerGroup = (RegExpGroup)atoms[0]; + if (group.isCapturing() == innerGroup.isCapturing()) { + myHolder.newAnnotation(HighlightSeverity.WARNING, RegExpBundle.message("error.redundant.group.nesting")).create(); } } } @@ -293,7 +290,7 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot @Override public void visitRegExpNamedGroupRef(RegExpNamedGroupRef groupRef) { - if (!myLanguageHosts.supportsNamedGroupRefSyntax(groupRef)) { + if (!(groupRef.getParent() instanceof RegExpConditional) && !myLanguageHosts.supportsNamedGroupRefSyntax(groupRef)) { myHolder.newAnnotation(HighlightSeverity.ERROR, RegExpBundle.message("error.this.named.group.reference.syntax.is.not.supported.in.this.regex.dialect")) .create(); @@ -332,15 +329,29 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot myHolder.newAnnotation(HighlightSeverity.ERROR, RegExpBundle.message("error.conditionals.are.not.supported.in.this.regex.dialect")).create(); } + final RegExpAtom condition = conditional.getCondition(); + if (!myLanguageHosts.supportConditionalCondition(condition)) { + if (condition instanceof RegExpGroup) { + myHolder.newAnnotation(HighlightSeverity.ERROR, + RegExpBundle.message("error.lookaround.conditions.in.conditionals.not.supported.in.this.regex.dialect")) + .range(condition) + .create(); + } + else if (condition != null) { + final ASTNode child = condition.getNode().getFirstChildNode(); + final IElementType type = child.getElementType(); + if (type == RegExpTT.QUOTED_CONDITION_BEGIN || type == RegExpTT.GROUP_BEGIN || type == RegExpTT.ANGLE_BRACKET_CONDITION_BEGIN) { + myHolder.newAnnotation(HighlightSeverity.ERROR, + RegExpBundle.message("error.this.kind.group.reference.condition.not.supported.in.this.regex.dialect")) + .range(condition) + .create(); + } + } + } } private static boolean isEmpty(RegExpBranch[] branches) { - for (RegExpBranch branch : branches) { - if (branch.getAtoms().length > 0) { - return false; - } - } - return true; + return !ContainerUtil.exists(branches, branch -> branch.getAtoms().length > 0); } @Override diff --git a/RegExpSupport/testData/psi/Groups39.txt b/RegExpSupport/testData/psi/Groups39.txt index a243579972b1..37f8b7ac4eee 100644 --- a/RegExpSupport/testData/psi/Groups39.txt +++ b/RegExpSupport/testData/psi/Groups39.txt @@ -2,9 +2,11 @@ REGEXP_FILE RegExpPatternImpl: <(?(name)yes-pattern|no-pattern)> RegExpBranchImpl: <(?(name)yes-pattern|no-pattern)> RegExpConditionalImpl: <(?(name)yes-pattern|no-pattern)> - PsiElement(PYTHON_COND_REF)('(?(') - PsiElement(NAME)('name') - PsiElement(GROUP_END)(')') + PsiElement(CONDITIONAL)('(?') + RegExpNamedGroupRefImpl: <(name)> + PsiElement(GROUP_BEGIN)('(') + PsiElement(NAME)('name') + PsiElement(GROUP_END)(')') RegExpBranchImpl: RegExpCharImpl: PsiElement(CHARACTER)('y') diff --git a/RegExpSupport/testData/psi/Groups40.txt b/RegExpSupport/testData/psi/Groups40.txt index 9f07f0efed79..1b61d74d8f65 100644 --- a/RegExpSupport/testData/psi/Groups40.txt +++ b/RegExpSupport/testData/psi/Groups40.txt @@ -2,9 +2,11 @@ REGEXP_FILE RegExpPatternImpl: <(?(name)yes-pattern|{> RegExpBranchImpl: <(?(name)yes-pattern|{> RegExpConditionalImpl: <(?(name)yes-pattern|{> - PsiElement(PYTHON_COND_REF)('(?(') - PsiElement(NAME)('name') - PsiElement(GROUP_END)(')') + PsiElement(CONDITIONAL)('(?') + RegExpNamedGroupRefImpl: <(name)> + PsiElement(GROUP_BEGIN)('(') + PsiElement(NAME)('name') + PsiElement(GROUP_END)(')') RegExpBranchImpl: RegExpCharImpl: PsiElement(CHARACTER)('y') @@ -34,4 +36,7 @@ REGEXP_FILE PsiElement(LBRACE)('{') PsiErrorElement:')' expected - \ No newline at end of file + + RegExpPatternImpl: <> + RegExpBranchImpl: <> + \ No newline at end of file diff --git a/RegExpSupport/testData/psi/Groups43.txt b/RegExpSupport/testData/psi/Groups43.txt index 778d1c238a05..e56de60dd881 100644 --- a/RegExpSupport/testData/psi/Groups43.txt +++ b/RegExpSupport/testData/psi/Groups43.txt @@ -1,10 +1,12 @@ REGEXP_FILE - RegExpPatternImpl: <(?(name)yes-pattern|no_pattern|maybe-pattern> - RegExpBranchImpl: <(?(name)yes-pattern|no_pattern> - RegExpConditionalImpl: <(?(name)yes-pattern|no_pattern> - PsiElement(PYTHON_COND_REF)('(?(') - PsiElement(NAME)('name') - PsiElement(GROUP_END)(')') + RegExpPatternImpl: <(?(name)yes-pattern|no_pattern|maybe-pattern)> + RegExpBranchImpl: <(?(name)yes-pattern|no_pattern|maybe-pattern)> + RegExpConditionalImpl: <(?(name)yes-pattern|no_pattern|maybe-pattern)> + PsiElement(CONDITIONAL)('(?') + RegExpNamedGroupRefImpl: <(name)> + PsiElement(GROUP_BEGIN)('(') + PsiElement(NAME)('name') + PsiElement(GROUP_END)(')') RegExpBranchImpl: RegExpCharImpl: PsiElement(CHARACTER)('y') @@ -52,34 +54,35 @@ REGEXP_FILE PsiElement(CHARACTER)('n') PsiErrorElement:')' expected - PsiElement(UNION)('|') - RegExpBranchImpl: - RegExpCharImpl: - PsiElement(CHARACTER)('m') - RegExpCharImpl: - PsiElement(CHARACTER)('a') - RegExpCharImpl: - PsiElement(CHARACTER)('y') - RegExpCharImpl: - PsiElement(CHARACTER)('b') - RegExpCharImpl: - PsiElement(CHARACTER)('e') - RegExpCharImpl: <-> - PsiElement(CHARACTER)('-') - RegExpCharImpl:

- PsiElement(CHARACTER)('p') - RegExpCharImpl: - PsiElement(CHARACTER)('a') - RegExpCharImpl: - PsiElement(CHARACTER)('t') - RegExpCharImpl: - PsiElement(CHARACTER)('t') - RegExpCharImpl: - PsiElement(CHARACTER)('e') - RegExpCharImpl: - PsiElement(CHARACTER)('r') - RegExpCharImpl: - PsiElement(CHARACTER)('n') - PsiErrorElement:Unmatched closing ')' - - PsiElement(GROUP_END)(')') \ No newline at end of file + RegExpPatternImpl: <|maybe-pattern> + RegExpBranchImpl: <> + + PsiElement(UNION)('|') + RegExpBranchImpl: + RegExpCharImpl: + PsiElement(CHARACTER)('m') + RegExpCharImpl: + PsiElement(CHARACTER)('a') + RegExpCharImpl: + PsiElement(CHARACTER)('y') + RegExpCharImpl: + PsiElement(CHARACTER)('b') + RegExpCharImpl: + PsiElement(CHARACTER)('e') + RegExpCharImpl: <-> + PsiElement(CHARACTER)('-') + RegExpCharImpl:

+ PsiElement(CHARACTER)('p') + RegExpCharImpl: + PsiElement(CHARACTER)('a') + RegExpCharImpl: + PsiElement(CHARACTER)('t') + RegExpCharImpl: + PsiElement(CHARACTER)('t') + RegExpCharImpl: + PsiElement(CHARACTER)('e') + RegExpCharImpl: + PsiElement(CHARACTER)('r') + RegExpCharImpl: + PsiElement(CHARACTER)('n') + PsiElement(GROUP_END)(')') \ No newline at end of file diff --git a/RegExpSupport/testData/psi/Regressions4.txt b/RegExpSupport/testData/psi/Regressions4.txt index 37ff3c0fc8a6..d916c7f5d69b 100644 --- a/RegExpSupport/testData/psi/Regressions4.txt +++ b/RegExpSupport/testData/psi/Regressions4.txt @@ -35,72 +35,77 @@ REGEXP_FILE PsiElement(CHAR_CLASS)('\s') RegExpQuantifierImpl: <*> PsiElement(STAR)('*') - RegExpClosureImpl: <(?:(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*)?> - RegExpGroupImpl: <(?:(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*)> - PsiElement(NON_CAPT_GROUP)('(?:') - RegExpPatternImpl: <(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*> - RegExpBranchImpl: <(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*> - RegExpClosureImpl: <(?:\{|:)?> - RegExpGroupImpl: <(?:\{|:)> - PsiElement(NON_CAPT_GROUP)('(?:') - RegExpPatternImpl: <\{|:> - RegExpBranchImpl: <\{> - RegExpCharImpl: <\{> - PsiElement(ESC_CHARACTER)('\{') - PsiElement(UNION)('|') - RegExpBranchImpl: <:> - RegExpCharImpl: <:> - PsiElement(CHARACTER)(':') - PsiElement(GROUP_END)(')') - RegExpQuantifierImpl: - PsiElement(QUEST)('?') - RegExpClosureImpl: <\s*> - RegExpSimpleClassImpl: <\s> - PsiElement(CHAR_CLASS)('\s') - RegExpQuantifierImpl: <*> - PsiElement(STAR)('*') - RegExpConditionalImpl: <(?([^\s\}]+)> - PsiElement(PYTHON_COND_REF)('(?(') - PsiErrorElement:Group name or number expected - - RegExpBranchImpl: <[^\s\}]+> - RegExpClosureImpl: <[^\s\}]+> - RegExpClassImpl: <[^\s\}]> - PsiElement(CLASS_BEGIN)('[') - PsiElement(CARET)('^') - RegExpSimpleClassImpl: <\s> - PsiElement(CHAR_CLASS)('\s') - RegExpCharImpl: <\}> - PsiElement(REDUNDANT_ESCAPE)('\}') - PsiElement(CLASS_END)(']') - RegExpQuantifierImpl: <+> - PsiElement(PLUS)('+') + RegExpGroupImpl: <(?:(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*)?(.*)> + PsiElement(NON_CAPT_GROUP)('(?:') + RegExpPatternImpl: <(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*)?(.*)> + RegExpBranchImpl: <(?:\{|:)?\s*(?([^\s\}]+)\s*\}?\s*)?(.*)> + RegExpClosureImpl: <(?:\{|:)?> + RegExpGroupImpl: <(?:\{|:)> + PsiElement(NON_CAPT_GROUP)('(?:') + RegExpPatternImpl: <\{|:> + RegExpBranchImpl: <\{> + RegExpCharImpl: <\{> + PsiElement(ESC_CHARACTER)('\{') + PsiElement(UNION)('|') + RegExpBranchImpl: <:> + RegExpCharImpl: <:> + PsiElement(CHARACTER)(':') PsiElement(GROUP_END)(')') - RegExpClosureImpl: <\s*> - RegExpSimpleClassImpl: <\s> - PsiElement(CHAR_CLASS)('\s') - RegExpQuantifierImpl: <*> - PsiElement(STAR)('*') - RegExpClosureImpl: <\}?> - RegExpCharImpl: <\}> - PsiElement(REDUNDANT_ESCAPE)('\}') - RegExpQuantifierImpl: - PsiElement(QUEST)('?') - RegExpClosureImpl: <\s*> - RegExpSimpleClassImpl: <\s> - PsiElement(CHAR_CLASS)('\s') - RegExpQuantifierImpl: <*> - PsiElement(STAR)('*') - PsiElement(GROUP_END)(')') - RegExpQuantifierImpl: - PsiElement(QUEST)('?') - RegExpGroupImpl: <(.*)> - PsiElement(GROUP_BEGIN)('(') - RegExpPatternImpl: <.*> - RegExpBranchImpl: <.*> - RegExpClosureImpl: <.*> - RegExpSimpleClassImpl: <.> - PsiElement(DOT)('.') + RegExpQuantifierImpl: + PsiElement(QUEST)('?') + RegExpClosureImpl: <\s*> + RegExpSimpleClassImpl: <\s> + PsiElement(CHAR_CLASS)('\s') RegExpQuantifierImpl: <*> PsiElement(STAR)('*') - PsiElement(GROUP_END)(')') \ No newline at end of file + RegExpClosureImpl: <(?([^\s\}]+)\s*\}?\s*)?> + RegExpConditionalImpl: <(?([^\s\}]+)\s*\}?\s*)> + PsiElement(CONDITIONAL)('(?') + PsiElement(GROUP_BEGIN)('(') + PsiErrorElement:Group name or number expected + + RegExpPatternImpl: <[^\s\}]+> + RegExpBranchImpl: <[^\s\}]+> + RegExpClosureImpl: <[^\s\}]+> + RegExpClassImpl: <[^\s\}]> + PsiElement(CLASS_BEGIN)('[') + PsiElement(CARET)('^') + RegExpSimpleClassImpl: <\s> + PsiElement(CHAR_CLASS)('\s') + RegExpCharImpl: <\}> + PsiElement(REDUNDANT_ESCAPE)('\}') + PsiElement(CLASS_END)(']') + RegExpQuantifierImpl: <+> + PsiElement(PLUS)('+') + PsiElement(GROUP_END)(')') + RegExpBranchImpl: <\s*\}?\s*> + RegExpClosureImpl: <\s*> + RegExpSimpleClassImpl: <\s> + PsiElement(CHAR_CLASS)('\s') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + RegExpClosureImpl: <\}?> + RegExpCharImpl: <\}> + PsiElement(REDUNDANT_ESCAPE)('\}') + RegExpQuantifierImpl: + PsiElement(QUEST)('?') + RegExpClosureImpl: <\s*> + RegExpSimpleClassImpl: <\s> + PsiElement(CHAR_CLASS)('\s') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + PsiElement(GROUP_END)(')') + RegExpQuantifierImpl: + PsiElement(QUEST)('?') + RegExpGroupImpl: <(.*)> + PsiElement(GROUP_BEGIN)('(') + RegExpPatternImpl: <.*> + RegExpBranchImpl: <.*> + RegExpClosureImpl: <.*> + RegExpSimpleClassImpl: <.> + PsiElement(DOT)('.') + RegExpQuantifierImpl: <*> + PsiElement(STAR)('*') + PsiElement(GROUP_END)(')') + PsiErrorElement:')' expected + \ No newline at end of file diff --git a/python/src/com/jetbrains/python/codeInsight/PythonRegExpHost.java b/python/src/com/jetbrains/python/codeInsight/PythonRegExpHost.java index 7dca2038d246..cc6b28c3feff 100644 --- a/python/src/com/jetbrains/python/codeInsight/PythonRegExpHost.java +++ b/python/src/com/jetbrains/python/codeInsight/PythonRegExpHost.java @@ -6,6 +6,7 @@ import com.intellij.psi.PsiLanguageInjectionHost; import com.jetbrains.python.psi.LanguageLevel; import org.intellij.lang.regexp.DefaultRegExpPropertiesProvider; import org.intellij.lang.regexp.RegExpLanguageHost; +import org.intellij.lang.regexp.RegExpTT; import org.intellij.lang.regexp.UnicodeCharacterNames; import org.intellij.lang.regexp.psi.*; import org.jetbrains.annotations.NotNull; @@ -40,6 +41,14 @@ public class PythonRegExpHost implements RegExpLanguageHost { return true; } + @Override + public boolean supportConditionalCondition(RegExpAtom condition) { + if (condition instanceof RegExpGroup) { + return false; + } + return condition.getNode().getFirstChildNode().getElementType() == RegExpTT.GROUP_BEGIN; + } + @Override public boolean supportsNamedGroupSyntax(RegExpGroup group) { return group.getType() == RegExpGroup.Type.PYTHON_NAMED_GROUP; diff --git a/python/testData/regexp/conditional.py b/python/testData/regexp/conditional.py new file mode 100644 index 000000000000..14efb47f3dac --- /dev/null +++ b/python/testData/regexp/conditional.py @@ -0,0 +1,7 @@ +import re + +re.compile(r"(?Pdelicious )?(?(group1)hamburger|milkshake)"); +re.compile(r"(?Pdelicious )?(?(1)hamburger|milkshake)"); +re.compile(r"(?Pdelicious )?(?('group1')hamburger|milkshake)"); +re.compile(r"(?delicious )?(?()hamburger|milkshake)"); +re.compile(r"(?'group1'delicious )?(?(group1)hamburger|milkshake)"); \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyRegexpTest.java b/python/testSrc/com/jetbrains/python/PyRegexpTest.java index 6ce92855afdc..1c30e1033cff 100644 --- a/python/testSrc/com/jetbrains/python/PyRegexpTest.java +++ b/python/testSrc/com/jetbrains/python/PyRegexpTest.java @@ -36,6 +36,10 @@ public class PyRegexpTest extends PyTestCase { doTestHighlighting(); } + public void testConditional() { + doTestHighlighting(); + } + public void testRedundantEscape() { myFixture.enableInspections(new RedundantEscapeInspection()); doTestHighlighting();