http.cup
上传用户:huihesys
上传日期:2007-01-04
资源大小:3877k
文件大小:2k
- package net.wastl.webmail.standalone;
- import net.wastl.webmail.server.http.HTTPRequestHeader;
- import java_cup.runtime.*;
- import java.util.Hashtable;
- /*
- * http.cup
- *
- * 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.
- */
- parser code {:
- HTTPLexer lexer;
- HTTPRequestHeader parent;
- Connection connection;
- Hashtable current_mime=new Hashtable();
- public HTTPParser(java.io.Reader input, Connection conn, HTTPRequestHeader parent) {
- lexer = new HTTPLexer(input);
- this.parent=parent;
- this.connection=conn;
- }
- public void syntax_error(Symbol cur_token) {
- }
- public void unrecovered_syntax_error(Symbol token) {
- }
- :};
- scan with {: return lexer.yylex(); :};
- terminal java.lang.String METHOD;
- terminal java.lang.String VERSION;
- terminal java.lang.String URI;
- terminal CRLF;
- terminal SP;
- terminal HEAD_SEP;
- terminal java.lang.String STRING_LITERAL;
- terminal java.lang.String DATA;
- non terminal http_request;
- non terminal headers;
- non terminal content;
- terminal java.lang.String TOKEN;
- start with http_request;
- http_request ::= METHOD:m SP URI:p SP VERSION:v CRLF headers
- {: parser.parent.setMethod(m);
- parser.parent.setPath(p);
- parser.parent.setVersion(v);
- :}
- | METHOD:m SP URI:p SP VERSION:v CRLF headers content
- {: parser.parent.setMethod(m);
- parser.parent.setPath(p);
- parser.parent.setVersion(v);
- :}
- ;
- headers ::= CRLF
- | TOKEN: k HEAD_SEP DATA:v headers
- {: parser.parent.setHeader(k,v); :}
- ;
- content ::= DATA:d
- {: parser.parent.setEncodedContent(d, parser.lexer.getContentType()); :}
- ;