vbscript: Added support for call keyword in lexer.
This commit is contained in:
parent
69dcc641df
commit
b6e9a83d78
|
@ -26,11 +26,61 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
|
||||
|
||||
static const WCHAR callW[] = {'c','a','l','l',0};
|
||||
|
||||
static const struct {
|
||||
const WCHAR *word;
|
||||
int token;
|
||||
} keywords[] = {
|
||||
{callW, tCALL}
|
||||
};
|
||||
|
||||
static inline BOOL is_identifier_char(WCHAR c)
|
||||
{
|
||||
return isalnumW(c) || c == '_';
|
||||
}
|
||||
|
||||
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word)
|
||||
{
|
||||
const WCHAR *p1 = ctx->ptr;
|
||||
const WCHAR *p2 = word;
|
||||
WCHAR c;
|
||||
|
||||
while(p1 < ctx->end && *p2) {
|
||||
c = tolowerW(*p1);
|
||||
if(c != *p2)
|
||||
return c - *p2;
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
|
||||
if(*p2 || (p1 < ctx->end && is_identifier_char(*p1)))
|
||||
return 1;
|
||||
|
||||
ctx->ptr = p1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_keywords(parser_ctx_t *ctx)
|
||||
{
|
||||
int min = 0, max = sizeof(keywords)/sizeof(keywords[0])-1, r, i;
|
||||
|
||||
while(min <= max) {
|
||||
i = (min+max)/2;
|
||||
|
||||
r = check_keyword(ctx, keywords[i].word);
|
||||
if(!r)
|
||||
return keywords[i].token;
|
||||
|
||||
if(r > 0)
|
||||
min = i+1;
|
||||
else
|
||||
max = i-1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret)
|
||||
{
|
||||
const WCHAR *ptr = ctx->ptr++;
|
||||
|
@ -62,8 +112,12 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
|
|||
|
||||
c = *ctx->ptr;
|
||||
|
||||
if(isalphaW(c))
|
||||
return parse_identifier(ctx, lval);
|
||||
if(isalphaW(c)) {
|
||||
int ret = check_keywords(ctx);
|
||||
if(!ret)
|
||||
return parse_identifier(ctx, lval);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch(c) {
|
||||
case '\n':
|
||||
|
|
|
@ -54,6 +54,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
|
|||
}
|
||||
|
||||
%token tEOF tNL blah
|
||||
%token tCALL
|
||||
%token <string> tIdentifier
|
||||
|
||||
%type <statement> Statement StatementNl
|
||||
|
|
Loading…
Reference in New Issue