HTTPLexer.java
上传用户:huihesys
上传日期:2007-01-04
资源大小:3877k
文件大小:22k
- /* The following code was generated by JFlex 1.2 on 18.05.00 09:47 */
- package net.wastl.webmail.standalone;
- import java_cup.runtime.*; /* this is convenience, but not necessary */
- import java.io.Reader;
- /*
- * http.lex
- *
- * Created: April 1999
- *
- * Copyright (C) 1999-2000 Sebastian Schaffert
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- /**
- * This class is a scanner generated by
- * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2
- * on 18.05.00 09:47 from the specification file
- * <tt>http.lex</tt>
- */
- class HTTPLexer extends sym {
- /** this character denotes the end of file */
- final public static int YYEOF = -1;
- /** lexical states */
- final public static int HEADERDATA = 2;
- final public static int CONTENT = 4;
- final public static int YYINITIAL = 0;
- final public static int HEADER = 1;
- final public static int END = 3;
- /**
- * Translates characters to character classes
- */
- final private static char [] yycmap = {
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 14, 12, 24, 24, 11, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 26, 25, 25, 25, 25, 25,
- 13, 28, 26, 25, 28, 28, 28, 28, 27, 27, 28, 28, 27, 32, 22, 21,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 31, 26, 29, 26, 27,
- 27, 2, 3, 4, 5, 6, 7, 9, 18, 8, 28, 28, 34, 33, 20, 16,
- 15, 28, 35, 17, 10, 19, 28, 30, 37, 36, 28, 26, 26, 26, 25, 28,
- 25, 2, 3, 4, 5, 6, 7, 9, 18, 8, 28, 28, 34, 33, 20, 16,
- 15, 28, 35, 17, 10, 19, 28, 38, 37, 36, 28, 26, 28, 26, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- /**
- * Translates a state to a row index in the transition table
- */
- final private static int yy_rowMap [] = {
- 0, 39, 78, 117, 156, 195, 234, 273, 312, 351,
- 390, 429, 468, 507, 312, 546, 585, 312, 624, 663,
- 702, 741, 780, 819, 858, 312, 312, 195, 897, 936,
- 975, 1014, 1053, 1092, 546, 312, 1131, 819, 1170, 1209,
- 195, 1248, 1287, 1326, 1365, 1404, 507, 1443, 1482, 1521,
- 1560, 1599, 1638, 1677, 1716, 1755, 1794, 1833, 1872, 1911,
- 1950, 1872, 1989, 2028, 2067, 2106, 2145, 2184, 2223, 2262,
- 2301, 2340, 2379, 2418, 2457, 2496, 2535, 2574, 2613, 2652,
- 2691, 2730, 2769, 2808, 2847, 2886, 2925, 2964, 3003, 3042,
- 3081, 3120, 3159, 3198, 3237, 3276, 3315, 3354, 3393, 3432,
- 3471, 3510, 3549, 3588, 3627, 3666, 3705, 3744, 3783, 3822,
- 3744, 3861
- };
- /**
- * The packed transition table of the DFA
- */
- final private static String yy_packed =
- "1161716110111212113114"+
- "16115261161621716217"+
- "16317761320121122223620"+
- "117120124117120217120317"+
- "7201171251261025127130125"+
- "1171125117102513152547324733"+
- "13344 6341 1341351 134"+
- "2 1343 15341364344 634"+
- "1 1341351 1342 1343 "+
- "73414 111116 21230 13344 "+
- "1341372341361341 134135"+
- "1 1342 1343 22344 140"+
- "5341 1341351 1342 134"+
- "3 15341413341424 6341 "+
- "1341351 1342 1343 734"+
- "1 12164 11163 141613434 "+
- "6431 1431441 1432 143"+
- "3 74314 12247 22310 124"+
- "34 22431 12252 1251 1125"+
- "1 16251 12252 1251 145"+
- "10251 162514 13024645 246"+
- "31 12252 1251 425147425"+
- "1 162525 15021 12341514 "+
- "6341 1341351 1342 134"+
- "3 22344 2341363341 134"+
- "1351 1342 1343 2134152"+
- "4 6341 1341351 1342 "+
- "1343 113415310344 6341 "+
- "1341351 1342 1343 2134"+
- "1544 6341 1341351 134"+
- "2 1343 7341 12252 125"+
- "1 15510251 16251 12252 "+
- "1251 11251 112515642525 "+
- "15721 10341602344 6341 "+
- "1341351 1342 1343 1434"+
- "1515344 6341 1341351 "+
- "1342 1343 22344 161534"+
- "1 1341351 1342 1343 "+
- "7341 12252 1251 11251 "+
- "11251624251 11251632 125"+
- "1 11251 162513344 134164"+
- "4341 1341351 1342 134"+
- "3 22344 6341651341351 "+
- "1342 1343 7341 725166"+
- "2252 1251 11251 16251 "+
- "7251672252 1251 11251 "+
- "162513344 5341511 134135"+
- "1 1342 1343 7341 170"+
- "46 3251716252 1251 1125"+
- "1 16251 12252 1251 172"+
- "10251 16251 17024 17321 "+
- "12517410252 1251 11251 "+
- "16251 12517510252 1251 "+
- "11251 16251 17646 1125177"+
- "2 1251 11251 16251 1225"+
- "2 1251 11251 12251100325"+
- "1 72511012252 1251 1125"+
- "1 16251 112511022 1251 "+
- "11251 16251 12252 1251 "+
- "12511037251 16251 12252 "+
- "1251 62511042251 16251 "+
- "12252 1251 52511053251 "+
- "16251 62511063252 1251 "+
- "11251 16251 12252 1251 "+
- "62511072251 16251 12252 "+
- "1251 12511107251 16251 "+
- "12252 1251 11251 14251111"+
- "1251 12252 1251 11251 "+
- "122511123251 12252 1251 "+
- "11251 72511136251 12252 "+
- "1251 11251 102511145251 "+
- "12252 1251 11251 5251115"+
- "72511151 12252 1251 1125"+
- "1 72511166251 12252 125"+
- "1 11251 525111772511171 "+
- "42511205252 1251 11251 "+
- "16251 12252 1251 11251 "+
- "525112172511211 12511221025"+
- "2 1251 11251 16251 1225"+
- "2 1251 11251 7251123625"+
- "1 112511242 1251 11251 "+
- "16251 62511253252 1251 "+
- "11251 16251 125112610252 "+
- "1251 11251 16251 12252 "+
- "1251 12511277251 16251 "+
- "12252 1251 11251 6251130"+
- "7251 12252 1251 11251 "+
- "122511313251 12252 11321 "+
- "11251 16251 12252 1251 "+
- "11251 102511335251 2251134"+
- "7252 1251 11251 16251 "+
- "12252 1251 11251 7251135"+
- "6251 12252 1251 1251136"+
- "7251 16251 12252 1251 "+
- "42511374251 16251 12252 "+
- "1251 42511404251 16251 "+
- "12252 1251 11251 12251141"+
- "3251 12252 1251 5251142"+
- "3251 16251 12252 1251 "+
- "11251 112511434251 4251144"+
- "5252 1251 11251 16251 "+
- "52511454252 1251 11251 "+
- "16251 125114610252 1251 "+
- "11251 16251 12252 1251 "+
- "52511473251 16251 12252 "+
- "1251 11251 122511503251 "+
- "32511516252 1251 11251 "+
- "16251 12252 1251 11251 "+
- "132511522251 12252 1251 "+
- "12511537251 16251 12252 "+
- "1251 11251 425115411251 "+
- "42511555252 1251 11251 "+
- "16251156121572 1251 6157125"+
- "11571251 115722511573257157"+
- "1 52511604252 1251 1125"+
- "1 1625131564 61561 11562 "+
- "11562 11563 71561 4251157"+
- "5252 1251 11251 1625";
- /**
- * The transition table of the DFA
- */
- final private static int yytrans [] = yy_unpack(yy_packed);
- /* error codes */
- final private static int YY_UNKNOWN_ERROR = 0;
- final private static int YY_ILLEGAL_STATE = 1;
- final private static int YY_NO_MATCH = 2;
- final private static int YY_PUSHBACK_2BIG = 3;
- /* error messages for the codes above */
- final private static String YY_ERROR_MSG[] = {
- "Unkown internal scanner error",
- "Internal error: unknown state",
- "Error: could not match input",
- "Error: pushback value was too large"
- };
- /**
- * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
- */
- private final static byte YY_ATTRIBUTE[] = {
- 0, 0, 0, 0, 0, 1, 1, 1, 9, 1, 1, 1, 1, 1, 9, 3,
- 1, 9, 1, 1, 1, 1, 1, 1, 1, 9, 9, 0, 0, 0, 0, 0,
- 0, 0, 2, 13, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0,
- 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
- };
- /** the input device */
- private java.io.Reader yy_reader;
- /** the current state of the DFA */
- private int yy_state;
- /** the current lexical state */
- private int yy_lexical_state = YYINITIAL;
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char yy_buffer[] = new char[16384];
- /** the textposition at the last accepting state */
- private int yy_markedPos;
- /** the current text position in the buffer */
- private int yy_currentPos;
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int yy_startRead;
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int yy_endRead;
- /** 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;
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning of a line
- */
- private boolean yy_atBOL;
- /** yy_atEOF == true <=> the scanner has returned a value for EOF */
- private boolean yy_atEOF;
- /* user code: */
- boolean has_content=false;
- boolean versionset=false;
- boolean set_contenttype=false;
- boolean set_contentlength=false;
- String content_type;
- int contentlength=0;
- int cur_contentlength;
- StringBuffer string = new StringBuffer();
- private Symbol symbol(int type) {
- return new Symbol(type, yyline, yycolumn);
- }
- private Symbol symbol(int type, Object value) {
- return new Symbol(type, yyline, yycolumn, value);
- }
-
- public String getContentType() {
- return content_type;
- }
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- HTTPLexer(java.io.Reader in) {
- this.yy_reader = in;
- }
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- HTTPLexer(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
- /**
- * Unpacks the compressed DFA transition table.
- *
- * @param packed the packed transition table
- * @return the unpacked transition table
- */
- private static int [] yy_unpack(String packed) {
- int [] trans = new int[3900];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 1886) {
- int count = packed.charAt(i++);
- int value = packed.charAt(i++);
- value--;
- do trans[j++] = value; while (--count > 0);
- }
- return trans;
- }
- /**
- * Gets the next input character.
- *
- * @return the next character of the input stream, EOF if the
- * end of the stream is reached.
- * @exception IOException if any I/O-Error occurs
- */
- private int yy_advance() throws java.io.IOException {
- /* standard case */
- if (yy_currentPos < yy_endRead) return yy_buffer[yy_currentPos++];
- /* if the eof is reached, we don't need to work hard */
- if (yy_atEOF) return YYEOF;
- /* otherwise: need to refill the buffer */
- /* first: make room (if you can) */
- if (yy_startRead > 0) {
- System.arraycopy(yy_buffer, yy_startRead,
- yy_buffer, 0,
- yy_endRead-yy_startRead);
- /* translate stored positions */
- yy_endRead-= yy_startRead;
- yy_currentPos-= yy_startRead;
- yy_markedPos-= yy_startRead;
- yy_startRead = 0;
- }
- /* is the buffer big enough? */
- if (yy_currentPos >= yy_buffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[yy_currentPos*2];
- System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
- yy_buffer = newBuffer;
- }
- /* finally: fill the buffer with new input */
- int numRead = yy_reader.read(yy_buffer, yy_endRead,
- yy_buffer.length-yy_endRead);
- if ( numRead == -1 ) return YYEOF;
- yy_endRead+= numRead;
- return yy_buffer[yy_currentPos++];
- }
- /**
- * Closes the input stream.
- */
- final public void yyclose() throws java.io.IOException {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yy_reader.close();
- }
- /**
- * Returns the current lexical state.
- */
- final public int yystate() {
- return yy_lexical_state;
- }
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
- final public void yybegin(int newState) {
- yy_lexical_state = newState;
- }
- /**
- * Returns the text matched by the current regular expression.
- */
- final public String yytext() {
- return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead );
- }
- /**
- * Returns the length of the matched text region.
- */
- final public int yylength() {
- return yy_markedPos-yy_startRead;
- }
- /**
- * Reports an error that occured while scanning.
- *
- * @param errorCode the code of the errormessage to display
- */
- private void yy_ScanError(int errorCode) {
- try {
- System.out.println(YY_ERROR_MSG[errorCode]);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
- }
- System.exit(1);
- }
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
- private void yypushback(int number) {
- if ( number > yylength() )
- yy_ScanError(YY_PUSHBACK_2BIG);
- yy_markedPos -= number;
- }
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception IOException if any I/O-Error occurs
- */
- public java_cup.runtime.Symbol yylex() throws java.io.IOException {
- int yy_input;
- int yy_action;
- int yy_pushbackPos = -1;
- boolean yy_was_pushback;
- while (true) {
- boolean yy_counted = false;
- for (yy_currentPos = yy_startRead; yy_currentPos < yy_markedPos;
- yy_currentPos++) {
- switch (yy_buffer[yy_currentPos]) {
- case 'r':
- yyline++;
- yycolumn = 0;
- yy_counted = true;
- break;
- case 'n':
- if (yy_counted)
- yy_counted = false;
- else {
- yyline++;
- yycolumn = 0;
- }
- break;
- default:
- yy_counted = false;
- yycolumn++;
- }
- }
- if (yy_counted) {
- if ( yy_advance() == 'n' ) yyline--;
- if ( !yy_atEOF ) yy_currentPos--;
- }
- yy_action = -1;
- yy_currentPos = yy_startRead = yy_markedPos;
- yy_state = yy_lexical_state;
- yy_was_pushback = false;
- yy_forAction: {
- while (true) {
- yy_input = yy_advance();
- if ( yy_input == YYEOF ) break yy_forAction;
- int yy_next = yytrans[ yy_rowMap[yy_state] + yycmap[yy_input] ];
- if (yy_next == -1) break yy_forAction;
- yy_state = yy_next;
- int yy_attributes = YY_ATTRIBUTE[yy_state];
- if ( (yy_attributes & 2) > 0 )
- yy_pushbackPos = yy_currentPos;
- if ( (yy_attributes & 1) > 0 ) {
- yy_was_pushback = (yy_attributes & 4) > 0;
- yy_action = yy_state;
- yy_markedPos = yy_currentPos;
- if ( (yy_attributes & 8) > 0 ) break yy_forAction;
- }
- }
- }
- if (yy_was_pushback)
- yy_markedPos = yy_pushbackPos;
- switch (yy_action) {
- case 40:
- { versionset=true;
- return symbol(METHOD,yytext()); }
- case 113: break;
- case 37:
- { string.append(" "); }
- case 114: break;
- case 19:
- { string.setLength(0);
- yybegin(HEADERDATA);
- return symbol(HEAD_SEP); }
- case 115: break;
- case 20:
- case 21:
- case 24:
- case 36:
- case 38:
- case 44:
- case 45:
- case 49:
- case 50:
- case 53:
- case 54:
- case 56:
- case 57:
- case 59:
- case 60:
- case 62:
- case 63:
- case 64:
- case 65:
- case 66:
- case 67:
- case 68:
- case 69:
- case 70:
- case 71:
- case 72:
- case 73:
- case 74:
- case 75:
- case 76:
- case 77:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- case 95:
- case 96:
- case 97:
- case 98:
- case 99:
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- case 108:
- case 111:
- { string.append(yytext()); }
- case 116: break;
- case 61:
- { return symbol(VERSION,yytext().substring(5)); }
- case 117: break;
- case 25:
- { return symbol(EOF); }
- case 118: break;
- case 9:
- case 18:
- { return symbol(SP); }
- case 119: break;
- case 13:
- { return symbol(URI,yytext()); }
- case 120: break;
- case 26:
- { string.append(yytext());
- cur_contentlength++;
- if(contentlength>0 && cur_contentlength >= contentlength) {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yybegin(END);
- return symbol(DATA,string.toString());
- } }
- case 121: break;
- case 5:
- case 6:
- case 10:
- case 11:
- case 12:
- case 14:
- case 15:
- { System.err.println("Invalid input!"); }
- case 122: break;
- case 35:
- { if(yytext().toUpperCase().trim().equals("CONTENT-LENGTH")) {
- set_contentlength=true;
- } else if(yytext().toUpperCase().trim().equals("CONTENT-TYPE")) {
- set_contenttype=true;
- }
- return symbol(TOKEN,yytext()); }
- case 123: break;
- case 16:
- case 17:
- { if(has_content) {
- cur_contentlength=0;
- string.setLength(0);
- yybegin(CONTENT);
- } else {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yybegin(END);
- }
- return symbol(CRLF); }
- case 124: break;
- case 22:
- case 23:
- { if(set_contentlength) {
- try {
- contentlength=Integer.parseInt(string.toString());
- } catch(NumberFormatException e) {
- e.printStackTrace();
- }
- set_contentlength=false;
- } else if(set_contenttype) {
- content_type=string.toString();
- set_contenttype=false;
- }
- yybegin(HEADER);
- return symbol(DATA,string.toString()); }
- case 125: break;
- case 109:
- case 110:
- { has_content=true;
- string.append(yytext()); }
- case 126: break;
- case 7:
- case 8:
- { if(versionset) {
- yybegin(HEADER);
- return symbol(CRLF);
- } }
- case 127: break;
- default:
- if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
- yy_atEOF = true;
- { return new java_cup.runtime.Symbol(sym.EOF);
- }
- }
- else {
- yy_ScanError(YY_NO_MATCH);
- }
- }
- }
- }
- }