Commit 1e224b4e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added lexer support for numeric literals.

parent bb80eaa4
......@@ -240,6 +240,33 @@ static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret)
return tString;
}
static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
{
double n = 0;
if(*ctx->ptr == '0' && !('0' <= ctx->ptr[1] && ctx->ptr[1] <= '9') && ctx->ptr[1] != '.')
return *ctx->ptr++;
do {
n = n*10 + *ctx->ptr++ - '0';
}while('0' <= *ctx->ptr && *ctx->ptr <= '9');
if(*ctx->ptr != '.') {
if((LONG)n == n) {
LONG l = n;
*(LONG*)ret = l;
return (short)l == l ? tShort : tLong;
}
}else {
double e = 1.0;
while('0' <= *++ctx->ptr && *ctx->ptr <= '9')
n += (e /= 10.0)*(*ctx->ptr-'0');
}
*(double*)ret = n;
return tDouble;
}
static void skip_spaces(parser_ctx_t *ctx)
{
while(*ctx->ptr == ' ' || *ctx->ptr == '\t' || *ctx->ptr == '\r')
......@@ -256,6 +283,9 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
c = *ctx->ptr;
if('0' <= c && c <= '9')
return parse_numeric_literal(ctx, lval);
if(isalphaW(c)) {
int ret = check_keywords(ctx);
if(!ret)
......
......@@ -74,6 +74,8 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME
%token tERROR tNEXT tON tRESUME tGOTO
%token <string> tIdentifier tString
%token <lng> tLong tShort
%token <dbl> tDouble
%type <statement> Statement StatementNl
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment