mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Python also has its own regexp dialect; correct parsing of character classes for Python (PY-2908)
This commit is contained in:
@@ -21,8 +21,8 @@ public class RegExpLexer extends FlexAdapter {
|
||||
|
||||
private static final int COMMENT_MODE = 1 << 14;
|
||||
|
||||
public RegExpLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) {
|
||||
super(new _RegExLexer(xmlSchemaMode, allowDanglingMetacharacters));
|
||||
public RegExpLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters, boolean allowRBracketInCharacterClass) {
|
||||
super(new _RegExLexer(xmlSchemaMode, allowDanglingMetacharacters, allowRBracketInCharacterClass));
|
||||
}
|
||||
|
||||
public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class RegExpParserDefinition implements ParserDefinition {
|
||||
|
||||
@NotNull
|
||||
public Lexer createLexer(Project project) {
|
||||
return new RegExpLexer(false, false);
|
||||
return new RegExpLexer(false, false, true);
|
||||
}
|
||||
|
||||
public PsiParser createParser(Project project) {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/* The following code was generated by JFlex 1.4.3 on 01.06.10 15:51 */
|
||||
/* The following code was generated by JFlex 1.4.3 on 21.02.11 18:10 */
|
||||
|
||||
/* 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" })
|
||||
@@ -15,8 +14,8 @@ import java.util.LinkedList;
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 01.06.10 15:51 from the specification file
|
||||
* <tt>C:/JetBrains/idea.branches/maia/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
|
||||
* on 21.02.11 18:10 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 {
|
||||
/** initial size of the lookahead buffer */
|
||||
@@ -24,17 +23,18 @@ class _RegExLexer implements FlexLexer {
|
||||
|
||||
/** lexical states */
|
||||
public static final int EMBRACED = 4;
|
||||
public static final int PY_NAMED_GROUP_REF = 20;
|
||||
public static final int PY_NAMED_GROUP_REF = 22;
|
||||
public static final int QUOTED = 2;
|
||||
public static final int OPTIONS = 12;
|
||||
public static final int PY_COND_REF = 22;
|
||||
public static final int CLASS2PY = 10;
|
||||
public static final int OPTIONS = 14;
|
||||
public static final int PY_COND_REF = 24;
|
||||
public static final int YYINITIAL = 0;
|
||||
public static final int NAMED_GROUP = 16;
|
||||
public static final int NAMED_GROUP = 18;
|
||||
public static final int CLASS2 = 8;
|
||||
public static final int CLASS1 = 6;
|
||||
public static final int COMMENT = 14;
|
||||
public static final int QUOTED_NAMED_GROUP = 18;
|
||||
public static final int PROP = 10;
|
||||
public static final int COMMENT = 16;
|
||||
public static final int QUOTED_NAMED_GROUP = 20;
|
||||
public static final int PROP = 12;
|
||||
|
||||
/**
|
||||
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
|
||||
@@ -44,7 +44,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
|
||||
8, 8, 9, 9, 10, 10, 11, 11, 12, 12
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -130,20 +130,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\4\0\1\3\1\4\1\5\1\6"+
|
||||
"\7\0\1\1\1\2\4\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\1\56\2\57\1\60\1\11"+
|
||||
"\1\61\1\62\1\63\1\64\1\65\1\66\1\0\1\67"+
|
||||
"\1\70\1\71\1\72\1\0\1\73\1\74\1\75\2\62"+
|
||||
"\2\63\1\76\1\77\1\100\1\101\1\0\1\74\1\62"+
|
||||
"\1\102\2\63\1\103\1\74\3\63\1\104";
|
||||
"\1\26\1\27\1\30\1\31\1\32\1\33\1\34\2\3"+
|
||||
"\1\11\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\1\56\2\57\1\60"+
|
||||
"\1\11\1\61\1\62\1\63\1\64\1\65\1\66\1\0"+
|
||||
"\1\67\1\70\1\71\1\72\1\0\1\73\1\74\1\75"+
|
||||
"\2\62\2\63\1\76\1\77\1\100\1\101\1\0\1\74"+
|
||||
"\1\62\1\102\2\63\1\103\1\74\3\63\1\104";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[100];
|
||||
int [] result = new int[103];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -169,21 +169,21 @@ class _RegExLexer implements FlexLexer {
|
||||
|
||||
private static final String ZZ_ROWMAP_PACKED_0 =
|
||||
"\0\0\0\63\0\146\0\231\0\314\0\377\0\u0132\0\u0165"+
|
||||
"\0\u0198\0\u01cb\0\u01fe\0\u0231\0\u0264\0\u0264\0\u0297\0\u0264"+
|
||||
"\0\u0264\0\u02ca\0\u02fd\0\u0264\0\u0264\0\u0264\0\u0264\0\u0264"+
|
||||
"\0\u0264\0\u0264\0\u0264\0\u0264\0\u0264\0\u0330\0\u0264\0\u0363"+
|
||||
"\0\u0264\0\u0396\0\u0264\0\u0264\0\u0264\0\u0264\0\u0264\0\u03c9"+
|
||||
"\0\u0264\0\u0264\0\u02ca\0\u0264\0\u0264\0\u03fc\0\u042f\0\u0264"+
|
||||
"\0\u0264\0\u0264\0\u0264\0\u0462\0\u0264\0\u0264\0\u0495\0\u04c8"+
|
||||
"\0\u0264\0\u0264\0\u0264\0\u0264\0\u0264\0\u0264\0\u04fb\0\u0264"+
|
||||
"\0\u0264\0\u0264\0\u052e\0\u0561\0\u0264\0\u0264\0\u0264\0\u0594"+
|
||||
"\0\u0264\0\u0264\0\u0264\0\u05c7\0\u05fa\0\u0264\0\u062d\0\u0264"+
|
||||
"\0\u0660\0\u0693\0\u06c6\0\u06f9\0\u0264\0\u0264\0\u0264\0\u0264"+
|
||||
"\0\u072c\0\u075f\0\u0264\0\u0264\0\u0792\0\u07c5\0\u0264\0\u0264"+
|
||||
"\0\u07f8\0\u082b\0\u0264\0\u0264";
|
||||
"\0\u0198\0\u01cb\0\u01fe\0\u0231\0\u0264\0\u0297\0\u0297\0\u02ca"+
|
||||
"\0\u0297\0\u0297\0\u02fd\0\u0330\0\u0297\0\u0297\0\u0297\0\u0297"+
|
||||
"\0\u0297\0\u0297\0\u0297\0\u0297\0\u0297\0\u0297\0\u0363\0\u0297"+
|
||||
"\0\u0396\0\u0297\0\u03c9\0\u0297\0\u0297\0\u0297\0\u0297\0\u0297"+
|
||||
"\0\u03fc\0\u02fd\0\u042f\0\u0297\0\u0297\0\u02fd\0\u0297\0\u0297"+
|
||||
"\0\u0462\0\u0495\0\u0297\0\u0297\0\u0297\0\u0297\0\u04c8\0\u0297"+
|
||||
"\0\u0297\0\u04fb\0\u052e\0\u0297\0\u0297\0\u0297\0\u0297\0\u0297"+
|
||||
"\0\u0297\0\u0561\0\u0297\0\u0297\0\u0297\0\u0594\0\u05c7\0\u0297"+
|
||||
"\0\u0297\0\u0297\0\u05fa\0\u0297\0\u0297\0\u0297\0\u062d\0\u0660"+
|
||||
"\0\u0297\0\u0693\0\u0297\0\u06c6\0\u06f9\0\u072c\0\u075f\0\u0297"+
|
||||
"\0\u0297\0\u0297\0\u0297\0\u0792\0\u07c5\0\u0297\0\u0297\0\u07f8"+
|
||||
"\0\u082b\0\u0297\0\u0297\0\u085e\0\u0891\0\u0297\0\u0297";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[100];
|
||||
int [] result = new int[103];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -206,47 +206,52 @@ class _RegExLexer implements FlexLexer {
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\3\15\1\16\1\17\1\20\1\21\1\15\1\22\1\15"+
|
||||
"\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+
|
||||
"\21\15\1\33\1\15\1\34\4\15\1\24\5\15\1\35"+
|
||||
"\1\15\1\24\12\15\1\36\1\0\47\15\1\37\2\40"+
|
||||
"\4\37\1\41\12\37\20\42\1\40\1\37\1\42\2\37"+
|
||||
"\1\40\1\43\12\37\11\44\1\45\1\44\1\0\47\44"+
|
||||
"\6\15\1\21\1\15\1\22\1\46\1\23\1\47\1\25"+
|
||||
"\26\15\1\33\5\15\1\50\1\47\7\15\1\47\6\51"+
|
||||
"\1\52\1\51\1\53\1\51\1\23\50\51\5\54\1\55"+
|
||||
"\14\54\20\56\1\54\1\57\1\56\6\54\1\60\7\54"+
|
||||
"\13\10\1\61\46\10\1\61\22\54\20\42\2\54\1\42"+
|
||||
"\7\54\1\62\30\54\20\42\2\54\1\42\14\54\1\63"+
|
||||
"\6\54\1\55\14\54\20\42\2\54\1\42\17\54\2\40"+
|
||||
"\2\54\1\55\14\54\20\42\1\40\1\54\1\42\2\54"+
|
||||
"\1\40\13\54\101\0\1\64\55\0\1\65\51\0\1\66"+
|
||||
"\1\67\1\70\4\71\1\66\1\71\1\66\1\71\1\72"+
|
||||
"\6\71\2\73\2\74\2\75\1\76\1\77\1\76\2\100"+
|
||||
"\1\101\1\102\1\101\1\103\1\104\1\67\1\71\1\101"+
|
||||
"\1\72\4\66\1\72\7\66\1\72\37\0\1\105\24\0"+
|
||||
"\2\40\37\0\1\40\4\0\1\40\14\0\2\42\17\0"+
|
||||
"\21\42\1\0\1\42\1\0\2\42\64\0\1\106\33\0"+
|
||||
"\20\56\2\0\1\56\40\0\20\57\2\0\1\57\22\0"+
|
||||
"\1\107\27\0\1\110\16\0\2\111\1\112\1\113\1\114"+
|
||||
"\1\115\1\116\2\0\2\67\37\0\1\67\22\0\1\117"+
|
||||
"\37\0\1\117\20\0\63\120\1\121\2\122\20\121\2\122"+
|
||||
"\2\121\3\122\3\121\1\122\1\121\1\122\2\121\1\122"+
|
||||
"\20\121\1\123\2\124\20\123\2\124\2\123\3\124\3\123"+
|
||||
"\1\124\1\123\1\124\2\123\1\124\20\123\55\0\1\125"+
|
||||
"\1\0\1\126\60\0\1\127\1\130\4\0\5\131\1\0"+
|
||||
"\55\131\2\0\1\132\37\0\1\132\20\0\64\133\2\134"+
|
||||
"\20\133\2\134\2\133\3\134\3\133\1\134\1\133\1\134"+
|
||||
"\2\133\1\134\20\133\64\135\2\136\20\135\2\136\2\135"+
|
||||
"\3\136\3\135\1\136\1\135\1\136\2\135\1\136\20\135"+
|
||||
"\5\131\1\137\55\131\2\0\1\140\37\0\1\140\20\0"+
|
||||
"\64\141\2\142\20\141\2\142\2\141\3\142\3\141\1\142"+
|
||||
"\1\141\1\142\2\141\1\142\20\141\64\143\2\144\20\143"+
|
||||
"\2\144\2\143\3\144\3\143\1\144\1\143\1\144\2\143"+
|
||||
"\1\144\20\143";
|
||||
"\3\16\1\17\1\20\1\21\1\22\1\16\1\23\1\16"+
|
||||
"\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+
|
||||
"\21\16\1\34\1\16\1\35\4\16\1\25\5\16\1\36"+
|
||||
"\1\16\1\25\12\16\1\37\1\0\47\16\1\40\2\41"+
|
||||
"\4\40\1\42\12\40\20\43\1\41\1\40\1\43\2\40"+
|
||||
"\1\41\1\44\12\40\11\45\1\46\1\45\1\0\47\45"+
|
||||
"\6\16\1\22\1\16\1\23\1\47\1\24\1\50\1\26"+
|
||||
"\26\16\1\34\5\16\1\51\1\50\7\16\1\50\6\16"+
|
||||
"\1\22\1\16\1\52\1\47\1\53\1\50\1\26\26\16"+
|
||||
"\1\34\6\16\1\50\7\16\1\50\6\54\1\55\1\54"+
|
||||
"\1\56\1\54\1\24\50\54\5\57\1\60\14\57\20\61"+
|
||||
"\1\57\1\62\1\61\6\57\1\63\7\57\13\11\1\64"+
|
||||
"\46\11\1\64\22\57\20\43\2\57\1\43\7\57\1\65"+
|
||||
"\30\57\20\43\2\57\1\43\14\57\1\66\6\57\1\60"+
|
||||
"\14\57\20\43\2\57\1\43\17\57\2\41\2\57\1\60"+
|
||||
"\14\57\20\43\1\41\1\57\1\43\2\57\1\41\13\57"+
|
||||
"\101\0\1\67\55\0\1\70\51\0\1\71\1\72\1\73"+
|
||||
"\4\74\1\71\1\74\1\71\1\74\1\75\6\74\2\76"+
|
||||
"\2\77\2\100\1\101\1\102\1\101\2\103\1\104\1\105"+
|
||||
"\1\104\1\106\1\107\1\72\1\74\1\104\1\75\4\71"+
|
||||
"\1\75\7\71\1\75\37\0\1\110\24\0\2\41\37\0"+
|
||||
"\1\41\4\0\1\41\14\0\2\43\17\0\21\43\1\0"+
|
||||
"\1\43\1\0\2\43\64\0\1\111\11\0\1\71\1\72"+
|
||||
"\1\73\4\74\1\71\1\74\1\16\1\74\1\75\6\74"+
|
||||
"\2\76\2\77\2\100\1\101\1\102\1\101\2\103\1\104"+
|
||||
"\1\105\1\104\1\106\1\107\1\72\1\74\1\104\1\75"+
|
||||
"\4\71\1\75\7\71\1\75\22\0\20\61\2\0\1\61"+
|
||||
"\40\0\20\62\2\0\1\62\22\0\1\112\27\0\1\113"+
|
||||
"\16\0\2\114\1\115\1\116\1\117\1\120\1\121\2\0"+
|
||||
"\2\72\37\0\1\72\22\0\1\122\37\0\1\122\20\0"+
|
||||
"\63\123\1\124\2\125\20\124\2\125\2\124\3\125\3\124"+
|
||||
"\1\125\1\124\1\125\2\124\1\125\20\124\1\126\2\127"+
|
||||
"\20\126\2\127\2\126\3\127\3\126\1\127\1\126\1\127"+
|
||||
"\2\126\1\127\20\126\55\0\1\130\1\0\1\131\60\0"+
|
||||
"\1\132\1\133\4\0\5\134\1\0\55\134\2\0\1\135"+
|
||||
"\37\0\1\135\20\0\64\136\2\137\20\136\2\137\2\136"+
|
||||
"\3\137\3\136\1\137\1\136\1\137\2\136\1\137\20\136"+
|
||||
"\64\140\2\141\20\140\2\141\2\140\3\141\3\140\1\141"+
|
||||
"\1\140\1\141\2\140\1\141\20\140\5\134\1\142\55\134"+
|
||||
"\2\0\1\143\37\0\1\143\20\0\64\144\2\145\20\144"+
|
||||
"\2\145\2\144\3\145\3\144\1\145\1\144\1\145\2\144"+
|
||||
"\1\145\20\144\64\146\2\147\20\146\2\147\2\146\3\147"+
|
||||
"\3\146\1\147\1\146\1\147\2\146\1\147\20\146";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[2142];
|
||||
int [] result = new int[2244];
|
||||
int offset = 0;
|
||||
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -287,15 +292,15 @@ class _RegExLexer implements FlexLexer {
|
||||
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
|
||||
|
||||
private static final String ZZ_ATTRIBUTE_PACKED_0 =
|
||||
"\6\0\2\1\4\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"+
|
||||
"\7\0\2\1\4\0\2\11\1\1\2\11\2\1\12\11"+
|
||||
"\1\1\1\11\1\1\1\11\1\1\5\11\3\1\2\11"+
|
||||
"\1\1\2\11\2\1\4\11\1\1\2\11\2\1\6\11"+
|
||||
"\1\1\3\11\2\1\3\11\1\0\3\11\1\1\1\0"+
|
||||
"\1\11\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[100];
|
||||
int [] result = new int[103];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
@@ -362,11 +367,13 @@ class _RegExLexer implements FlexLexer {
|
||||
private boolean xmlSchemaMode;
|
||||
|
||||
private boolean allowDanglingMetacharacters;
|
||||
private boolean allowRBracketInCharacterClass;
|
||||
|
||||
_RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) {
|
||||
_RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters, boolean allowRBracketInCharacterClass) {
|
||||
this((java.io.Reader)null);
|
||||
this.xmlSchemaMode = xmlSchemaMode;
|
||||
this.allowDanglingMetacharacters = allowDanglingMetacharacters;
|
||||
this.allowRBracketInCharacterClass = allowRBracketInCharacterClass;
|
||||
}
|
||||
|
||||
private void yypushstate(int state) {
|
||||
@@ -644,19 +651,25 @@ class _RegExLexer implements FlexLexer {
|
||||
{ return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 70: break;
|
||||
case 38:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 71: break;
|
||||
case 14:
|
||||
{ return RegExpTT.STAR;
|
||||
}
|
||||
case 72: break;
|
||||
case 71: break;
|
||||
case 42:
|
||||
{ return RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 72: break;
|
||||
case 38:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ if (allowRBracketInCharacterClass) {
|
||||
yypushstate(CLASS1);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2PY);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 73: break;
|
||||
case 28:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
|
||||
@@ -666,209 +679,215 @@ class _RegExLexer implements FlexLexer {
|
||||
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 75: break;
|
||||
case 8:
|
||||
{ if (allowRBracketInCharacterClass) {
|
||||
yypushstate(CLASS2);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2PY);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 76: break;
|
||||
case 39:
|
||||
{ return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 76: break;
|
||||
case 77: break;
|
||||
case 24:
|
||||
{ return RegExpTT.COMMA;
|
||||
}
|
||||
case 77: break;
|
||||
case 78: break;
|
||||
case 58:
|
||||
{ yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP;
|
||||
}
|
||||
case 78: break;
|
||||
case 79: break;
|
||||
case 64:
|
||||
{ return RegExpTT.POS_LOOKBEHIND;
|
||||
}
|
||||
case 79: break;
|
||||
case 80: break;
|
||||
case 41:
|
||||
{ return RegExpTT.BAD_OCT_VALUE;
|
||||
}
|
||||
case 80: break;
|
||||
case 81: break;
|
||||
case 10:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
|
||||
}
|
||||
case 81: break;
|
||||
case 82: break;
|
||||
case 30:
|
||||
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 82: break;
|
||||
case 83: break;
|
||||
case 51:
|
||||
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
|
||||
}
|
||||
case 83: break;
|
||||
case 84: break;
|
||||
case 65:
|
||||
{ return RegExpTT.NEG_LOOKBEHIND;
|
||||
}
|
||||
case 84: break;
|
||||
case 85: break;
|
||||
case 68:
|
||||
{ return RegExpTT.UNICODE_CHAR;
|
||||
}
|
||||
case 85: break;
|
||||
case 86: break;
|
||||
case 61:
|
||||
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
|
||||
}
|
||||
case 86: break;
|
||||
case 87: break;
|
||||
case 37:
|
||||
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
|
||||
}
|
||||
case 87: break;
|
||||
case 88: break;
|
||||
case 12:
|
||||
{ return RegExpTT.DOLLAR;
|
||||
}
|
||||
case 88: break;
|
||||
case 89: break;
|
||||
case 52:
|
||||
{ yypopstate(); return RegExpTT.QUOTE_END;
|
||||
}
|
||||
case 89: break;
|
||||
case 90: break;
|
||||
case 56:
|
||||
{ return RegExpTT.POS_LOOKAHEAD;
|
||||
}
|
||||
case 90: break;
|
||||
case 91: break;
|
||||
case 22:
|
||||
{ yypopstate(); return RegExpTT.RBRACE;
|
||||
}
|
||||
case 91: break;
|
||||
case 92: break;
|
||||
case 3:
|
||||
{ return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 92: break;
|
||||
case 93: break;
|
||||
case 57:
|
||||
{ return RegExpTT.NEG_LOOKAHEAD;
|
||||
}
|
||||
case 93: break;
|
||||
case 94: break;
|
||||
case 44:
|
||||
{ return RegExpTT.ESC_CTRL_CHARACTER;
|
||||
}
|
||||
case 94: break;
|
||||
case 95: break;
|
||||
case 23:
|
||||
{ return RegExpTT.NAME;
|
||||
}
|
||||
case 95: break;
|
||||
case 96: break;
|
||||
case 53:
|
||||
{ return RegExpTT.ANDAND;
|
||||
}
|
||||
case 96: break;
|
||||
case 97: break;
|
||||
case 13:
|
||||
{ return RegExpTT.QUEST;
|
||||
}
|
||||
case 97: break;
|
||||
case 98: break;
|
||||
case 46:
|
||||
{ return RegExpTT.CHAR_CLASS;
|
||||
}
|
||||
case 98: break;
|
||||
case 99: break;
|
||||
case 17:
|
||||
{ return RegExpTT.MINUS;
|
||||
}
|
||||
case 99: break;
|
||||
case 100: break;
|
||||
case 67:
|
||||
{ return RegExpTT.COMMENT;
|
||||
}
|
||||
case 100: break;
|
||||
case 101: break;
|
||||
case 40:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 101: break;
|
||||
case 102: break;
|
||||
case 16:
|
||||
{ return RegExpTT.UNION;
|
||||
}
|
||||
case 102: break;
|
||||
case 103: break;
|
||||
case 47:
|
||||
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 103: break;
|
||||
case 104: break;
|
||||
case 60:
|
||||
{ return RegExpTT.OCT_CHAR;
|
||||
}
|
||||
case 104: break;
|
||||
case 105: break;
|
||||
case 4:
|
||||
{ return RegExpTT.DOT;
|
||||
}
|
||||
case 105: break;
|
||||
case 106: break;
|
||||
case 32:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 106: break;
|
||||
case 107: break;
|
||||
case 21:
|
||||
{ return RegExpTT.NUMBER;
|
||||
}
|
||||
case 107: break;
|
||||
case 108: break;
|
||||
case 35:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GT;
|
||||
}
|
||||
case 108: break;
|
||||
case 109: break;
|
||||
case 59:
|
||||
{ yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP;
|
||||
}
|
||||
case 109: break;
|
||||
case 110: break;
|
||||
case 54:
|
||||
{ yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF;
|
||||
}
|
||||
case 110: break;
|
||||
case 111: break;
|
||||
case 48:
|
||||
{ yypushstate(PROP); return RegExpTT.PROPERTY;
|
||||
}
|
||||
case 111: break;
|
||||
case 112: break;
|
||||
case 18:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 112: break;
|
||||
case 113: break;
|
||||
case 33:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
|
||||
}
|
||||
case 113: break;
|
||||
case 114: break;
|
||||
case 34:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.COLON;
|
||||
}
|
||||
case 114: break;
|
||||
case 115: break;
|
||||
case 25:
|
||||
{ assert false : yytext();
|
||||
}
|
||||
case 115: break;
|
||||
case 116: break;
|
||||
case 62:
|
||||
{ yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF;
|
||||
}
|
||||
case 116: break;
|
||||
case 117: break;
|
||||
case 27:
|
||||
{ yypopstate(); return RegExpTT.CLASS_END;
|
||||
}
|
||||
case 117: break;
|
||||
case 118: break;
|
||||
case 11:
|
||||
{ return RegExpTT.CARET;
|
||||
}
|
||||
case 118: break;
|
||||
case 119: break;
|
||||
case 1:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_ON;
|
||||
}
|
||||
case 119: break;
|
||||
case 120: break;
|
||||
case 29:
|
||||
{ yypopstate(); yypushback(1);
|
||||
}
|
||||
case 120: break;
|
||||
case 121: break;
|
||||
case 45:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 121: break;
|
||||
case 122: break;
|
||||
case 63:
|
||||
{ yybegin(NAMED_GROUP); return RegExpTT.PYTHON_NAMED_GROUP;
|
||||
}
|
||||
case 122: break;
|
||||
case 123: break;
|
||||
case 19:
|
||||
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 123: break;
|
||||
case 124: break;
|
||||
case 66:
|
||||
{ return RegExpTT.HEX_CHAR;
|
||||
}
|
||||
case 124: break;
|
||||
case 125: break;
|
||||
case 5:
|
||||
{ return RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
case 125: break;
|
||||
case 8:
|
||||
{ yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 126: break;
|
||||
case 55:
|
||||
{ return RegExpTT.NON_CAPT_GROUP;
|
||||
@@ -882,26 +901,6 @@ class _RegExLexer implements FlexLexer {
|
||||
{ yybegin(YYINITIAL); return RegExpTT.QUOTE;
|
||||
}
|
||||
case 129: break;
|
||||
case 50:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 130: break;
|
||||
case 2:
|
||||
{ yypopstate(); return RegExpTT.COMMENT;
|
||||
}
|
||||
case 131: break;
|
||||
case 49:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 132: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 133: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 134: break;
|
||||
case 20:
|
||||
{ if (allowDanglingMetacharacters) {
|
||||
yypopstate(); yypushback(1);
|
||||
@@ -909,6 +908,26 @@ class _RegExLexer implements FlexLexer {
|
||||
return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
}
|
||||
case 130: break;
|
||||
case 50:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 131: break;
|
||||
case 2:
|
||||
{ yypopstate(); return RegExpTT.COMMENT;
|
||||
}
|
||||
case 132: break;
|
||||
case 49:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 133: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 134: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 135: break;
|
||||
case 31:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
|
||||
|
||||
@@ -27,11 +27,13 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
private boolean xmlSchemaMode;
|
||||
|
||||
private boolean allowDanglingMetacharacters;
|
||||
private boolean allowRBracketInCharacterClass;
|
||||
|
||||
_RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) {
|
||||
_RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters, boolean allowRBracketInCharacterClass) {
|
||||
this((java.io.Reader)null);
|
||||
this.xmlSchemaMode = xmlSchemaMode;
|
||||
this.allowDanglingMetacharacters = allowDanglingMetacharacters;
|
||||
this.allowRBracketInCharacterClass = allowRBracketInCharacterClass;
|
||||
}
|
||||
|
||||
private void yypushstate(int state) {
|
||||
@@ -59,6 +61,7 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
%xstate EMBRACED
|
||||
%xstate CLASS1
|
||||
%state CLASS2
|
||||
%state CLASS2PY
|
||||
%state PROP
|
||||
%xstate OPTIONS
|
||||
%xstate COMMENT
|
||||
@@ -146,7 +149,14 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
|
||||
{ESCAPE} [:letter:] { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
{ESCAPE} [\n\b\t\r\f ] { return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE; }
|
||||
|
||||
<CLASS2PY> {
|
||||
{ESCAPE} {RBRACKET} { return RegExpTT.CHARACTER; }
|
||||
}
|
||||
|
||||
{ESCAPE} {ANY} { return RegExpTT.REDUNDANT_ESCAPE; }
|
||||
|
||||
|
||||
{ESCAPE} { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; }
|
||||
|
||||
<PROP> {
|
||||
@@ -175,8 +185,25 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
"-" { return RegExpTT.MINUS; }
|
||||
"^" { return RegExpTT.CARET; }
|
||||
|
||||
{LBRACKET} / {RBRACKET} { yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; }
|
||||
{LBRACKET} { yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN; }
|
||||
<CLASS2PY> {
|
||||
{LBRACKET} { return RegExpTT.CHARACTER; }
|
||||
}
|
||||
|
||||
{LBRACKET} / {RBRACKET} { if (allowRBracketInCharacterClass) {
|
||||
yypushstate(CLASS1);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2PY);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN; }
|
||||
|
||||
{LBRACKET} { if (allowRBracketInCharacterClass) {
|
||||
yypushstate(CLASS2);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2PY);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN; }
|
||||
|
||||
/* []abc] is legal. The first ] is treated as literal character */
|
||||
<CLASS1> {
|
||||
@@ -192,6 +219,15 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
{ANY} { return RegExpTT.CHARACTER; }
|
||||
}
|
||||
|
||||
/* see rules for matching LBRACKET and escaped RBRACKET in CLASS2PY above */
|
||||
<CLASS2PY> {
|
||||
{RBRACKET} { yypopstate(); return RegExpTT.CLASS_END; }
|
||||
|
||||
[\n\b\t\r\f] { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER; }
|
||||
{ANY} { return RegExpTT.CHARACTER; }
|
||||
}
|
||||
|
||||
|
||||
<YYINITIAL> {
|
||||
{LPAREN} { return RegExpTT.GROUP_BEGIN; }
|
||||
{RPAREN} { return RegExpTT.GROUP_END; }
|
||||
|
||||
Reference in New Issue
Block a user