vbscript: Added support for HTML comments.
This commit is contained in:
parent
68c1bf507d
commit
290f563199
@ -1644,7 +1644,7 @@ static void release_compiler(compile_ctx_t *ctx)
|
|||||||
release_vbscode(ctx->code);
|
release_vbscode(ctx->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
|
HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, vbscode_t **ret)
|
||||||
{
|
{
|
||||||
function_t *new_func;
|
function_t *new_func;
|
||||||
function_decl_t *func_decl;
|
function_decl_t *func_decl;
|
||||||
@ -1653,7 +1653,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
|
|||||||
vbscode_t *code;
|
vbscode_t *code;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = parse_script(&ctx.parser, src);
|
hres = parse_script(&ctx.parser, src, delimiter);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -320,6 +320,16 @@ static void skip_spaces(parser_ctx_t *ctx)
|
|||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int comment_line(parser_ctx_t *ctx)
|
||||||
|
{
|
||||||
|
ctx->ptr = strchrW(ctx->ptr, '\n');
|
||||||
|
if(ctx->ptr)
|
||||||
|
ctx->ptr++;
|
||||||
|
else
|
||||||
|
ctx->ptr = ctx->end;
|
||||||
|
return tNL;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
WCHAR c;
|
WCHAR c;
|
||||||
@ -347,18 +357,12 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
|||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
return tNL;
|
return tNL;
|
||||||
case '\'':
|
case '\'':
|
||||||
ctx->ptr = strchrW(ctx->ptr, '\n');
|
return comment_line(ctx);
|
||||||
if(ctx->ptr)
|
|
||||||
ctx->ptr++;
|
|
||||||
else
|
|
||||||
ctx->ptr = ctx->end;
|
|
||||||
return tNL;
|
|
||||||
case ':':
|
case ':':
|
||||||
case ')':
|
case ')':
|
||||||
case ',':
|
case ',':
|
||||||
case '=':
|
case '=':
|
||||||
case '+':
|
case '+':
|
||||||
case '-':
|
|
||||||
case '*':
|
case '*':
|
||||||
case '/':
|
case '/':
|
||||||
case '^':
|
case '^':
|
||||||
@ -366,6 +370,11 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
|||||||
case '.':
|
case '.':
|
||||||
case '_':
|
case '_':
|
||||||
return *ctx->ptr++;
|
return *ctx->ptr++;
|
||||||
|
case '-':
|
||||||
|
if(ctx->is_html && ctx->ptr[1] == '-' && ctx->ptr[2] == '>')
|
||||||
|
return comment_line(ctx);
|
||||||
|
ctx->ptr++;
|
||||||
|
return '-';
|
||||||
case '(':
|
case '(':
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
* We resolve empty brackets in lexer instead of parser to avoid complex conflicts
|
* We resolve empty brackets in lexer instead of parser to avoid complex conflicts
|
||||||
@ -392,6 +401,9 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
|||||||
case '=':
|
case '=':
|
||||||
ctx->ptr++;
|
ctx->ptr++;
|
||||||
return tLTEQ;
|
return tLTEQ;
|
||||||
|
case '!':
|
||||||
|
if(ctx->is_html && ctx->ptr[1] == '-' && ctx->ptr[2] == '-')
|
||||||
|
return comment_line(ctx);
|
||||||
}
|
}
|
||||||
return '<';
|
return '<';
|
||||||
case '>':
|
case '>':
|
||||||
|
@ -253,6 +253,7 @@ typedef struct {
|
|||||||
|
|
||||||
BOOL option_explicit;
|
BOOL option_explicit;
|
||||||
BOOL parse_complete;
|
BOOL parse_complete;
|
||||||
|
BOOL is_html;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
int last_token;
|
int last_token;
|
||||||
@ -265,7 +266,7 @@ typedef struct {
|
|||||||
vbsheap_t heap;
|
vbsheap_t heap;
|
||||||
} parser_ctx_t;
|
} parser_ctx_t;
|
||||||
|
|
||||||
HRESULT parse_script(parser_ctx_t*,const WCHAR*) DECLSPEC_HIDDEN;
|
HRESULT parse_script(parser_ctx_t*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
|
||||||
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
||||||
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
||||||
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;
|
void *parser_alloc(parser_ctx_t*,size_t) DECLSPEC_HIDDEN;
|
||||||
|
@ -919,8 +919,10 @@ void *parser_alloc(parser_ctx_t *ctx, size_t size)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
|
HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimiter)
|
||||||
{
|
{
|
||||||
|
const WCHAR html_delimiterW[] = {'<','/','s','c','r','i','p','t','>',0};
|
||||||
|
|
||||||
ctx->code = ctx->ptr = code;
|
ctx->code = ctx->ptr = code;
|
||||||
ctx->end = ctx->code + strlenW(ctx->code);
|
ctx->end = ctx->code + strlenW(ctx->code);
|
||||||
|
|
||||||
@ -934,6 +936,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
|
|||||||
ctx->stats = ctx->stats_tail = NULL;
|
ctx->stats = ctx->stats_tail = NULL;
|
||||||
ctx->class_decls = NULL;
|
ctx->class_decls = NULL;
|
||||||
ctx->option_explicit = FALSE;
|
ctx->option_explicit = FALSE;
|
||||||
|
ctx->is_html = delimiter && !strcmpiW(delimiter, html_delimiterW);
|
||||||
|
|
||||||
parser_parse(ctx);
|
parser_parse(ctx);
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||||||
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
hres = compile_script(This->ctx, pstrCode, &code);
|
hres = compile_script(This->ctx, pstrCode, pstrDelimiter, &code);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptPar
|
|||||||
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED)
|
||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
hres = compile_script(This->ctx, pstrCode, &code);
|
hres = compile_script(This->ctx, pstrCode, pstrDelimiter, &code);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ struct _vbscode_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT compile_script(script_ctx_t*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
|
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
|
||||||
HRESULT exec_script(script_ctx_t*,function_t*,IDispatch*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
HRESULT exec_script(script_ctx_t*,function_t*,IDispatch*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
|
||||||
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user