📄 cplusplustokenmaker.flex
字号:
<YYINITIAL> "goto" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "if" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "inline" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "mutable" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "namespace" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "new" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "operator" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "private" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "protected" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "public" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "register" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "reinterpret_cast" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "return" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "sizeof" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "static" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "static_cast" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "struct" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "switch" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "template" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "this" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "throw" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "try" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "typedef" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "typeid" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "typename" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "union" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "using" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "virtual" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "volatile" { addToken(Token.RESERVED_WORD); }
<YYINITIAL> "while" { addToken(Token.RESERVED_WORD); }
/* Boolean literals. */
<YYINITIAL> "true" { addToken(Token.LITERAL_BOOLEAN); }
<YYINITIAL> "false" { addToken(Token.LITERAL_BOOLEAN); }
/* Data types. */
<YYINITIAL> "bool" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "char" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "double" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "float" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "int" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "long" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "short" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "signed" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "unsigned" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "void" { addToken(Token.DATA_TYPE); }
<YYINITIAL> "wchar_t" { addToken(Token.DATA_TYPE); }
/* Standard functions */
<YYINITIAL> "abort" { addToken(Token.FUNCTION); }
<YYINITIAL> "abs" { addToken(Token.FUNCTION); }
<YYINITIAL> "acos" { addToken(Token.FUNCTION); }
<YYINITIAL> "asctime" { addToken(Token.FUNCTION); }
<YYINITIAL> "asin" { addToken(Token.FUNCTION); }
<YYINITIAL> "assert" { addToken(Token.FUNCTION); }
<YYINITIAL> "atan2" { addToken(Token.FUNCTION); }
<YYINITIAL> "atan" { addToken(Token.FUNCTION); }
<YYINITIAL> "atexit" { addToken(Token.FUNCTION); }
<YYINITIAL> "atof" { addToken(Token.FUNCTION); }
<YYINITIAL> "atoi" { addToken(Token.FUNCTION); }
<YYINITIAL> "atol" { addToken(Token.FUNCTION); }
<YYINITIAL> "bsearch" { addToken(Token.FUNCTION); }
<YYINITIAL> "calloc" { addToken(Token.FUNCTION); }
<YYINITIAL> "ceil" { addToken(Token.FUNCTION); }
<YYINITIAL> "clearerr" { addToken(Token.FUNCTION); }
<YYINITIAL> "clock" { addToken(Token.FUNCTION); }
<YYINITIAL> "cosh" { addToken(Token.FUNCTION); }
<YYINITIAL> "cos" { addToken(Token.FUNCTION); }
<YYINITIAL> "ctime" { addToken(Token.FUNCTION); }
<YYINITIAL> "difftime" { addToken(Token.FUNCTION); }
<YYINITIAL> "div" { addToken(Token.FUNCTION); }
<YYINITIAL> "errno" { addToken(Token.FUNCTION); }
<YYINITIAL> "exit" { addToken(Token.FUNCTION); }
<YYINITIAL> "exp" { addToken(Token.FUNCTION); }
<YYINITIAL> "fabs" { addToken(Token.FUNCTION); }
<YYINITIAL> "fclose" { addToken(Token.FUNCTION); }
<YYINITIAL> "feof" { addToken(Token.FUNCTION); }
<YYINITIAL> "ferror" { addToken(Token.FUNCTION); }
<YYINITIAL> "fflush" { addToken(Token.FUNCTION); }
<YYINITIAL> "fgetc" { addToken(Token.FUNCTION); }
<YYINITIAL> "fgetpos" { addToken(Token.FUNCTION); }
<YYINITIAL> "fgets" { addToken(Token.FUNCTION); }
<YYINITIAL> "floor" { addToken(Token.FUNCTION); }
<YYINITIAL> "fmod" { addToken(Token.FUNCTION); }
<YYINITIAL> "fopen" { addToken(Token.FUNCTION); }
<YYINITIAL> "fprintf" { addToken(Token.FUNCTION); }
<YYINITIAL> "fputc" { addToken(Token.FUNCTION); }
<YYINITIAL> "fputs" { addToken(Token.FUNCTION); }
<YYINITIAL> "fread" { addToken(Token.FUNCTION); }
<YYINITIAL> "free" { addToken(Token.FUNCTION); }
<YYINITIAL> "freopen" { addToken(Token.FUNCTION); }
<YYINITIAL> "frexp" { addToken(Token.FUNCTION); }
<YYINITIAL> "fscanf" { addToken(Token.FUNCTION); }
<YYINITIAL> "fseek" { addToken(Token.FUNCTION); }
<YYINITIAL> "fsetpos" { addToken(Token.FUNCTION); }
<YYINITIAL> "ftell" { addToken(Token.FUNCTION); }
<YYINITIAL> "fwrite" { addToken(Token.FUNCTION); }
<YYINITIAL> "getchar" { addToken(Token.FUNCTION); }
<YYINITIAL> "getc" { addToken(Token.FUNCTION); }
<YYINITIAL> "getenv" { addToken(Token.FUNCTION); }
<YYINITIAL> "gets" { addToken(Token.FUNCTION); }
<YYINITIAL> "gmtime" { addToken(Token.FUNCTION); }
<YYINITIAL> "isalnum" { addToken(Token.FUNCTION); }
<YYINITIAL> "isalpha" { addToken(Token.FUNCTION); }
<YYINITIAL> "iscntrl" { addToken(Token.FUNCTION); }
<YYINITIAL> "isdigit" { addToken(Token.FUNCTION); }
<YYINITIAL> "isgraph" { addToken(Token.FUNCTION); }
<YYINITIAL> "islower" { addToken(Token.FUNCTION); }
<YYINITIAL> "isprint" { addToken(Token.FUNCTION); }
<YYINITIAL> "ispunct" { addToken(Token.FUNCTION); }
<YYINITIAL> "isspace" { addToken(Token.FUNCTION); }
<YYINITIAL> "isupper" { addToken(Token.FUNCTION); }
<YYINITIAL> "isxdigit" { addToken(Token.FUNCTION); }
<YYINITIAL> "labs" { addToken(Token.FUNCTION); }
<YYINITIAL> "ldexp" { addToken(Token.FUNCTION); }
<YYINITIAL> "ldiv" { addToken(Token.FUNCTION); }
<YYINITIAL> "localeconv" { addToken(Token.FUNCTION); }
<YYINITIAL> "localtime" { addToken(Token.FUNCTION); }
<YYINITIAL> "log10" { addToken(Token.FUNCTION); }
<YYINITIAL> "log" { addToken(Token.FUNCTION); }
<YYINITIAL> "longjmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "malloc" { addToken(Token.FUNCTION); }
<YYINITIAL> "mblen" { addToken(Token.FUNCTION); }
<YYINITIAL> "mbstowcs" { addToken(Token.FUNCTION); }
<YYINITIAL> "mbtowc" { addToken(Token.FUNCTION); }
<YYINITIAL> "memchr" { addToken(Token.FUNCTION); }
<YYINITIAL> "memcmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "memcpy" { addToken(Token.FUNCTION); }
<YYINITIAL> "memmove" { addToken(Token.FUNCTION); }
<YYINITIAL> "memset" { addToken(Token.FUNCTION); }
<YYINITIAL> "mktime" { addToken(Token.FUNCTION); }
<YYINITIAL> "modf" { addToken(Token.FUNCTION); }
<YYINITIAL> "offsetof" { addToken(Token.FUNCTION); }
<YYINITIAL> "perror" { addToken(Token.FUNCTION); }
<YYINITIAL> "pow" { addToken(Token.FUNCTION); }
<YYINITIAL> "printf" { addToken(Token.FUNCTION); }
<YYINITIAL> "putchar" { addToken(Token.FUNCTION); }
<YYINITIAL> "putc" { addToken(Token.FUNCTION); }
<YYINITIAL> "puts" { addToken(Token.FUNCTION); }
<YYINITIAL> "qsort" { addToken(Token.FUNCTION); }
<YYINITIAL> "raise" { addToken(Token.FUNCTION); }
<YYINITIAL> "rand" { addToken(Token.FUNCTION); }
<YYINITIAL> "realloc" { addToken(Token.FUNCTION); }
<YYINITIAL> "remove" { addToken(Token.FUNCTION); }
<YYINITIAL> "rename" { addToken(Token.FUNCTION); }
<YYINITIAL> "rewind" { addToken(Token.FUNCTION); }
<YYINITIAL> "scanf" { addToken(Token.FUNCTION); }
<YYINITIAL> "setbuf" { addToken(Token.FUNCTION); }
<YYINITIAL> "setjmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "setlocale" { addToken(Token.FUNCTION); }
<YYINITIAL> "setvbuf" { addToken(Token.FUNCTION); }
<YYINITIAL> "setvbuf" { addToken(Token.FUNCTION); }
<YYINITIAL> "signal" { addToken(Token.FUNCTION); }
<YYINITIAL> "sinh" { addToken(Token.FUNCTION); }
<YYINITIAL> "sin" { addToken(Token.FUNCTION); }
<YYINITIAL> "sprintf" { addToken(Token.FUNCTION); }
<YYINITIAL> "sqrt" { addToken(Token.FUNCTION); }
<YYINITIAL> "srand" { addToken(Token.FUNCTION); }
<YYINITIAL> "sscanf" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcat" { addToken(Token.FUNCTION); }
<YYINITIAL> "strchr" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcoll" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcpy" { addToken(Token.FUNCTION); }
<YYINITIAL> "strcspn" { addToken(Token.FUNCTION); }
<YYINITIAL> "strerror" { addToken(Token.FUNCTION); }
<YYINITIAL> "strftime" { addToken(Token.FUNCTION); }
<YYINITIAL> "strlen" { addToken(Token.FUNCTION); }
<YYINITIAL> "strncat" { addToken(Token.FUNCTION); }
<YYINITIAL> "strncmp" { addToken(Token.FUNCTION); }
<YYINITIAL> "strncpy" { addToken(Token.FUNCTION); }
<YYINITIAL> "strpbrk" { addToken(Token.FUNCTION); }
<YYINITIAL> "strrchr" { addToken(Token.FUNCTION); }
<YYINITIAL> "strspn" { addToken(Token.FUNCTION); }
<YYINITIAL> "strstr" { addToken(Token.FUNCTION); }
<YYINITIAL> "strtod" { addToken(Token.FUNCTION); }
<YYINITIAL> "strtok" { addToken(Token.FUNCTION); }
<YYINITIAL> "strtol" { addToken(Token.FUNCTION); }
<YYINITIAL> "strtoul" { addToken(Token.FUNCTION); }
<YYINITIAL> "strxfrm" { addToken(Token.FUNCTION); }
<YYINITIAL> "system" { addToken(Token.FUNCTION); }
<YYINITIAL> "tanh" { addToken(Token.FUNCTION); }
<YYINITIAL> "tan" { addToken(Token.FUNCTION); }
<YYINITIAL> "time" { addToken(Token.FUNCTION); }
<YYINITIAL> "tmpfile" { addToken(Token.FUNCTION); }
<YYINITIAL> "tmpnam" { addToken(Token.FUNCTION); }
<YYINITIAL> "tolower" { addToken(Token.FUNCTION); }
<YYINITIAL> "toupper" { addToken(Token.FUNCTION); }
<YYINITIAL> "ungetc" { addToken(Token.FUNCTION); }
<YYINITIAL> "va_arg" { addToken(Token.FUNCTION); }
<YYINITIAL> "va_end" { addToken(Token.FUNCTION); }
<YYINITIAL> "va_start" { addToken(Token.FUNCTION); }
<YYINITIAL> "vfprintf" { addToken(Token.FUNCTION); }
<YYINITIAL> "vprintf" { addToken(Token.FUNCTION); }
<YYINITIAL> "vsprintf" { addToken(Token.FUNCTION); }
<YYINITIAL> "wcstombs" { addToken(Token.FUNCTION); }
<YYINITIAL> "wctomb" { addToken(Token.FUNCTION); }
/* Standard-defined macros. */
<YYINITIAL> "__DATE__" { addToken(Token.PREPROCESSOR); }
<YYINITIAL> "__TIME__" { addToken(Token.PREPROCESSOR); }
<YYINITIAL> "__FILE__" { addToken(Token.PREPROCESSOR); }
<YYINITIAL> "__LINE__" { addToken(Token.PREPROCESSOR); }
<YYINITIAL> "__STDC__" { addToken(Token.PREPROCESSOR); }
<YYINITIAL> {
{LineTerminator} { addNullToken(); return firstToken; }
{Identifier} { addToken(Token.IDENTIFIER); }
{WhiteSpace}+ { addToken(Token.WHITESPACE); }
/* Preprocessor directives */
"#"{WhiteSpace}*{PreprocessorWord} { addToken(Token.PREPROCESSOR); }
/* String/Character Literals. */
{CharLiteral} { addToken(Token.LITERAL_CHAR); }
{UnclosedCharLiteral} { addToken(Token.ERROR_CHAR); /*addNullToken(); return firstToken;*/ }
{ErrorUnclosedCharLiteral} { addToken(Token.ERROR_CHAR); addNullToken(); return firstToken; }
{ErrorCharLiteral} { addToken(Token.ERROR_CHAR); }
{StringLiteral} { addToken(Token.LITERAL_STRING_DOUBLE_QUOTE); }
{UnclosedStringLiteral} { addToken(Token.ERROR_STRING_DOUBLE); addNullToken(); return firstToken; }
{ErrorUnclosedStringLiteral} { addToken(Token.ERROR_STRING_DOUBLE); addNullToken(); return firstToken; }
{ErrorStringLiteral} { addToken(Token.ERROR_STRING_DOUBLE); }
/* Comment Literals. */
{MLCBegin} { start = zzMarkedPos-2; yybegin(MLC); }
{LineCommentBegin}.* { addToken(Token.COMMENT_EOL); addNullToken(); return firstToken; }
/* Separators. */
"(" { addToken(Token.SEPARATOR); }
")" { addToken(Token.SEPARATOR); }
"[" { addToken(Token.SEPARATOR); }
"]" { addToken(Token.SEPARATOR); }
"{" { addToken(Token.SEPARATOR); }
"}" { addToken(Token.SEPARATOR); }
/* Operators. */
{Trigraph} { addToken(Token.OPERATOR); }
"=" { addToken(Token.OPERATOR); }
"+" { addToken(Token.OPERATOR); }
"-" { addToken(Token.OPERATOR); }
"*" { addToken(Token.OPERATOR); }
"/" { addToken(Token.OPERATOR); }
"%" { addToken(Token.OPERATOR); }
"~" { addToken(Token.OPERATOR); }
"<" { addToken(Token.OPERATOR); }
">" { addToken(Token.OPERATOR); }
"<<" { addToken(Token.OPERATOR); }
">>" { addToken(Token.OPERATOR); }
"==" { addToken(Token.OPERATOR); }
"+=" { addToken(Token.OPERATOR); }
"-=" { addToken(Token.OPERATOR); }
"*=" { addToken(Token.OPERATOR); }
"/=" { addToken(Token.OPERATOR); }
"%=" { addToken(Token.OPERATOR); }
">>=" { addToken(Token.OPERATOR); }
"<<=" { addToken(Token.OPERATOR); }
"^" { addToken(Token.OPERATOR); }
"&" { addToken(Token.OPERATOR); }
"&&" { addToken(Token.OPERATOR); }
"|" { addToken(Token.OPERATOR); }
"||" { addToken(Token.OPERATOR); }
"?" { addToken(Token.OPERATOR); }
":" { addToken(Token.OPERATOR); }
"," { addToken(Token.OPERATOR); }
"!" { addToken(Token.OPERATOR); }
"++" { addToken(Token.OPERATOR); }
"--" { addToken(Token.OPERATOR); }
"." { addToken(Token.OPERATOR); }
"," { addToken(Token.OPERATOR); }
/* Numbers */
{IntegerLiteral} { addToken(Token.LITERAL_NUMBER_DECIMAL_INT); }
{HexLiteral} { addToken(Token.LITERAL_NUMBER_HEXADECIMAL); }
{FloatLiteral} { addToken(Token.LITERAL_NUMBER_FLOAT); }
{ErrorNumberFormat} { addToken(Token.ERROR_NUMBER_FORMAT); }
/* Some lines will end in '\' to wrap an expression. */
"\\" { addToken(Token.IDENTIFIER); }
{ErrorIdentifier} { addToken(Token.ERROR_IDENTIFIER); }
/* Other punctuation, we'll highlight it as "identifiers." */
";" { addToken(Token.IDENTIFIER); }
/* Ended with a line not in a string or comment. */
<<EOF>> { addNullToken(); return firstToken; }
/* Catch any other (unhandled) characters and flag them as bad. */
. { addToken(Token.ERROR_IDENTIFIER); }
}
<MLC> {
[^\n\*]+ {}
\n { addToken(start,zzStartRead-1, Token.COMMENT_MULTILINE); return firstToken; }
{MLCEnd} { yybegin(YYINITIAL); addToken(start,zzStartRead+1, Token.COMMENT_MULTILINE); }
\* {}
<<EOF>> { addToken(start,zzStartRead-1, Token.COMMENT_MULTILINE); return firstToken; }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -