📄 scanner.jflex
字号:
/* * Scanner.jflex * * Lexer for the Table format * * See LICENSE file for license conditions. */package residue.tables;import java_cup.runtime.*;%%%class TableScanner%cup%unicode%line%column// Used for storing the intermediate values of// String results.%{ private StringBuffer sb = new StringBuffer();%}%state STRING%%/* * Only returns positive integers, quoted strings, * semicolons, and the expected tags. White space is * accepted, but not returned. All other text is * treated as an error, causing an instance of * RuntimeException to be thrown with a detail message * describing the location of the bad text, and giving * the first such character. */<YYINITIAL>{ "-"?[0-9]+ { int val; try { val = Integer.parseInt(yytext()); } catch (Exception e) { if (!yytext().startsWith("-")) val = Integer.MIN_VALUE; else val = Integer.MAX_VALUE; } return new Symbol(sym.NUMBER, new Integer(val)); } "[probed blocks]" { return new Symbol(sym.STARTPROBED); } "[referenced blocks]" { return new Symbol(sym.STARTREFERENCED); } "[source roots]" { return new Symbol(sym.STARTROOTS); } ; { return new Symbol(sym.SEMICOLON); } \" { sb.setLength(0); yybegin(STRING); } [ \t\r\n]+ { /* do nothing */ }}/* * Strings are contained between pairs of double quotes. ALL * characters (including "control" characters, newlines, etc.) * within the quotes are returned as part of the string, with * the following exceptions: * \uXXXX where X is a hexadecimal digit is converted to the * unicode character represented by that hex sequence. * \" is translated to a double quote that does not * terminate the string * \\ is translated to a single backslash * Any other sequence of characters beginning with a backslash * is treated as an error. */<STRING>{ \\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f] { char c = (char)Integer.parseInt(yytext().substring(2), 16); sb.append(c); } \\\" { sb.append('"'); } \\\\ { sb.append('\\'); } \" { yybegin(YYINITIAL); return new Symbol(sym.STRING, sb.toString()); } [^\"\\]+ { sb.append(yytext()); }}// Fallback case. { throw new RuntimeException("Illegal character (" + yytext() + ") in input, at line " + (yyline + 1) + ", character " + (yycolumn + 1)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -