mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support Python conditional references in regexps
This commit is contained in:
@@ -37,6 +37,7 @@ public interface RegExpElementTypes {
|
||||
IElementType BACKREF = new RegExpElementType("BACKREF");
|
||||
IElementType BOUNDARY = new RegExpElementType("BOUNDARY");
|
||||
IElementType PY_NAMED_GROUP_REF = new RegExpElementType("PY_NAMED_GROUP_REF");
|
||||
IElementType PY_COND_REF = new RegExpElementType("PY_COND_REF");
|
||||
|
||||
TokenSet ATOMS = TokenSet.create(CLOSURE, BOUNDARY,
|
||||
SIMPLE_CLASS, CLASS, CHAR, GROUP, PROPERTY, SET_OPTIONS, BACKREF, PY_NAMED_GROUP_REF);
|
||||
|
||||
@@ -23,4 +23,5 @@ public interface RegExpLanguageHost {
|
||||
boolean supportsPerl5EmbeddedComments();
|
||||
boolean supportsPossessiveQuantifiers();
|
||||
boolean supportsPythonNamedGroups();
|
||||
boolean supportsPythonConditionalRefs();
|
||||
}
|
||||
|
||||
@@ -361,6 +361,27 @@ public class RegExpParser implements PsiParser {
|
||||
checkMatches(builder, RegExpTT.NAME, "Group name expected");
|
||||
checkMatches(builder, RegExpTT.GROUP_END, "Unclosed group reference");
|
||||
marker.done(RegExpElementTypes.PY_NAMED_GROUP_REF);
|
||||
} else if (type == RegExpTT.PYTHON_COND_REF) {
|
||||
builder.advanceLexer();
|
||||
if (builder.getTokenType() == RegExpTT.NAME || builder.getTokenType() == RegExpTT.NUMBER) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
else {
|
||||
builder.error("Group name or number expected");
|
||||
}
|
||||
checkMatches(builder, RegExpTT.GROUP_END, "Unclosed group reference");
|
||||
if (!parseBranch(builder)) {
|
||||
patternExpected(builder);
|
||||
} else {
|
||||
if (builder.getTokenType() == RegExpTT.UNION) {
|
||||
builder.advanceLexer();
|
||||
if (!parseBranch(builder)) {
|
||||
patternExpected(builder);
|
||||
}
|
||||
}
|
||||
checkMatches(builder, RegExpTT.GROUP_END, "Unclosed group");
|
||||
}
|
||||
marker.done(RegExpElementTypes.PY_COND_REF);
|
||||
} else if (type == RegExpTT.PROPERTY) {
|
||||
parseProperty(builder);
|
||||
marker.done(RegExpElementTypes.PROPERTY);
|
||||
|
||||
@@ -98,7 +98,10 @@ public class RegExpParserDefinition implements ParserDefinition {
|
||||
return new RegExpIntersectionImpl(node);
|
||||
} else if (type == RegExpElementTypes.PY_NAMED_GROUP_REF) {
|
||||
return new RegExpPyNamedGroupRefImpl(node);
|
||||
} else if (type == RegExpElementTypes.PY_COND_REF) {
|
||||
return new RegExpPyCondRefImpl(node);
|
||||
}
|
||||
|
||||
return new ASTWrapperPsiElement(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,9 @@ public interface RegExpTT {
|
||||
IElementType PYTHON_NAMED_GROUP = new RegExpElementType("PYTHON_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");
|
||||
|
||||
|
||||
TokenSet KEYWORDS = TokenSet.create(DOT, STAR, QUEST, PLUS);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* The following code was generated by JFlex 1.4.3 on 22.03.10 21:13 */
|
||||
/* The following code was generated by JFlex 1.4.3 on 22.03.10 22:06 */
|
||||
|
||||
/* It's an automatically generated code. Do not modify it. */
|
||||
package org.intellij.lang.regexp;
|
||||
@@ -14,7 +14,7 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 22.03.10 21:13 from the specification file
|
||||
* on 22.03.10 22:06 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 {
|
||||
@@ -27,6 +27,7 @@ class _RegExLexer implements FlexLexer {
|
||||
public static final int PY_NAMED_GROUP_REF = 18;
|
||||
public static final int QUOTED = 2;
|
||||
public static final int OPTIONS = 12;
|
||||
public static final int PY_COND_REF = 20;
|
||||
public static final int YYINITIAL = 0;
|
||||
public static final int CLASS2 = 8;
|
||||
public static final int CLASS1 = 6;
|
||||
@@ -41,7 +42,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
|
||||
8, 8, 9, 9, 10, 10
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -127,20 +128,20 @@ class _RegExLexer implements FlexLexer {
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
|
||||
private static final String ZZ_ACTION_PACKED_0 =
|
||||
"\6\0\1\1\1\2\2\0\1\3\1\4\1\5\1\6"+
|
||||
"\6\0\1\1\1\2\3\0\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\3\1\24\1\25"+
|
||||
"\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\3"+
|
||||
"\1\35\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\1\55\2\56\1\57\1\11\1\60"+
|
||||
"\1\61\1\62\1\63\1\64\1\0\1\65\1\66\1\67"+
|
||||
"\2\0\1\70\1\71\2\61\2\62\1\72\1\73\1\74"+
|
||||
"\1\75\1\0\1\70\1\61\1\76\2\62\1\77\1\70"+
|
||||
"\3\62\1\100";
|
||||
"\1\61\1\62\1\63\1\64\1\65\1\0\1\66\1\67"+
|
||||
"\1\70\2\0\1\71\1\72\2\61\2\62\1\73\1\74"+
|
||||
"\1\75\1\76\1\0\1\71\1\61\1\77\2\62\1\100"+
|
||||
"\1\71\3\62\1\101";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[95];
|
||||
int [] result = new int[97];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -166,20 +167,21 @@ class _RegExLexer implements FlexLexer {
|
||||
|
||||
private static final String ZZ_ROWMAP_PACKED_0 =
|
||||
"\0\0\0\62\0\144\0\226\0\310\0\372\0\u012c\0\u015e"+
|
||||
"\0\u0190\0\u01c2\0\u01f4\0\u01f4\0\u0226\0\u01f4\0\u01f4\0\u0258"+
|
||||
"\0\u028a\0\u01f4\0\u01f4\0\u01f4\0\u01f4\0\u01f4\0\u01f4\0\u01f4"+
|
||||
"\0\u01f4\0\u01f4\0\u01f4\0\u02bc\0\u01f4\0\u02ee\0\u01f4\0\u0320"+
|
||||
"\0\u01f4\0\u01f4\0\u01f4\0\u01f4\0\u01f4\0\u0352\0\u01f4\0\u01f4"+
|
||||
"\0\u0258\0\u01f4\0\u01f4\0\u0384\0\u03b6\0\u01f4\0\u01f4\0\u01f4"+
|
||||
"\0\u03e8\0\u01f4\0\u01f4\0\u041a\0\u044c\0\u01f4\0\u01f4\0\u01f4"+
|
||||
"\0\u01f4\0\u01f4\0\u01f4\0\u047e\0\u01f4\0\u01f4\0\u01f4\0\u04b0"+
|
||||
"\0\u04e2\0\u01f4\0\u01f4\0\u0514\0\u01f4\0\u01f4\0\u01f4\0\u0546"+
|
||||
"\0\u0578\0\u05aa\0\u01f4\0\u05dc\0\u060e\0\u0640\0\u0672\0\u01f4"+
|
||||
"\0\u01f4\0\u01f4\0\u01f4\0\u06a4\0\u06d6\0\u01f4\0\u01f4\0\u0708"+
|
||||
"\0\u073a\0\u01f4\0\u01f4\0\u076c\0\u079e\0\u01f4\0\u01f4";
|
||||
"\0\u0190\0\u01c2\0\u01f4\0\u0226\0\u0226\0\u0258\0\u0226\0\u0226"+
|
||||
"\0\u028a\0\u02bc\0\u0226\0\u0226\0\u0226\0\u0226\0\u0226\0\u0226"+
|
||||
"\0\u0226\0\u0226\0\u0226\0\u0226\0\u02ee\0\u0226\0\u0320\0\u0226"+
|
||||
"\0\u0352\0\u0226\0\u0226\0\u0226\0\u0226\0\u0226\0\u0384\0\u0226"+
|
||||
"\0\u0226\0\u028a\0\u0226\0\u0226\0\u03b6\0\u03e8\0\u0226\0\u0226"+
|
||||
"\0\u0226\0\u041a\0\u0226\0\u0226\0\u044c\0\u047e\0\u0226\0\u0226"+
|
||||
"\0\u0226\0\u0226\0\u0226\0\u0226\0\u04b0\0\u0226\0\u0226\0\u0226"+
|
||||
"\0\u04e2\0\u0514\0\u0226\0\u0226\0\u0226\0\u0546\0\u0226\0\u0226"+
|
||||
"\0\u0226\0\u0578\0\u05aa\0\u05dc\0\u0226\0\u060e\0\u0640\0\u0672"+
|
||||
"\0\u06a4\0\u0226\0\u0226\0\u0226\0\u0226\0\u06d6\0\u0708\0\u0226"+
|
||||
"\0\u0226\0\u073a\0\u076c\0\u0226\0\u0226\0\u079e\0\u07d0\0\u0226"+
|
||||
"\0\u0226";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[95];
|
||||
int [] result = new int[97];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -202,44 +204,46 @@ class _RegExLexer implements FlexLexer {
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\3\13\1\14\1\15\1\16\1\17\1\13\1\20\1\13"+
|
||||
"\1\21\1\22\1\23\1\24\1\25\1\26\1\27\1\30"+
|
||||
"\21\13\1\31\1\13\1\32\4\13\1\22\5\13\1\33"+
|
||||
"\1\22\12\13\1\34\1\0\46\13\1\35\2\36\4\35"+
|
||||
"\1\37\12\35\20\40\1\36\1\35\1\40\2\35\1\36"+
|
||||
"\1\41\11\35\11\42\1\43\1\42\1\0\46\42\6\13"+
|
||||
"\1\17\1\13\1\20\1\44\1\21\1\45\1\23\26\13"+
|
||||
"\1\31\5\13\1\46\1\45\6\13\1\45\6\47\1\50"+
|
||||
"\1\47\1\51\1\47\1\21\47\47\5\52\1\53\14\52"+
|
||||
"\20\54\1\52\1\55\1\54\6\52\1\56\6\52\13\10"+
|
||||
"\1\57\45\10\1\57\22\0\20\40\2\0\1\40\7\0"+
|
||||
"\1\60\5\0\5\52\1\53\14\52\20\40\2\52\1\40"+
|
||||
"\15\52\100\0\1\61\54\0\1\62\50\0\1\63\1\64"+
|
||||
"\1\65\4\66\1\63\1\66\1\63\1\66\1\67\6\66"+
|
||||
"\2\70\2\71\2\72\1\73\1\74\1\73\2\75\1\76"+
|
||||
"\1\77\1\76\1\100\1\101\1\64\1\66\1\76\1\67"+
|
||||
"\4\63\1\67\6\63\1\67\37\0\1\102\23\0\2\36"+
|
||||
"\37\0\1\36\4\0\1\36\13\0\2\40\17\0\21\40"+
|
||||
"\1\0\1\40\1\0\2\40\63\0\1\103\32\0\20\54"+
|
||||
"\2\0\1\54\37\0\20\55\2\0\1\55\51\0\1\104"+
|
||||
"\16\0\2\105\1\106\1\107\1\110\1\111\2\0\2\64"+
|
||||
"\37\0\1\64\21\0\1\112\37\0\1\112\17\0\62\113"+
|
||||
"\1\114\2\115\20\114\2\115\2\114\3\115\3\114\1\115"+
|
||||
"\1\114\1\115\2\114\1\115\17\114\1\116\2\117\20\116"+
|
||||
"\3\14\1\15\1\16\1\17\1\20\1\14\1\21\1\14"+
|
||||
"\1\22\1\23\1\24\1\25\1\26\1\27\1\30\1\31"+
|
||||
"\21\14\1\32\1\14\1\33\4\14\1\23\5\14\1\34"+
|
||||
"\1\23\12\14\1\35\1\0\46\14\1\36\2\37\4\36"+
|
||||
"\1\40\12\36\20\41\1\37\1\36\1\41\2\36\1\37"+
|
||||
"\1\42\11\36\11\43\1\44\1\43\1\0\46\43\6\14"+
|
||||
"\1\20\1\14\1\21\1\45\1\22\1\46\1\24\26\14"+
|
||||
"\1\32\5\14\1\47\1\46\6\14\1\46\6\50\1\51"+
|
||||
"\1\50\1\52\1\50\1\22\47\50\5\53\1\54\14\53"+
|
||||
"\20\55\1\53\1\56\1\55\6\53\1\57\6\53\13\10"+
|
||||
"\1\60\45\10\1\60\22\0\20\41\2\0\1\41\7\0"+
|
||||
"\1\61\5\0\5\53\1\54\14\53\20\41\2\53\1\41"+
|
||||
"\16\53\2\37\2\53\1\54\14\53\20\41\1\37\1\53"+
|
||||
"\1\41\2\53\1\37\12\53\100\0\1\62\54\0\1\63"+
|
||||
"\50\0\1\64\1\65\1\66\4\67\1\64\1\67\1\64"+
|
||||
"\1\67\1\70\6\67\2\71\2\72\2\73\1\74\1\75"+
|
||||
"\1\74\2\76\1\77\1\100\1\77\1\101\1\102\1\65"+
|
||||
"\1\67\1\77\1\70\4\64\1\70\6\64\1\70\37\0"+
|
||||
"\1\103\23\0\2\37\37\0\1\37\4\0\1\37\13\0"+
|
||||
"\2\41\17\0\21\41\1\0\1\41\1\0\2\41\63\0"+
|
||||
"\1\104\32\0\20\55\2\0\1\55\37\0\20\56\2\0"+
|
||||
"\1\56\21\0\1\105\27\0\1\106\16\0\2\107\1\110"+
|
||||
"\1\111\1\112\1\113\2\0\2\65\37\0\1\65\21\0"+
|
||||
"\1\114\37\0\1\114\17\0\62\115\1\116\2\117\20\116"+
|
||||
"\2\117\2\116\3\117\3\116\1\117\1\116\1\117\2\116"+
|
||||
"\1\117\17\116\55\0\1\120\1\0\1\121\57\0\1\122"+
|
||||
"\1\123\3\0\5\124\1\0\54\124\2\0\1\125\37\0"+
|
||||
"\1\125\17\0\63\126\2\127\20\126\2\127\2\126\3\127"+
|
||||
"\3\126\1\127\1\126\1\127\2\126\1\127\17\126\63\130"+
|
||||
"\1\117\17\116\1\120\2\121\20\120\2\121\2\120\3\121"+
|
||||
"\3\120\1\121\1\120\1\121\2\120\1\121\17\120\55\0"+
|
||||
"\1\122\1\0\1\123\57\0\1\124\1\125\3\0\5\126"+
|
||||
"\1\0\54\126\2\0\1\127\37\0\1\127\17\0\63\130"+
|
||||
"\2\131\20\130\2\131\2\130\3\131\3\130\1\131\1\130"+
|
||||
"\1\131\2\130\1\131\17\130\5\124\1\132\54\124\2\0"+
|
||||
"\1\133\37\0\1\133\17\0\63\134\2\135\20\134\2\135"+
|
||||
"\2\134\3\135\3\134\1\135\1\134\1\135\2\134\1\135"+
|
||||
"\17\134\63\136\2\137\20\136\2\137\2\136\3\137\3\136"+
|
||||
"\1\137\1\136\1\137\2\136\1\137\17\136";
|
||||
"\1\131\2\130\1\131\17\130\63\132\2\133\20\132\2\133"+
|
||||
"\2\132\3\133\3\132\1\133\1\132\1\133\2\132\1\133"+
|
||||
"\17\132\5\126\1\134\54\126\2\0\1\135\37\0\1\135"+
|
||||
"\17\0\63\136\2\137\20\136\2\137\2\136\3\137\3\136"+
|
||||
"\1\137\1\136\1\137\2\136\1\137\17\136\63\140\2\141"+
|
||||
"\20\140\2\141\2\140\3\141\3\140\1\141\1\140\1\141"+
|
||||
"\2\140\1\141\17\140";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[2000];
|
||||
int [] result = new int[2050];
|
||||
int offset = 0;
|
||||
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -280,15 +284,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\0\2\11\1\1\2\11\2\1\12\11"+
|
||||
"\6\0\2\1\3\0\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\3\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\1\3\11\2\1\3\11\1\0\3\11\2\0\1\1"+
|
||||
"\1\11\4\1\4\11\1\0\1\1\2\11\2\1\2\11"+
|
||||
"\2\1\2\11";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[95];
|
||||
int [] result = new int[97];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -644,253 +648,257 @@ class _RegExLexer implements FlexLexer {
|
||||
case 7:
|
||||
{ if (yystate() != CLASS2) yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 65: break;
|
||||
case 66: break;
|
||||
case 6:
|
||||
{ return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 66: break;
|
||||
case 67: break;
|
||||
case 37:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 67: break;
|
||||
case 68: break;
|
||||
case 14:
|
||||
{ return RegExpTT.STAR;
|
||||
}
|
||||
case 68: break;
|
||||
case 69: break;
|
||||
case 41:
|
||||
{ return RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 69: break;
|
||||
case 70: break;
|
||||
case 28:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 70: break;
|
||||
case 71: break;
|
||||
case 42:
|
||||
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 71: break;
|
||||
case 72: break;
|
||||
case 38:
|
||||
{ return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 72: break;
|
||||
case 73: break;
|
||||
case 24:
|
||||
{ return RegExpTT.COMMA;
|
||||
}
|
||||
case 73: break;
|
||||
case 60:
|
||||
case 74: break;
|
||||
case 61:
|
||||
{ return RegExpTT.POS_LOOKBEHIND;
|
||||
}
|
||||
case 74: break;
|
||||
case 75: break;
|
||||
case 40:
|
||||
{ return RegExpTT.BAD_OCT_VALUE;
|
||||
}
|
||||
case 75: break;
|
||||
case 76: break;
|
||||
case 10:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
|
||||
}
|
||||
case 76: break;
|
||||
case 77: break;
|
||||
case 30:
|
||||
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 77: break;
|
||||
case 78: break;
|
||||
case 50:
|
||||
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
|
||||
}
|
||||
case 78: break;
|
||||
case 61:
|
||||
case 79: break;
|
||||
case 62:
|
||||
{ return RegExpTT.NEG_LOOKBEHIND;
|
||||
}
|
||||
case 79: break;
|
||||
case 64:
|
||||
case 80: break;
|
||||
case 65:
|
||||
{ return RegExpTT.UNICODE_CHAR;
|
||||
}
|
||||
case 80: break;
|
||||
case 57:
|
||||
case 81: break;
|
||||
case 58:
|
||||
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
|
||||
}
|
||||
case 81: break;
|
||||
case 82: break;
|
||||
case 36:
|
||||
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
|
||||
}
|
||||
case 82: break;
|
||||
case 83: break;
|
||||
case 12:
|
||||
{ return RegExpTT.DOLLAR;
|
||||
}
|
||||
case 83: break;
|
||||
case 84: break;
|
||||
case 51:
|
||||
{ yypopstate(); return RegExpTT.QUOTE_END;
|
||||
}
|
||||
case 84: break;
|
||||
case 54:
|
||||
case 85: break;
|
||||
case 55:
|
||||
{ return RegExpTT.POS_LOOKAHEAD;
|
||||
}
|
||||
case 85: break;
|
||||
case 86: break;
|
||||
case 22:
|
||||
{ yypopstate(); return RegExpTT.RBRACE;
|
||||
}
|
||||
case 86: break;
|
||||
case 87: break;
|
||||
case 3:
|
||||
{ return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 87: break;
|
||||
case 55:
|
||||
case 88: break;
|
||||
case 56:
|
||||
{ return RegExpTT.NEG_LOOKAHEAD;
|
||||
}
|
||||
case 88: break;
|
||||
case 89: break;
|
||||
case 43:
|
||||
{ return RegExpTT.ESC_CTRL_CHARACTER;
|
||||
}
|
||||
case 89: break;
|
||||
case 90: break;
|
||||
case 23:
|
||||
{ return RegExpTT.NAME;
|
||||
}
|
||||
case 90: break;
|
||||
case 91: break;
|
||||
case 52:
|
||||
{ return RegExpTT.ANDAND;
|
||||
}
|
||||
case 91: break;
|
||||
case 92: break;
|
||||
case 13:
|
||||
{ return RegExpTT.QUEST;
|
||||
}
|
||||
case 92: break;
|
||||
case 93: break;
|
||||
case 45:
|
||||
{ return RegExpTT.CHAR_CLASS;
|
||||
}
|
||||
case 93: break;
|
||||
case 94: break;
|
||||
case 17:
|
||||
{ return RegExpTT.MINUS;
|
||||
}
|
||||
case 94: break;
|
||||
case 63:
|
||||
case 95: break;
|
||||
case 64:
|
||||
{ return RegExpTT.COMMENT;
|
||||
}
|
||||
case 95: break;
|
||||
case 96: break;
|
||||
case 39:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 96: break;
|
||||
case 97: break;
|
||||
case 16:
|
||||
{ return RegExpTT.UNION;
|
||||
}
|
||||
case 97: break;
|
||||
case 98: break;
|
||||
case 46:
|
||||
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 98: break;
|
||||
case 56:
|
||||
case 99: break;
|
||||
case 57:
|
||||
{ return RegExpTT.OCT_CHAR;
|
||||
}
|
||||
case 99: break;
|
||||
case 100: break;
|
||||
case 4:
|
||||
{ return RegExpTT.DOT;
|
||||
}
|
||||
case 100: break;
|
||||
case 101: break;
|
||||
case 32:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 101: break;
|
||||
case 102: break;
|
||||
case 21:
|
||||
{ return RegExpTT.NUMBER;
|
||||
}
|
||||
case 102: break;
|
||||
case 103: break;
|
||||
case 35:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GT;
|
||||
}
|
||||
case 103: break;
|
||||
case 104: break;
|
||||
case 53:
|
||||
{ yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF;
|
||||
}
|
||||
case 105: break;
|
||||
case 47:
|
||||
{ yypushstate(PROP); return RegExpTT.PROPERTY;
|
||||
}
|
||||
case 104: break;
|
||||
case 106: break;
|
||||
case 18:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 105: break;
|
||||
case 107: break;
|
||||
case 33:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
|
||||
}
|
||||
case 106: break;
|
||||
case 108: break;
|
||||
case 34:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.COLON;
|
||||
}
|
||||
case 107: break;
|
||||
case 109: break;
|
||||
case 25:
|
||||
{ assert false : yytext();
|
||||
}
|
||||
case 108: break;
|
||||
case 58:
|
||||
case 110: break;
|
||||
case 59:
|
||||
{ yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF;
|
||||
}
|
||||
case 109: break;
|
||||
case 111: break;
|
||||
case 27:
|
||||
{ yypopstate(); return RegExpTT.CLASS_END;
|
||||
}
|
||||
case 110: break;
|
||||
case 112: break;
|
||||
case 11:
|
||||
{ return RegExpTT.CARET;
|
||||
}
|
||||
case 111: break;
|
||||
case 113: break;
|
||||
case 1:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_ON;
|
||||
}
|
||||
case 112: break;
|
||||
case 114: break;
|
||||
case 29:
|
||||
{ yypopstate(); yypushback(1);
|
||||
}
|
||||
case 113: break;
|
||||
case 115: break;
|
||||
case 44:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 114: break;
|
||||
case 116: break;
|
||||
case 19:
|
||||
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 115: break;
|
||||
case 62:
|
||||
case 117: break;
|
||||
case 63:
|
||||
{ return RegExpTT.HEX_CHAR;
|
||||
}
|
||||
case 116: break;
|
||||
case 59:
|
||||
case 118: break;
|
||||
case 60:
|
||||
{ yybegin(PY_NAMED_GROUP); return RegExpTT.PYTHON_NAMED_GROUP;
|
||||
}
|
||||
case 117: break;
|
||||
case 119: break;
|
||||
case 5:
|
||||
{ return RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
case 118: break;
|
||||
case 120: break;
|
||||
case 8:
|
||||
{ yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 119: break;
|
||||
case 53:
|
||||
case 121: break;
|
||||
case 54:
|
||||
{ return RegExpTT.NON_CAPT_GROUP;
|
||||
}
|
||||
case 120: break;
|
||||
case 122: break;
|
||||
case 9:
|
||||
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 121: break;
|
||||
case 123: break;
|
||||
case 49:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 122: break;
|
||||
case 124: break;
|
||||
case 2:
|
||||
{ yypopstate(); return RegExpTT.COMMENT;
|
||||
}
|
||||
case 123: break;
|
||||
case 125: break;
|
||||
case 48:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 124: break;
|
||||
case 126: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 125: break;
|
||||
case 127: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 126: break;
|
||||
case 128: break;
|
||||
case 20:
|
||||
{ if (allowDanglingMetacharacters) {
|
||||
yypopstate(); yypushback(1);
|
||||
@@ -898,11 +906,11 @@ class _RegExLexer implements FlexLexer {
|
||||
return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
}
|
||||
case 127: break;
|
||||
case 129: break;
|
||||
case 31:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
case 128: break;
|
||||
case 130: break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
|
||||
@@ -86,4 +86,8 @@ public class RegExpElementVisitor extends PsiElementVisitor {
|
||||
public void visitRegExpPyNamedGroupRef(RegExpPyNamedGroupRef groupRef) {
|
||||
visitRegExpElement(groupRef);
|
||||
}
|
||||
|
||||
public void visitRegExpPyCondRef(RegExpPyCondRef condRef) {
|
||||
visitRegExpElement(condRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
*/
|
||||
package org.intellij.lang.regexp.psi;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface RegExpPyCondRef extends RegExpAtom {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
*/
|
||||
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.RegExpPyCondRef;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class RegExpPyCondRefImpl extends RegExpElementImpl implements RegExpPyCondRef {
|
||||
public RegExpPyCondRefImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(RegExpElementVisitor visitor) {
|
||||
visitor.visitRegExpPyCondRef(this);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
%xstate COMMENT
|
||||
%xstate PY_NAMED_GROUP
|
||||
%xstate PY_NAMED_GROUP_REF
|
||||
%xstate PY_COND_REF
|
||||
|
||||
DIGITS=[1-9][0-9]*
|
||||
|
||||
@@ -209,6 +210,7 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
"(?#" [^)]+ ")" { return RegExpTT.COMMENT; }
|
||||
"(?P<" { yybegin(PY_NAMED_GROUP); 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(OPTIONS); return RegExpTT.SET_OPTIONS; }
|
||||
}
|
||||
@@ -234,6 +236,13 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
{ANY} { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; }
|
||||
}
|
||||
|
||||
<PY_COND_REF> {
|
||||
[:letter:]([:letter:]|_|[:digit:])* { return RegExpTT.NAME; }
|
||||
[:digit:]+ { return RegExpTT.NUMBER; }
|
||||
")" { yybegin(YYINITIAL); return RegExpTT.GROUP_END; }
|
||||
{ANY} { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; }
|
||||
}
|
||||
|
||||
/* "dangling ]" */
|
||||
<YYINITIAL> {RBRACKET} { return RegExpTT.CHARACTER; }
|
||||
|
||||
|
||||
@@ -202,7 +202,15 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(RegExpBranch[] branches) {
|
||||
@Override
|
||||
public void visitRegExpPyCondRef(RegExpPyCondRef condRef) {
|
||||
RegExpLanguageHost host = findRegExpHost(condRef);
|
||||
if (host == null || !host.supportsPythonConditionalRefs()) {
|
||||
myHolder.createErrorAnnotation(condRef, "Conditional references are not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(RegExpBranch[] branches) {
|
||||
for (RegExpBranch branch : branches) {
|
||||
if (branch.getAtoms().length > 0) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user