📄 jsp_parser.y
字号:
tagl_attr : DIR_URI
{
DIRATTR_HDR();
PG->dir_attribute = DIR_URI;
}
| DIR_PREFIX
{
DIRATTR_HDR();
PG->dir_attribute = DIR_PREFIX;
}
;
incl_attr : DIR_INCFILE
{
DIRATTR_HDR();
PG->dir_attribute = DIR_INCFILE;
}
;
page_value : BOOL
{
if (PG->pass) fprintf( PG->out, "%d\n", pi3lval); else
{
switch (PG->dir_attribute)
{
case DIR_SESSION: PG->session = pi3lval; break;
case DIR_ISTHREADSAFE: PG->isThreadSafe = pi3lval; break;
case DIR_AUTOFLUSH: PG->autoFlush = pi3lval; break;
case DIR_ISERRORPAGE: PG->isErrorPage = pi3lval;
};
};
}
| STRING
{
if (PG->pass) fprintf( PG->out, "%s\n", (char *)pi3lval); else
{
switch (PG->dir_attribute)
{
case DIR_LANGUAGE:
if (strcmp((char *)pi3lval, "java"))
{
if (PG->pass) fprintf( PG->out, "\n/**\n* ERROR: Invalid value %s of attribute 'language' \
(only 'java' is allowed here).\n**/\n", (char *)pi3lval);
YYABORT;
};
break;
case DIR_BUFFER:
if (!strcmp((char *)pi3lval, "none"))
{
PG->buffer = -1;
}
else
{
// we parse this by hand to avoid trouble with numbers
// within other quoted values
PG->buf = strspn((char *)pi3lval, "0123456789");
if (PG->buf)
{
((char *)pi3lval)[PG->buf] = 0;
PG->buffer = atoi((const char *)pi3lval);
if (PG->pass && strcmp((const char *)(((char *)pi3lval)[PG->buf+1]), "kB"))
{
fprintf( PG->out, "\n/**\n* ERROR: Invalid value %s of attribute 'buffer' \
(only 'none'|'<size>kB' are allowed here).\n**/\n", (char *)pi3lval);
YYABORT;
};
}
else
{
if (PG->pass)
{
fprintf( PG->out, "\n/**\n* ERROR: Invalid value %s of attribute 'buffer' \
(only 'none'|'<size>kB' are allowed here).\n**/\n", (char *)pi3lval);
YYABORT;
};
};
};
break;
case DIR_IMPORT:
if (PG->import_ptr <= MAX_IMPORT_DEPTH)
{
strcpy(PG->imports[PG->import_ptr++], (char *)pi3lval);
}
else
{
if (PG->pass) fprintf( PG->out, "\n/**\n* ERROR: Too much imports in page directive, \
define %d at maximum.\n**/\n", MAX_IMPORT_DEPTH);
};
break;
case DIR_EXTENDS: strcpy(PG->extends, (char *)pi3lval); break;
case DIR_INFO: strcpy(PG->info, (char *)pi3lval); break;
case DIR_ERRORPAGE: strcpy(PG->errorPage, (char *)pi3lval); break;
case DIR_CONTENTTYPE: strcpy(PG->contentType, (char *)pi3lval);
};
};
}
| NUMBER STRING
{
if (PG->pass)
{
fprintf( PG->out, "%d%s\n", $1, $2);
if ((PG->dir_attribute == DIR_BUFFER) && strcmp((char *)$2, "kB"))
{
fprintf( PG->out, "\n/**\n* ERROR: Invalid unit %s of attribute 'buffer' \
(only 'kB' is allowed here).\n**/\n", (char *)pi3lval);
YYABORT;
};
}
else
{
switch (PG->dir_attribute)
{
case DIR_BUFFER: PG->buffer = $1;
};
};
}
;
tagl_value : STRING
{
if (PG->pass) fprintf( PG->out, "%s\n", (char *)pi3lval); else
{
switch (PG->dir_attribute)
{
case DIR_PREFIX: break;
case DIR_URI: break;
};
}
}
;
push_inc : PUSH_INCLUDE
{
if (PG->pass) fprintf( PG->out, "%s, level %d, included text follows >>>>>\n\t\t\t**/\n",
get_incl_name(PG), get_incl_level(PG));
}
;
pop_inc : POP_INCLUDE
{
if (PG->pass) fprintf( PG->out, "\t\t\t/**\n\t\t\t* >>>>> End of included text, level %d\n",
get_incl_level(PG) + 1);
}
;
usebean_start : ACTION_START JSP_USEBEAN
{
JSPACTION_HDR((char *)$2, "");
PG->action = JSP_USEBEAN;
}
;
setprop_start : ACTION_START JSP_SETPROPERTY
{
JSPACTION_HDR((char *)$2, "");
PG->action = JSP_SETPROPERTY;
}
;
getprop_start : ACTION_START JSP_GETPROPERTY
{
JSPACTION_HDR((char *)$2, "");
PG->action = JSP_GETPROPERTY;
}
;
include_start : ACTION_START JSP_INCLUDE
{
JSPACTION_HDR((char *)$2, "");
if (PG->pass) fprintf( PG->out, "\t\t\tapplication.getRequestDispatcher(");
PG->action = JSP_INCLUDE;
}
;
forward_start : ACTION_START JSP_FORWARD
{
JSPACTION_HDR((char *)$2, "");
if (PG->pass) fprintf( PG->out, "\t\t\tapplication.getRequestDispatcher(");
PG->action = JSP_FORWARD;
}
;
plugin_start : ACTION_START JSP_PLUGIN
{
JSPACTION_HDR((char *)$2, "(unsupported)");
PG->action = JSP_PLUGIN;
}
;
params_start : ACTION_START JSP_PARAMS
{
JSPACTION_HDR((char *)$2, "(unsupported)");
PG->action = JSP_PARAMS;
}
;
param_start : ACTION_START JSP_PARAM
{
JSPACTION_HDR((char *)$2, "(unsupported)");
PG->action = JSP_PARAM;
}
;
fallback_start : ACTION_START JSP_FALLBACK
{
JSPACTION_HDR((char *)$2, "(unsupported)");
PG->action = JSP_FALLBACK;
}
;
usebean_text : usebean_attr '=' '"' jsp_value '"'
| WHITESPACE
| usebean_text usebean_text
;
setprop_text : setprop_attr '=' '"' jsp_value '"'
| setprop_attr '=' ''' jsp_expr '''
| WHITESPACE
| setprop_text setprop_text
;
getprop_text : getprop_attr '=' '"' jsp_value '"'
| WHITESPACE
| getprop_text getprop_text
;
include_text : include_attr '=' '"' jsp_value '"'
| include_attr '=' ''' jsp_expr '''
| WHITESPACE
| include_text include_text
;
forward_text : forward_attr '=' '"' jsp_value '"'
| forward_attr '=' ''' jsp_expr '''
| WHITESPACE
| forward_text WHITESPACE
| WHITESPACE forward_text
;
plugin_text : plugin_attr '=' '"' jsp_value '"'
| WHITESPACE
| plugin_text plugin_text
;
param_text : param_attr '=' '"' jsp_value '"'
| WHITESPACE
| param_text param_text
;
usebean_attr : JSP_ID
{
// !!! Check duplicate ID's !!!
PG->act_attribute = JSP_ID;
}
| JSP_SCOPE
{
PG->act_attribute = JSP_SCOPE;
}
| JSP_CLASS
{
PG->act_attribute = JSP_CLASS;
}
| JSP_BEANNAME
{
PG->act_attribute = JSP_BEANNAME;
}
| JSP_TYPE
{
PG->act_attribute = JSP_TYPE;
}
;
setprop_attr : JSP_NAME
{
PG->act_attribute = JSP_NAME;
}
| JSP_PROPERTY
{
PG->act_attribute = JSP_PROPERTY;
}
| JSP_PROPERTYPARAM
{
PG->act_attribute = JSP_PROPERTYPARAM;
}
| JSP_VALUE
{
PG->act_attribute = JSP_VALUE;
}
;
getprop_attr : JSP_NAME
{
PG->act_attribute = JSP_NAME;
}
| JSP_PROPERTY
{
PG->act_attribute = JSP_PROPERTY;
}
;
include_attr : JSP_PAGE
{
PG->act_attribute = JSP_PAGE;
}
| JSP_FLUSH
{
PG->act_attribute = JSP_FLUSH;
}
;
forward_attr : JSP_PAGE
{
PG->act_attribute = JSP_PAGE;
}
;
plugin_attr : JSP_TYPE
{
PG->act_attribute = JSP_TYPE;
}
| JSP_CODE
{
PG->act_attribute = JSP_CODE;
}
| JSP_CODEBASE
{
PG->act_attribute = JSP_CODEBASE;
}
| JSP_ALIGN
{
PG->act_attribute = JSP_ALIGN;
}
| JSP_ARCHIVE
{
PG->act_attribute = JSP_ARCHIVE;
}
| JSP_HEIGHT
{
PG->act_attribute = JSP_HEIGHT;
}
| JSP_HSPACE
{
PG->act_attribute = JSP_HSPACE;
}
| JSP_JREVERSION
{
PG->act_attribute = JSP_JREVERSION;
}
| JSP_JNAME
{
PG->act_attribute = JSP_JNAME;
}
| JSP_VSPACE
{
PG->act_attribute = JSP_VSPACE;
}
| JSP_WIDTH
{
PG->act_attribute = JSP_WIDTH;
}
| JSP_NSPLUGINURL
{
PG->act_attribute = JSP_NSPLUGINURL;
}
| JSP_IEPLUGINURL
{
PG->act_attribute = JSP_IEPLUGINURL;
}
;
param_attr : JSP_NAME
{
PG->act_attribute = JSP_NAME;
}
| JSP_VALUE
{
PG->act_attribute = JSP_VALUE;
}
;
jsp_expr : jexp_start jexp_text jexp_end
| EXPRESSION_START EXPRESSION_END
;
jexp_start : EXPRESSION_START
{
if (PG->pass && PG->bs.prop.name[0])
{
fprintf( PG->out, "\t\t\tBeanProperty.set(%s,\"%s\",",
PG->bs.prop.name, PG->bs.prop.property );
}
}
;
jexp_text : JSP_EXPRESSION
{
if (PG->pass) fprintf( PG->out, "%s", (char *)pi3lval);
}
| WHITESPACE
{
if (PG->pass)
{
fprintf( PG->out, "%s", (char *)pi3lval);
if ((((char *)pi3lval)[0]==13) || (((char *)pi3lval)[0]==10))
fprintf( PG->out, "\t\t\t\t");
};
}
| jexp_text jexp_text
;
jexp_end : EXPRESSION_END
{
if (PG->pass && PG->bs.prop.name[0])
{
fprintf( PG->out, ");\n");
}
}
;
jsp_value : BOOL
| STRING
{
if (PG->pass)
{
switch (PG->action)
{
case JSP_GETPROPERTY:
switch (PG->act_attribute)
{
case JSP_NAME:
strcpy((char *)&(PG->bs.prop.name), (char *)pi3lval);
break;
case JSP_PROPERTY:
strcpy((char *)&(PG->bs.prop.property), (char *)pi3lval);
break;
default:
{
fprintf( PG->out, "\nPARSE ERROR\n");
// YYABORT;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -