pythontokenmaker.java
来自「具有不同语法高亮的编辑器实例」· Java 代码 · 共 1,121 行 · 第 1/3 页
JAVA
1,121 行
"\2\5\3\0\7\5\1\316\12\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\5\5\1\317"+
"\14\5\15\0\7\5\4\0\10\5\1\0\2\5\1\0"+
"\2\5\3\0\15\5\1\320\4\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\1\321\21\5"+
"\14\0\3\66\1\231\4\66\3\0\1\66\2\67\1\231"+
"\2\66\3\231\1\0\2\231\1\0\2\66\1\0\1\66"+
"\1\0\1\231\1\66\1\231\2\66\1\231\1\66\1\231"+
"\12\66\12\0\1\66\2\0\7\5\4\0\10\5\1\0"+
"\2\5\1\0\2\5\3\0\1\5\1\215\20\5\15\0"+
"\7\5\4\0\10\5\1\0\2\5\1\0\2\5\3\0"+
"\14\5\1\162\5\5\15\0\7\5\4\0\10\5\1\0"+
"\2\5\1\0\2\5\3\0\1\322\21\5\15\0\7\5"+
"\4\0\10\5\1\0\1\164\1\5\1\0\2\5\3\0"+
"\4\5\1\166\15\5\15\0\7\5\4\0\10\5\1\0"+
"\2\5\1\0\2\5\3\0\1\323\21\5\15\0\7\5"+
"\4\0\10\5\1\0\1\162\1\5\1\0\2\5\3\0"+
"\22\5\15\0\7\5\4\0\6\5\1\162\1\5\1\0"+
"\2\5\1\0\2\5\3\0\22\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\7\5\1\324"+
"\12\5\15\0\7\5\4\0\10\5\1\0\1\325\1\5"+
"\1\0\2\5\3\0\22\5\15\0\7\5\4\0\10\5"+
"\1\0\2\5\1\0\2\5\3\0\14\5\1\326\5\5"+
"\15\0\7\5\4\0\1\164\7\5\1\0\2\5\1\0"+
"\2\5\3\0\22\5\15\0\7\5\4\0\10\5\1\0"+
"\1\327\1\5\1\0\2\5\3\0\22\5\15\0\7\5"+
"\4\0\1\330\7\5\1\0\2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
"\1\160\2\5\4\0\10\5\1\0\2\5\1\0\2\5"+
"\3\0\22\5\15\0\4\5\1\345\2\5\4\0\10\5"+
"\1\0\2\5\1\0\2\5\3\0\22\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\1\5"+
"\1\346\20\5\15\0\7\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\10\5\1\327\11\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\12\5"+
"\1\347\7\5\15\0\7\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\1\5\1\131\20\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\3\5"+
"\1\162\16\5\15\0\7\5\4\0\1\125\7\5\1\0"+
"\2\5\1\0\2\5\3\0\22\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\5\5\1\350"+
"\14\5\15\0\7\5\4\0\1\237\7\5\1\0\2\5"+
"\1\0\2\5\3\0\22\5\15\0\7\5\4\0\10\5"+
"\1\0\2\5\1\0\2\5\3\0\1\331\16\5\1\164"+
"\2\5\15\0\7\5\4\0\10\5\1\0\2\5\1\0"+
"\2\5\3\0\2\5\1\320\17\5\17\0\1\311\12\0"+
"\1\311\2\0\1\311\6\0\2\206\42\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\1\315\21\5"+
"\15\0\3\5\1\351\3\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\22\5\15\0\7\5\4\0\10\5"+
"\1\0\2\5\1\0\2\5\3\0\11\5\1\352\10\5"+
"\15\0\7\5\4\0\10\5\1\0\2\5\1\0\2\5"+
"\3\0\10\5\1\353\6\5\1\214\2\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\2\5"+
"\1\354\17\5\15\0\7\5\4\0\1\127\7\5\1\0"+
"\2\5\1\0\2\5\3\0\22\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1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\u0102\3\5\4\0\10\5\1\0\2\5\1\0"+
"\2\5\3\0\22\5\15\0\7\5\4\0\1\u0103\7\5"+
"\1\0\2\5\1\0\2\5\3\0\22\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\12\5"+
"\1\273\7\5\15\0\7\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\1\u0104\21\5\15\0\7\5\4\0"+
"\10\5\1\0\1\u0105\1\5\1\0\2\5\3\0\22\5"+
"\15\0\4\5\1\237\2\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\22\5\15\0\7\5\4\0\1\u0106"+
"\7\5\1\0\2\5\1\0\2\5\3\0\22\5\15\0"+
"\7\5\4\0\10\5\1\0\2\5\1\0\2\5\3\0"+
"\1\u0107\21\5\15\0\7\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\4\5\1\330\15\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\4\5"+
"\1\260\15\5\15\0\7\5\4\0\10\5\1\0\2\5"+
"\1\0\2\5\3\0\4\5\1\u0108\15\5\15\0\7\5"+
"\4\0\10\5\1\0\2\5\1\0\2\5\3\0\1\u0109"+
"\21\5\15\0\7\5\4\0\10\5\1\0\2\5\1\0"+
"\2\5\3\0\1\5\1\252\20\5\15\0\7\5\4\0"+
"\10\5\1\0\2\5\1\0\2\5\3\0\17\5\1\333"+
"\2\5\15\0\7\5\4\0\10\5\1\0\2\5\1\0"+
"\2\5\3\0\3\5\1\127\16\5\14\0";
private static int [] zzUnpackTrans() {
int [] result = new int[14514];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
}
private static int zzUnpackTrans(String packed, int offset, int [] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
while (i < l) {
int count = packed.charAt(i++);
int value = packed.charAt(i++);
value--;
do result[j++] = value; while (--count > 0);
}
return j;
}
/* error codes */
private static final int ZZ_UNKNOWN_ERROR = 0;
private static final int ZZ_NO_MATCH = 1;
private static final int ZZ_PUSHBACK_2BIG = 2;
/* error messages for the codes above */
private static final String ZZ_ERROR_MSG[] = {
"Unkown internal scanner error",
"Error: could not match input",
"Error: pushback value was too large"
};
/**
* ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
*/
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\3\0\1\11\10\1\1\11\32\1\1\11\3\1\1\11"+
"\4\1\1\11\17\1\1\0\2\1\1\0\76\1\3\0"+
"\1\11\1\1\1\0\12\1\3\11\61\1\2\11\101\1";
private static int [] zzUnpackAttribute() {
int [] result = new int[265];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
}
private static int zzUnpackAttribute(String packed, int offset, int [] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
while (i < l) {
int count = packed.charAt(i++);
int value = packed.charAt(i++);
do result[j++] = value; while (--count > 0);
}
return j;
}
/** the input device */
private java.io.Reader zzReader;
/** the current state of the DFA */
private int zzState;
/** the current lexical state */
private int zzLexicalState = YYINITIAL;
/** this buffer contains the current text to be matched and is
the source of the yytext() string */
private char zzBuffer[];
/** the textposition at the last accepting state */
private int zzMarkedPos;
/** the textposition at the last state to be included in yytext */
private int zzPushbackPos;
/** the current text position in the buffer */
private int zzCurrentPos;
/** startRead marks the beginning of the yytext() string in the buffer */
private int zzStartRead;
/** endRead marks the last character in the buffer, that has been read
from input */
private int zzEndRead;
/** number of newlines encountered up to the start of the matched text */
private int yyline;
/** the number of characters up to the start of the matched text */
private int yychar;
/**
* the number of characters from the last newline up to the start of the
* matched text
*/
private int yycolumn;
/**
* zzAtBOL == true <=> the scanner is currently at the beginning of a line
*/
private boolean zzAtBOL = true;
/** zzAtEOF == true <=> the scanner is at the EOF */
private boolean zzAtEOF;
/* user code: */
/*****************************************************************************/
/**
* Constructor. This must be here because JFlex does not generate a
* no-parameter constructor.
*/
public PythonTokenMaker() {
super();
}
/*****************************************************************************/
/**
* Adds the token specified to the current linked list of tokens.
*
* @param tokenType The token's type.
*/
private void addToken(int tokenType) {
addToken(zzStartRead, zzMarkedPos-1, tokenType);
}
/*****************************************************************************/
/**
* Adds the token specified to the current linked list of tokens.
*
* @param tokenType The token's type.
*/
private void addToken(int start, int end, int tokenType) {
int so = start + offsetShift;
addToken(zzBuffer, start,end, tokenType, so);
}
/*****************************************************************************/
/**
* Adds the token specified to the current linked list of tokens.
*
* @param array The character array.
* @param start The starting offset in the array.
* @param end The ending offset in the array.
* @param tokenType The token's type.
* @param startOffset The offset in the document at which this token
* occurs.
*/
public void addToken(char[] array, int start, int end, int tokenType, int startOffset) {
super.addToken(array, start,end, tokenType, startOffset);
zzStartRead = zzMarkedPos;
}
/*****************************************************************************/
/**
* Returns the first token in the linked list of tokens generated
* from <code>text</code>. This method must be implemented by
* subclasses so they can correctly implement syntax highlighting.
*
* @param text The text from which to get tokens.
* @param initialTokenType The token type we should start with.
* @param startOffset The offset into the document at which
* <code>text</code> starts.
* @return The first <code>Token</code> in a linked list representing
* the syntax highlighted text.
*/
public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
resetTokenList();
this.offsetShift = -text.offset + startOffset;
// Start off in the proper state.
int state = Token.NULL;
switch (initialTokenType) {
case Token.LITERAL_STRING_DOUBLE_QUOTE:
state = LONG_STRING_2;
break;
case Token.LITERAL_CHAR:
state = LONG_STRING_1;
break;
default:
state = Token.NULL;
}
s = text;
try {
yyreset(zzReader);
yybegin(state);
return yylex();
} catch (IOException ioe) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?