📄 jsp_scanner.h
字号:
#ifndef _PI3_JSP_SCANNER_H
#define _PI3_JSP_SCANNER_H
#include <stdio.h>
#include <assert.h>
#define MAX_INCLUDE_DEPTH 10
#define MAX_IMPORT_DEPTH 64
/* Macros, which control the generated scanner and the parser */
#define YYLEX_PARAM pp
#define YYPARSE_PARAM pp
#define YY_DECL inline int JspFlexLexer::yylex(int *pi3lval)
/* Macros for convenience used by scanner */
#define pi3text YYText()
#define PG ((pPG)YYPARSE_PARAM)
#define PI3LESS(text, len) i = strlen(text) - len; yyless(i)
#ifdef POSIX
# include <sys/param.h>
# define _MAX_PATH PATH_MAX
# ifdef __GNUC__
# undef __GNUC__
# endif
#endif
typedef struct {
char id[_MAX_PATH];
char type[_MAX_PATH];
char className[_MAX_PATH];
char beanName[_MAX_PATH];
char scope[_MAX_PATH];
} usebean_struct, *pUseBean;
typedef struct {
char name[_MAX_PATH];
char property[_MAX_PATH];
char param[_MAX_PATH];
char value[_MAX_PATH];
} property_struct, *pProperty;
typedef union {
usebean_struct bean;
property_struct prop;
} bean_struct, *pBean;
/**
* The block of global values for the parser,
* we need this to keep the parser reentrant
**/
typedef struct {
/**
* In the 1st pass we collect information for the class
* header of the servlet, in the 2nd pass we print out the
* stuff.
**/
int pass;
int directive;
int dir_attribute;
int action;
int act_attribute;
// to check invalid multiple page-attributes
int page_attribs[DIR_INCFILE - DIR_LANGUAGE + 1];
// page variable buffers
int import_ptr;
char imports[_MAX_PATH][MAX_IMPORT_DEPTH];
char classname[_MAX_PATH];
char extends[_MAX_PATH];
char info[_MAX_PATH];
char errorPage[_MAX_PATH];
char contentType[64];
int session;
int buffer;
int autoFlush;
int isThreadSafe;
int isErrorPage;
int buf;
bean_struct bs;
void *scanner; // scanner_globals;
FILE *out;
} parser_globals, *pPG;
#ifdef __cplusplus
typedef struct yy_buffer_state *YY_BUFFER_STATE;
/**
* The C++ class version of the globals struct, for easier
* encapsulation of struct as class member of scanner class
**/
class JspFlexLexer;
class p_globals : public parser_globals {
public:
p_globals( const char *ClassName, const char *Extends,
const char *OutFile, JspFlexLexer *JspFlexLexer )
{
assert( ClassName );
assert( Extends );
assert( JspFlexLexer );
pass = 0;
directive = DIR_PAGE;
dir_attribute = DIR_LANGUAGE;
action = JSP_USEBEAN;
act_attribute = JSP_ID;
int i;
for (i = 0; i < DIR_INCFILE - DIR_LANGUAGE + 1; i++)
page_attribs[i] = 0;
import_ptr = 0;
for (i = 0; i < MAX_IMPORT_DEPTH; i++)
imports[0][i] = 0;
strcpy( (char *)classname, ClassName );
strcpy( (char *)extends, Extends );
strcpy( (char *)info, "null" );
strcpy( (char *)errorPage, "null" );
strcpy( (char *)contentType, "text/html; charset=ISO-8859-1" );
session = 1;
buffer = 8;
autoFlush = 1;
isThreadSafe = 1;
isErrorPage = 0;
buf = 0;
bs.bean.id[0] = 0;
bs.bean.type[0] = 0;
bs.bean.className[0] = 0;
bs.bean.beanName[0] = 0;
bs.bean.scope[0] = 0;
scanner = JspFlexLexer;
out = 0;
out = OutFile ? fopen(OutFile, "w") : stdout;
if (!out) out = stdout;
}
virtual ~p_globals() {
if ( out && ( out != stdout )) fclose( out );
}
};
/* Scanner class */
class JspFlexLexer : public yyFlexLexer
{
private:
const char *inFileName;
int i;
p_globals *pp;
char fname_buf[_MAX_PATH]; // include file info
int include_stack_ptr;
YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
public:
JspFlexLexer( const char *ifname = 0, const char *ofname = 0,
const char *classname = 0, const char *extends = "Pi3HttpJspPage" );
virtual ~JspFlexLexer();
int exec();
inline const char *get_incl_name() { return (const char *)&fname_buf; };
inline int get_incl_level() { return include_stack_ptr; };
inline pPG get_globals() { return (pPG)pp; };
inline int prepare_next_pass();
inline int yylex( int *pi3lval );
};
# define SG ((JspFlexLexer *)((parser_globals *)pp)->scanner)
# define EC extern "C"
#else
# define EC
#endif // #ifdef __cplusplus
// common function prototypes
EC int pi3lex(int *, void *);
EC int pi3error(char *);
EC int pi3servlet_head(void *);
EC int pi3servlet_foot(void *);
EC int pi3write_bean(void *);
EC int pi3write_setproperty(void *);
EC int pi3write_getproperty(void *);
EC int pi3write_plain(void *, const char *);
EC int pi3parse(void *);
EC const char *get_incl_name(void *);
EC int get_incl_level(void *);
EC int get_lineno(void *);
#undef EC
#endif /* _PI3_JSP_SCANNER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -