support for Python named groups in regexp lexer and parser

This commit is contained in:
Dmitry Jemerov
2010-02-21 21:18:21 +03:00
parent 756b9b41eb
commit 80ea3d052a
8 changed files with 234 additions and 209 deletions
@@ -28,6 +28,7 @@ public class RegExpBraceMatcher implements PairedBraceMatcher {
new BracePair(RegExpTT.SET_OPTIONS, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NON_CAPT_GROUP, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.POS_LOOKAHEAD, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKAHEAD, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.POS_LOOKBEHIND, RegExpTT.GROUP_END, true), new BracePair(RegExpTT.NEG_LOOKBEHIND, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.PYTHON_NAMED_GROUP, RegExpTT.GROUP_END, true),
new BracePair(RegExpTT.CLASS_BEGIN, RegExpTT.CLASS_END, false), new BracePair(RegExpTT.LBRACE, RegExpTT.RBRACE, false),
new BracePair(RegExpTT.QUOTE_BEGIN, RegExpTT.QUOTE_END, false),};
}
@@ -22,4 +22,5 @@ public interface RegExpLanguageHost {
boolean characterNeedsEscaping(char c);
boolean supportsPerl5EmbeddedComments();
boolean supportsPossessiveQuantifiers();
boolean supportsPythonNamedGroups();
}
@@ -97,6 +97,9 @@ public interface RegExpTT {
IElementType OPTIONS_ON = new RegExpElementType("OPTIONS_ON");
IElementType OPTIONS_OFF = new RegExpElementType("OPTIONS_OFF");
// (?P<name>...
IElementType PYTHON_NAMED_GROUP = new RegExpElementType("PYTHON_NAMED_GROUP");
TokenSet KEYWORDS = TokenSet.create(DOT, STAR, QUEST, PLUS);
TokenSet CHARACTERS = TokenSet.create(CHARACTER,
@@ -123,7 +126,8 @@ public interface RegExpTT {
POS_LOOKAHEAD,
NEG_LOOKAHEAD,
POS_LOOKBEHIND,
NEG_LOOKBEHIND);
NEG_LOOKBEHIND,
PYTHON_NAMED_GROUP);
TokenSet BOUNDARIES = TokenSet.create(BOUNDARY, CARET, DOLLAR);
}
@@ -1,21 +1,20 @@
/* The following code was generated by JFlex 1.4.1 on 18.12.09 20:27 */
/* The following code was generated by JFlex 1.4.3 on 21.02.10 20:59 */
/* It's an automatically generated code. Do not modify it. */
package org.intellij.lang.regexp;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.StringEscapesTokenTypes;
import com.intellij.psi.tree.IElementType;
import java.util.LinkedList;
import com.intellij.psi.StringEscapesTokenTypes;
// IDEADEV-11055
@SuppressWarnings({ "ALL", "SameParameterValue", "WeakerAccess", "SameReturnValue", "RedundantThrows", "UnusedDeclaration", "UnusedDeclaration" })
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.1
* on 18.12.09 20:27 from the specification file
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 21.02.10 20:59 from the specification file
* <tt>C:/JetBrains/IDEA/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
*/
class _RegExLexer implements FlexLexer {
@@ -23,86 +22,96 @@ class _RegExLexer implements FlexLexer {
private static final int ZZ_BUFFERSIZE = 16384;
/** lexical states */
public static final int CLASS1 = 3;
public static final int PROP = 5;
public static final int EMBRACED = 2;
public static final int QUOTED = 1;
public static final int CLASS1 = 6;
public static final int PROP = 10;
public static final int EMBRACED = 4;
public static final int QUOTED = 2;
public static final int YYINITIAL = 0;
public static final int COMMENT = 7;
public static final int OPTIONS = 6;
public static final int CLASS2 = 4;
public static final int COMMENT = 14;
public static final int OPTIONS = 12;
public static final int CLASS2 = 8;
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
};
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\10\0\2\51\1\13\1\0\1\51\1\60\22\0\1\44\1\55\1\0"+
"\1\57\1\15\1\0\1\50\1\0\1\4\1\5\1\17\1\20\1\47"+
"\1\42\1\3\1\0\1\2\7\41\2\1\1\52\1\0\1\56\1\54"+
"\1\53\1\16\1\0\1\24\1\24\1\30\1\27\1\36\1\34\1\25"+
"\1\43\1\32\6\43\1\33\1\35\1\43\1\26\3\43\1\26\1\26"+
"\1\43\1\25\1\10\1\12\1\11\1\14\1\45\1\0\1\23\1\24"+
"\1\31\1\27\1\23\1\23\2\43\1\32\4\43\1\22\1\43\1\33"+
"\1\43\1\22\1\26\1\22\1\40\1\43\1\26\1\37\1\43\1\25"+
"\1\6\1\21\1\7\54\0\1\43\12\0\1\43\4\0\1\43\5\0"+
"\27\43\1\0\37\43\1\0\u013f\43\31\0\162\43\4\0\14\43\16\0"+
"\5\43\11\0\1\43\213\0\1\43\13\0\1\43\1\0\3\43\1\0"+
"\1\43\1\0\24\43\1\0\54\43\1\0\46\43\1\0\5\43\4\0"+
"\202\43\10\0\105\43\1\0\46\43\2\0\2\43\6\0\20\43\41\0"+
"\46\43\2\0\1\43\7\0\47\43\110\0\33\43\5\0\3\43\56\0"+
"\32\43\5\0\13\43\25\0\12\46\4\0\2\43\1\0\143\43\1\0"+
"\1\43\17\0\2\43\7\0\2\43\12\46\3\43\2\0\1\43\20\0"+
"\1\43\1\0\36\43\35\0\3\43\60\0\46\43\13\0\1\43\u0152\0"+
"\66\43\3\0\1\43\22\0\1\43\7\0\12\43\4\0\12\46\25\0"+
"\10\43\2\0\2\43\2\0\26\43\1\0\7\43\1\0\1\43\3\0"+
"\4\43\3\0\1\43\36\0\2\43\1\0\3\43\4\0\12\46\2\43"+
"\23\0\6\43\4\0\2\43\2\0\26\43\1\0\7\43\1\0\2\43"+
"\1\0\2\43\1\0\2\43\37\0\4\43\1\0\1\43\7\0\12\46"+
"\2\0\3\43\20\0\11\43\1\0\3\43\1\0\26\43\1\0\7\43"+
"\1\0\2\43\1\0\5\43\3\0\1\43\22\0\1\43\17\0\2\43"+
"\4\0\12\46\25\0\10\43\2\0\2\43\2\0\26\43\1\0\7\43"+
"\1\0\2\43\1\0\5\43\3\0\1\43\36\0\2\43\1\0\3\43"+
"\4\0\12\46\1\0\1\43\21\0\1\43\1\0\6\43\3\0\3\43"+
"\1\0\4\43\3\0\2\43\1\0\1\43\1\0\2\43\3\0\2\43"+
"\3\0\3\43\3\0\10\43\1\0\3\43\55\0\11\46\25\0\10\43"+
"\1\0\3\43\1\0\27\43\1\0\12\43\1\0\5\43\46\0\2\43"+
"\4\0\12\46\25\0\10\43\1\0\3\43\1\0\27\43\1\0\12\43"+
"\1\0\5\43\3\0\1\43\40\0\1\43\1\0\2\43\4\0\12\46"+
"\25\0\10\43\1\0\3\43\1\0\27\43\1\0\20\43\46\0\2\43"+
"\4\0\12\46\25\0\22\43\3\0\30\43\1\0\11\43\1\0\1\43"+
"\2\0\7\43\72\0\60\43\1\0\2\43\14\0\7\43\11\0\12\46"+
"\47\0\2\43\1\0\1\43\2\0\2\43\1\0\1\43\2\0\1\43"+
"\6\0\4\43\1\0\7\43\1\0\3\43\1\0\1\43\1\0\1\43"+
"\2\0\2\43\1\0\4\43\1\0\2\43\11\0\1\43\2\0\5\43"+
"\1\0\1\43\11\0\12\46\2\0\2\43\42\0\1\43\37\0\12\46"+
"\26\0\10\43\1\0\42\43\35\0\4\43\164\0\42\43\1\0\5\43"+
"\1\0\2\43\25\0\12\46\6\0\6\43\112\0\46\43\12\0\51\43"+
"\7\0\132\43\5\0\104\43\5\0\122\43\6\0\7\43\1\0\77\43"+
"\1\0\1\43\1\0\4\43\2\0\7\43\1\0\1\43\1\0\4\43"+
"\2\0\47\43\1\0\1\43\1\0\4\43\2\0\37\43\1\0\1\43"+
"\1\0\4\43\2\0\7\43\1\0\1\43\1\0\4\43\2\0\7\43"+
"\1\0\7\43\1\0\27\43\1\0\37\43\1\0\1\43\1\0\4\43"+
"\2\0\7\43\1\0\47\43\1\0\23\43\16\0\11\46\56\0\125\43"+
"\14\0\u026c\43\2\0\10\43\12\0\32\43\5\0\113\43\25\0\15\43"+
"\1\0\4\43\16\0\22\43\16\0\22\43\16\0\15\43\1\0\3\43"+
"\17\0\64\43\43\0\1\43\4\0\1\43\3\0\12\46\46\0\12\46"+
"\6\0\130\43\10\0\51\43\127\0\35\43\51\0\12\46\36\43\2\0"+
"\5\43\u038b\0\154\43\224\0\234\43\4\0\132\43\6\0\26\43\2\0"+
"\6\43\2\0\46\43\2\0\6\43\2\0\10\43\1\0\1\43\1\0"+
"\1\43\1\0\1\43\1\0\37\43\2\0\65\43\1\0\7\43\1\0"+
"\1\43\3\0\3\43\1\0\7\43\3\0\4\43\2\0\6\43\4\0"+
"\15\43\5\0\3\43\1\0\7\43\164\0\1\43\15\0\1\43\202\0"+
"\1\43\4\0\1\43\2\0\12\43\1\0\1\43\3\0\5\43\6\0"+
"\1\43\1\0\1\43\1\0\1\43\1\0\4\43\1\0\3\43\1\0"+
"\7\43\3\0\3\43\5\0\5\43\u0ebb\0\2\43\52\0\5\43\5\0"+
"\2\43\4\0\126\43\6\0\3\43\1\0\132\43\1\0\4\43\5\0"+
"\50\43\4\0\136\43\21\0\30\43\70\0\20\43\u0200\0\u19b6\43\112\0"+
"\u51a6\43\132\0\u048d\43\u0773\0\u2ba4\43\u215c\0\u012e\43\2\0\73\43\225\0"+
"\7\43\14\0\5\43\5\0\1\43\1\0\12\43\1\0\15\43\1\0"+
"\5\43\1\0\1\43\1\0\2\43\1\0\2\43\1\0\154\43\41\0"+
"\u016b\43\22\0\100\43\2\0\66\43\50\0\14\43\164\0\5\43\1\0"+
"\207\43\23\0\12\46\7\0\32\43\6\0\32\43\13\0\131\43\3\0"+
"\6\43\2\0\6\43\2\0\6\43\2\0\3\43\43\0";
"\10\0\2\52\1\13\1\0\1\52\1\61\22\0\1\45\1\56\1\0"+
"\1\60\1\15\1\0\1\51\1\0\1\4\1\5\1\17\1\20\1\50"+
"\1\43\1\3\1\0\1\2\7\42\2\1\1\53\1\0\1\57\1\55"+
"\1\54\1\16\1\0\1\24\1\24\1\30\1\27\1\37\1\35\1\25"+
"\1\44\1\32\6\44\1\34\1\36\1\44\1\26\3\44\1\26\1\26"+
"\1\44\1\25\1\10\1\12\1\11\1\14\1\46\1\0\1\23\1\24"+
"\1\31\1\27\1\23\1\23\2\44\1\32\4\44\1\22\1\44\1\33"+
"\1\44\1\22\1\26\1\22\1\41\1\44\1\26\1\40\1\44\1\25"+
"\1\6\1\21\1\7\54\0\1\44\12\0\1\44\4\0\1\44\5\0"+
"\27\44\1\0\37\44\1\0\u013f\44\31\0\162\44\4\0\14\44\16\0"+
"\5\44\11\0\1\44\213\0\1\44\13\0\1\44\1\0\3\44\1\0"+
"\1\44\1\0\24\44\1\0\54\44\1\0\46\44\1\0\5\44\4\0"+
"\202\44\10\0\105\44\1\0\46\44\2\0\2\44\6\0\20\44\41\0"+
"\46\44\2\0\1\44\7\0\47\44\110\0\33\44\5\0\3\44\56\0"+
"\32\44\5\0\13\44\25\0\12\47\4\0\2\44\1\0\143\44\1\0"+
"\1\44\17\0\2\44\7\0\2\44\12\47\3\44\2\0\1\44\20\0"+
"\1\44\1\0\36\44\35\0\3\44\60\0\46\44\13\0\1\44\u0152\0"+
"\66\44\3\0\1\44\22\0\1\44\7\0\12\44\4\0\12\47\25\0"+
"\10\44\2\0\2\44\2\0\26\44\1\0\7\44\1\0\1\44\3\0"+
"\4\44\3\0\1\44\36\0\2\44\1\0\3\44\4\0\12\47\2\44"+
"\23\0\6\44\4\0\2\44\2\0\26\44\1\0\7\44\1\0\2\44"+
"\1\0\2\44\1\0\2\44\37\0\4\44\1\0\1\44\7\0\12\47"+
"\2\0\3\44\20\0\11\44\1\0\3\44\1\0\26\44\1\0\7\44"+
"\1\0\2\44\1\0\5\44\3\0\1\44\22\0\1\44\17\0\2\44"+
"\4\0\12\47\25\0\10\44\2\0\2\44\2\0\26\44\1\0\7\44"+
"\1\0\2\44\1\0\5\44\3\0\1\44\36\0\2\44\1\0\3\44"+
"\4\0\12\47\1\0\1\44\21\0\1\44\1\0\6\44\3\0\3\44"+
"\1\0\4\44\3\0\2\44\1\0\1\44\1\0\2\44\3\0\2\44"+
"\3\0\3\44\3\0\10\44\1\0\3\44\55\0\11\47\25\0\10\44"+
"\1\0\3\44\1\0\27\44\1\0\12\44\1\0\5\44\46\0\2\44"+
"\4\0\12\47\25\0\10\44\1\0\3\44\1\0\27\44\1\0\12\44"+
"\1\0\5\44\3\0\1\44\40\0\1\44\1\0\2\44\4\0\12\47"+
"\25\0\10\44\1\0\3\44\1\0\27\44\1\0\20\44\46\0\2\44"+
"\4\0\12\47\25\0\22\44\3\0\30\44\1\0\11\44\1\0\1\44"+
"\2\0\7\44\72\0\60\44\1\0\2\44\14\0\7\44\11\0\12\47"+
"\47\0\2\44\1\0\1\44\2\0\2\44\1\0\1\44\2\0\1\44"+
"\6\0\4\44\1\0\7\44\1\0\3\44\1\0\1\44\1\0\1\44"+
"\2\0\2\44\1\0\4\44\1\0\2\44\11\0\1\44\2\0\5\44"+
"\1\0\1\44\11\0\12\47\2\0\2\44\42\0\1\44\37\0\12\47"+
"\26\0\10\44\1\0\42\44\35\0\4\44\164\0\42\44\1\0\5\44"+
"\1\0\2\44\25\0\12\47\6\0\6\44\112\0\46\44\12\0\51\44"+
"\7\0\132\44\5\0\104\44\5\0\122\44\6\0\7\44\1\0\77\44"+
"\1\0\1\44\1\0\4\44\2\0\7\44\1\0\1\44\1\0\4\44"+
"\2\0\47\44\1\0\1\44\1\0\4\44\2\0\37\44\1\0\1\44"+
"\1\0\4\44\2\0\7\44\1\0\1\44\1\0\4\44\2\0\7\44"+
"\1\0\7\44\1\0\27\44\1\0\37\44\1\0\1\44\1\0\4\44"+
"\2\0\7\44\1\0\47\44\1\0\23\44\16\0\11\47\56\0\125\44"+
"\14\0\u026c\44\2\0\10\44\12\0\32\44\5\0\113\44\25\0\15\44"+
"\1\0\4\44\16\0\22\44\16\0\22\44\16\0\15\44\1\0\3\44"+
"\17\0\64\44\43\0\1\44\4\0\1\44\3\0\12\47\46\0\12\47"+
"\6\0\130\44\10\0\51\44\127\0\35\44\51\0\12\47\36\44\2\0"+
"\5\44\u038b\0\154\44\224\0\234\44\4\0\132\44\6\0\26\44\2\0"+
"\6\44\2\0\46\44\2\0\6\44\2\0\10\44\1\0\1\44\1\0"+
"\1\44\1\0\1\44\1\0\37\44\2\0\65\44\1\0\7\44\1\0"+
"\1\44\3\0\3\44\1\0\7\44\3\0\4\44\2\0\6\44\4\0"+
"\15\44\5\0\3\44\1\0\7\44\164\0\1\44\15\0\1\44\202\0"+
"\1\44\4\0\1\44\2\0\12\44\1\0\1\44\3\0\5\44\6\0"+
"\1\44\1\0\1\44\1\0\1\44\1\0\4\44\1\0\3\44\1\0"+
"\7\44\3\0\3\44\5\0\5\44\u0ebb\0\2\44\52\0\5\44\5\0"+
"\2\44\4\0\126\44\6\0\3\44\1\0\132\44\1\0\4\44\5\0"+
"\50\44\4\0\136\44\21\0\30\44\70\0\20\44\u0200\0\u19b6\44\112\0"+
"\u51a6\44\132\0\u048d\44\u0773\0\u2ba4\44\u215c\0\u012e\44\2\0\73\44\225\0"+
"\7\44\14\0\5\44\5\0\1\44\1\0\12\44\1\0\15\44\1\0"+
"\5\44\1\0\1\44\1\0\2\44\1\0\2\44\1\0\154\44\41\0"+
"\u016b\44\22\0\100\44\2\0\66\44\50\0\14\44\164\0\5\44\1\0"+
"\207\44\23\0\12\47\7\0\32\44\6\0\32\44\13\0\131\44\3\0"+
"\6\44\2\0\6\44\2\0\6\44\2\0\3\44\43\0";
/**
* Translates characters to character classes
@@ -122,12 +131,12 @@ class _RegExLexer implements FlexLexer {
"\1\36\1\35\1\37\1\40\1\1\1\41\1\42\1\2"+
"\1\43\1\44\1\45\1\46\1\47\1\50\1\51\1\52"+
"\1\53\1\54\2\55\1\56\1\11\1\57\1\60\1\61"+
"\1\62\1\63\1\64\1\65\1\66\2\0\1\67\1\70"+
"\2\60\2\61\1\71\1\72\1\0\1\67\1\60\1\73"+
"\2\61\1\74\1\67\3\61\1\75";
"\1\62\1\63\1\0\1\64\1\65\1\66\2\0\1\67"+
"\1\70\2\60\2\61\1\0\1\71\1\72\1\0\1\67"+
"\1\60\1\73\2\61\1\74\1\75\1\67\3\61\1\76";
private static int [] zzUnpackAction() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -152,21 +161,21 @@ class _RegExLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\61\0\142\0\223\0\304\0\365\0\u0126\0\u0157"+
"\0\u0188\0\u0188\0\u01b9\0\u0188\0\u0188\0\u01ea\0\u021b\0\u0188"+
"\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188"+
"\0\u0188\0\u024c\0\u0188\0\u027d\0\u0188\0\u02ae\0\u0188\0\u0188"+
"\0\u0188\0\u0188\0\u0188\0\u02df\0\u0188\0\u0188\0\u01ea\0\u0188"+
"\0\u0188\0\u0310\0\u0341\0\u0188\0\u0188\0\u0372\0\u0188\0\u0188"+
"\0\u03a3\0\u03d4\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188\0\u0188"+
"\0\u0405\0\u0188\0\u0188\0\u0188\0\u0436\0\u0467\0\u0188\0\u0188"+
"\0\u0188\0\u0188\0\u0188\0\u0498\0\u04c9\0\u04fa\0\u0188\0\u052b"+
"\0\u055c\0\u058d\0\u05be\0\u0188\0\u0188\0\u05ef\0\u0620\0\u0188"+
"\0\u0188\0\u0651\0\u0682\0\u0188\0\u0188\0\u06b3\0\u06e4\0\u0188"+
"\0\u0188";
"\0\0\0\62\0\144\0\226\0\310\0\372\0\u012c\0\u015e"+
"\0\u0190\0\u0190\0\u01c2\0\u0190\0\u0190\0\u01f4\0\u0226\0\u0190"+
"\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190"+
"\0\u0190\0\u0258\0\u0190\0\u028a\0\u0190\0\u02bc\0\u0190\0\u0190"+
"\0\u0190\0\u0190\0\u0190\0\u02ee\0\u0190\0\u0190\0\u01f4\0\u0190"+
"\0\u0190\0\u0320\0\u0352\0\u0190\0\u0190\0\u0384\0\u0190\0\u0190"+
"\0\u03b6\0\u03e8\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190\0\u0190"+
"\0\u041a\0\u0190\0\u0190\0\u0190\0\u044c\0\u047e\0\u0190\0\u0190"+
"\0\u04b0\0\u0190\0\u0190\0\u0190\0\u04e2\0\u0514\0\u0546\0\u0190"+
"\0\u0578\0\u05aa\0\u05dc\0\u060e\0\u0640\0\u0190\0\u0190\0\u0672"+
"\0\u06a4\0\u0190\0\u0190\0\u06d6\0\u0708\0\u0190\0\u0190\0\u0190"+
"\0\u073a\0\u076c\0\u0190\0\u0190";
private static int [] zzUnpackRowMap() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -191,40 +200,41 @@ class _RegExLexer implements FlexLexer {
private static final String ZZ_TRANS_PACKED_0 =
"\3\11\1\12\1\13\1\14\1\15\1\11\1\16\1\11"+
"\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26"+
"\20\11\1\27\1\11\1\30\4\11\1\20\5\11\1\31"+
"\1\20\12\11\1\32\1\0\45\11\1\33\2\34\4\33"+
"\1\35\12\33\17\36\1\34\1\33\1\36\2\33\1\34"+
"\1\37\11\33\11\40\1\41\1\40\1\0\45\40\6\11"+
"\1\15\1\11\1\16\1\42\1\17\1\43\1\21\25\11"+
"\21\11\1\27\1\11\1\30\4\11\1\20\5\11\1\31"+
"\1\20\12\11\1\32\1\0\46\11\1\33\2\34\4\33"+
"\1\35\12\33\20\36\1\34\1\33\1\36\2\33\1\34"+
"\1\37\11\33\11\40\1\41\1\40\1\0\46\40\6\11"+
"\1\15\1\11\1\16\1\42\1\17\1\43\1\21\26\11"+
"\1\27\5\11\1\44\1\43\6\11\1\43\6\45\1\46"+
"\1\45\1\47\1\45\1\17\46\45\5\50\1\51\14\50"+
"\17\52\1\50\1\53\1\52\6\50\1\54\6\50\13\10"+
"\1\55\44\10\1\55\77\0\1\56\53\0\1\57\47\0"+
"\1\45\1\47\1\45\1\17\47\45\5\50\1\51\14\50"+
"\20\52\1\50\1\53\1\52\6\50\1\54\6\50\13\10"+
"\1\55\45\10\1\55\100\0\1\56\54\0\1\57\50\0"+
"\1\60\1\61\1\62\4\63\1\60\1\63\1\60\1\63"+
"\1\64\6\63\2\65\2\66\2\67\1\70\1\71\1\70"+
"\1\72\1\73\1\74\1\73\1\75\1\76\1\61\1\63"+
"\1\73\1\64\4\60\1\64\6\60\1\64\36\0\1\77"+
"\23\0\2\34\36\0\1\34\4\0\1\34\13\0\2\36"+
"\17\0\20\36\1\0\1\36\1\0\2\36\62\0\1\100"+
"\32\0\17\52\2\0\1\52\37\0\17\53\2\0\1\53"+
"\67\0\2\101\1\102\1\103\1\104\1\105\2\0\2\61"+
"\36\0\1\61\21\0\1\106\36\0\1\106\17\0\61\107"+
"\1\110\2\111\20\110\2\111\2\110\3\111\2\110\1\111"+
"\1\110\1\111\2\110\1\111\17\110\1\112\2\113\20\112"+
"\2\113\2\112\3\113\2\112\1\113\1\112\1\113\2\112"+
"\1\113\17\112\54\0\1\114\1\115\3\0\5\116\1\0"+
"\53\116\2\0\1\117\36\0\1\117\17\0\62\120\2\121"+
"\20\120\2\121\2\120\3\121\2\120\1\121\1\120\1\121"+
"\2\120\1\121\17\120\62\122\2\123\20\122\2\123\2\122"+
"\3\123\2\122\1\123\1\122\1\123\2\122\1\123\17\122"+
"\5\116\1\124\53\116\2\0\1\125\36\0\1\125\17\0"+
"\62\126\2\127\20\126\2\127\2\126\3\127\2\126\1\127"+
"\1\126\1\127\2\126\1\127\17\126\62\130\2\131\20\130"+
"\2\131\2\130\3\131\2\130\1\131\1\130\1\131\2\130"+
"\1\131\17\130";
"\2\72\1\73\1\74\1\73\1\75\1\76\1\61\1\63"+
"\1\73\1\64\4\60\1\64\6\60\1\64\37\0\1\77"+
"\23\0\2\34\37\0\1\34\4\0\1\34\13\0\2\36"+
"\17\0\21\36\1\0\1\36\1\0\2\36\63\0\1\100"+
"\32\0\20\52\2\0\1\52\37\0\20\53\2\0\1\53"+
"\51\0\1\101\16\0\2\102\1\103\1\104\1\105\1\106"+
"\2\0\2\61\37\0\1\61\21\0\1\107\37\0\1\107"+
"\17\0\62\110\1\111\2\112\20\111\2\112\2\111\3\112"+
"\3\111\1\112\1\111\1\112\2\111\1\112\17\111\1\113"+
"\2\114\20\113\2\114\2\113\3\114\3\113\1\114\1\113"+
"\1\114\2\113\1\114\17\113\57\0\1\115\57\0\1\116"+
"\1\117\3\0\5\120\1\0\54\120\2\0\1\121\37\0"+
"\1\121\17\0\63\122\2\123\20\122\2\123\2\122\3\123"+
"\3\122\1\123\1\122\1\123\2\122\1\123\17\122\63\124"+
"\2\125\20\124\2\125\2\124\3\125\3\124\1\125\1\124"+
"\1\125\2\124\1\125\17\124\22\0\20\115\2\0\1\115"+
"\7\0\1\126\5\0\5\120\1\127\54\120\2\0\1\130"+
"\37\0\1\130\17\0\63\131\2\132\20\131\2\132\2\131"+
"\3\132\3\131\1\132\1\131\1\132\2\131\1\132\17\131"+
"\63\133\2\134\20\133\2\134\2\133\3\134\3\133\1\134"+
"\1\133\1\134\2\133\1\134\17\133";
private static int [] zzUnpackTrans() {
int [] result = new int[1813];
int [] result = new int[1950];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -265,15 +275,15 @@ class _RegExLexer implements FlexLexer {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\6\0\2\1\2\11\1\1\2\11\1\3\1\1\12\11"+
"\1\1\1\11\1\1\1\11\1\1\5\11\1\1\2\11"+
"\1\3\2\11\2\1\2\11\1\1\1\15\1\11\2\1"+
"\6\11\1\1\3\11\2\1\5\11\2\0\1\1\1\11"+
"\4\1\2\11\1\0\1\1\2\11\2\1\2\11\2\1"+
"\2\11";
"\6\0\2\1\2\11\1\1\2\11\2\1\12\11\1\1"+
"\1\11\1\1\1\11\1\1\5\11\1\1\2\11\1\1"+
"\2\11\2\1\2\11\1\1\2\11\2\1\6\11\1\1"+
"\3\11\2\1\2\11\1\0\3\11\2\0\1\1\1\11"+
"\4\1\1\0\2\11\1\0\1\1\2\11\2\1\3\11"+
"\2\1\2\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[89];
int [] result = new int[92];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -570,8 +580,6 @@ class _RegExLexer implements FlexLexer {
int [] zzTransL = ZZ_TRANS;
int [] zzRowMapL = ZZ_ROWMAP;
int [] zzAttrL = ZZ_ATTRIBUTE;
int zzPushbackPosL = zzPushbackPos = -1;
boolean zzWasPushback;
while (true) {
zzMarkedPosL = zzMarkedPos;
@@ -580,9 +588,8 @@ class _RegExLexer implements FlexLexer {
zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
zzState = zzLexicalState;
zzState = ZZ_LEXSTATE[zzLexicalState];
zzWasPushback = false;
zzForAction: {
while (true) {
@@ -597,14 +604,12 @@ class _RegExLexer implements FlexLexer {
// store back cached positions
zzCurrentPos = zzCurrentPosL;
zzMarkedPos = zzMarkedPosL;
zzPushbackPos = zzPushbackPosL;
boolean eof = zzRefill();
// get translated positions and possibly new buffer
zzCurrentPosL = zzCurrentPos;
zzMarkedPosL = zzMarkedPos;
zzBufferL = zzBuffer;
zzEndReadL = zzEndRead;
zzPushbackPosL = zzPushbackPos;
if (eof) {
zzInput = YYEOF;
break zzForAction;
@@ -618,11 +623,7 @@ class _RegExLexer implements FlexLexer {
zzState = zzNext;
int zzAttributes = zzAttrL[zzState];
if ( (zzAttributes & 2) == 2 )
zzPushbackPosL = zzCurrentPosL;
if ( (zzAttributes & 1) == 1 ) {
zzWasPushback = (zzAttributes & 4) == 4;
zzAction = zzState;
zzMarkedPosL = zzCurrentPosL;
if ( (zzAttributes & 8) == 8 ) break zzForAction;
@@ -633,246 +634,250 @@ class _RegExLexer implements FlexLexer {
// store back cached position
zzMarkedPos = zzMarkedPosL;
if (zzWasPushback)
zzMarkedPos = zzPushbackPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 7:
{ if (yystate() != CLASS2) yypushstate(EMBRACED); return RegExpTT.LBRACE;
}
case 62: break;
case 63: break;
case 6:
{ return RegExpTT.GROUP_END;
}
case 63: break;
case 64: break;
case 36:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 1;
{ yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN;
}
case 64: break;
case 65: break;
case 14:
{ return RegExpTT.STAR;
}
case 65: break;
case 66: break;
case 40:
{ return RegExpTT.ESC_CHARACTER;
}
case 66: break;
case 67: break;
case 28:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
}
case 67: break;
case 68: break;
case 41:
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
}
case 68: break;
case 69: break;
case 37:
{ return RegExpTT.REDUNDANT_ESCAPE;
}
case 69: break;
case 70: break;
case 24:
{ return RegExpTT.COMMA;
}
case 70: break;
case 71: break;
case 57:
{ return RegExpTT.POS_LOOKBEHIND;
}
case 71: break;
case 72: break;
case 39:
{ return RegExpTT.BAD_OCT_VALUE;
}
case 72: break;
case 73: break;
case 10:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
}
case 73: break;
case 74: break;
case 30:
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
}
case 74: break;
case 75: break;
case 49:
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
}
case 75: break;
case 76: break;
case 58:
{ return RegExpTT.NEG_LOOKBEHIND;
}
case 76: break;
case 61:
case 77: break;
case 62:
{ return RegExpTT.UNICODE_CHAR;
}
case 77: break;
case 78: break;
case 56:
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
}
case 78: break;
case 79: break;
case 35:
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
}
case 79: break;
case 80: break;
case 12:
{ return RegExpTT.DOLLAR;
}
case 80: break;
case 81: break;
case 50:
{ yypopstate(); return RegExpTT.QUOTE_END;
}
case 81: break;
case 82: break;
case 53:
{ return RegExpTT.POS_LOOKAHEAD;
}
case 82: break;
case 83: break;
case 22:
{ yypopstate(); return RegExpTT.RBRACE;
}
case 83: break;
case 84: break;
case 3:
{ return RegExpTT.CHARACTER;
}
case 84: break;
case 85: break;
case 54:
{ return RegExpTT.NEG_LOOKAHEAD;
}
case 85: break;
case 86: break;
case 42:
{ return RegExpTT.ESC_CTRL_CHARACTER;
}
case 86: break;
case 87: break;
case 23:
{ return RegExpTT.NAME;
}
case 87: break;
case 88: break;
case 51:
{ return RegExpTT.ANDAND;
}
case 88: break;
case 89: break;
case 13:
{ return RegExpTT.QUEST;
}
case 89: break;
case 90: break;
case 44:
{ return RegExpTT.CHAR_CLASS;
}
case 90: break;
case 91: break;
case 17:
{ return RegExpTT.MINUS;
}
case 91: break;
case 60:
case 92: break;
case 61:
{ return RegExpTT.COMMENT;
}
case 92: break;
case 93: break;
case 38:
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
}
case 93: break;
case 94: break;
case 16:
{ return RegExpTT.UNION;
}
case 94: break;
case 95: break;
case 60:
{ return RegExpTT.PYTHON_NAMED_GROUP;
}
case 96: break;
case 45:
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
}
case 95: break;
case 97: break;
case 55:
{ return RegExpTT.OCT_CHAR;
}
case 96: break;
case 98: break;
case 4:
{ return RegExpTT.DOT;
}
case 97: break;
case 99: break;
case 32:
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
}
case 98: break;
case 100: break;
case 21:
{ return RegExpTT.NUMBER;
}
case 99: break;
case 101: break;
case 46:
{ yypushstate(PROP); return RegExpTT.PROPERTY;
}
case 100: break;
case 102: break;
case 18:
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
}
case 101: break;
case 103: break;
case 33:
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
}
case 102: break;
case 104: break;
case 34:
{ yybegin(YYINITIAL); return RegExpTT.COLON;
}
case 103: break;
case 105: break;
case 25:
{ assert false : yytext();
}
case 104: break;
case 106: break;
case 27:
{ yypopstate(); return RegExpTT.CLASS_END;
}
case 105: break;
case 107: break;
case 11:
{ return RegExpTT.CARET;
}
case 106: break;
case 108: break;
case 1:
{ handleOptions(); return RegExpTT.OPTIONS_ON;
}
case 107: break;
case 109: break;
case 29:
{ yypopstate(); yypushback(1);
}
case 108: break;
case 110: break;
case 43:
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
}
case 109: break;
case 111: break;
case 19:
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
}
case 110: break;
case 112: break;
case 59:
{ return RegExpTT.HEX_CHAR;
}
case 111: break;
case 113: break;
case 5:
{ return RegExpTT.GROUP_BEGIN;
}
case 112: break;
case 114: break;
case 8:
{ yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN;
}
case 113: break;
case 115: break;
case 52:
{ return RegExpTT.NON_CAPT_GROUP;
}
case 114: break;
case 116: break;
case 9:
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
}
case 115: break;
case 117: break;
case 48:
{ return RegExpTT.BAD_HEX_VALUE;
}
case 116: break;
case 118: break;
case 2:
{ yypopstate(); return RegExpTT.COMMENT;
}
case 117: break;
case 119: break;
case 47:
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
}
case 118: break;
case 120: break;
case 26:
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
}
case 119: break;
case 121: break;
case 15:
{ return RegExpTT.PLUS;
}
case 120: break;
case 122: break;
case 20:
{ if (allowDanglingMetacharacters) {
yypopstate(); yypushback(1);
@@ -880,11 +885,11 @@ class _RegExLexer implements FlexLexer {
return RegExpTT.BAD_CHARACTER;
}
}
case 121: break;
case 123: break;
case 31:
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
}
case 122: break;
case 124: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;
@@ -22,4 +22,6 @@ public interface RegExpGroup extends RegExpAtom {
@Nullable
RegExpPattern getPattern();
boolean isPythonNamedGroup();
}
@@ -41,4 +41,8 @@ public class RegExpGroupImpl extends RegExpElementImpl implements RegExpGroup {
final ASTNode node = getNode().findChildByType(RegExpElementTypes.PATTERN);
return node != null ? (RegExpPattern)node.getPsi() : null;
}
public boolean isPythonNamedGroup() {
return getNode().findChildByType(RegExpTT.PYTHON_NAMED_GROUP) != null;
}
}
@@ -205,6 +205,7 @@ HEX_CHAR=[0-9a-fA-F]
"(?<=" { return RegExpTT.POS_LOOKBEHIND; }
"(?<!" { return RegExpTT.NEG_LOOKBEHIND; }
"(?#" [^)]+ ")" { return RegExpTT.COMMENT; }
"(?P<" [:letter:]* ">" { return RegExpTT.PYTHON_NAMED_GROUP; }
"(?" { yybegin(OPTIONS); return RegExpTT.SET_OPTIONS; }
}
@@ -30,12 +30,13 @@ import org.intellij.lang.regexp.RegExpLanguageHost;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.*;
import org.intellij.lang.regexp.psi.impl.RegExpPropertyImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class RegExpAnnotator extends RegExpElementVisitor implements Annotator {
private AnnotationHolder myHolder;
public void annotate(PsiElement psiElement, AnnotationHolder holder) {
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
assert myHolder == null : "unsupported concurrent annotator invocation";
try {
myHolder = holder;
@@ -159,6 +160,12 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
}
}
}
if (group.isPythonNamedGroup()) {
RegExpLanguageHost host = findRegExpHost(group);
if (host == null || !host.supportsPythonNamedGroups()) {
myHolder.createErrorAnnotation(group, "This named group syntax is not supported");
}
}
}
@Override