#include <assert.h>
#include <limits.h>
#include <math.h>
#include "vbscript.h"
#include "parse.h"
#include "parser.tab.h"
#include "wine/debug.h"
Go to the source code of this file.
|
| | WINE_DEFAULT_DEBUG_CHANNEL (vbscript) |
| |
| static BOOL | is_identifier_char (WCHAR c) |
| |
| static int | check_keyword (parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) |
| |
| static int | check_keywords (parser_ctx_t *ctx, const WCHAR **lval) |
| |
| static int | parse_identifier (parser_ctx_t *ctx, const WCHAR **ret) |
| |
| static int | parse_string_literal (parser_ctx_t *ctx, const WCHAR **ret) |
| |
| static int | parse_date_literal (parser_ctx_t *ctx, DATE *ret) |
| |
| static int | parse_numeric_literal (parser_ctx_t *ctx, void **ret) |
| |
| static int | hex_to_int (WCHAR c) |
| |
| static int | parse_hex_literal (parser_ctx_t *ctx, LONG *ret) |
| |
| static void | skip_spaces (parser_ctx_t *ctx) |
| |
| static int | comment_line (parser_ctx_t *ctx) |
| |
| static int | parse_next_token (void *lval, unsigned *loc, parser_ctx_t *ctx) |
| |
| int | parser_lex (void *lval, unsigned *loc, parser_ctx_t *ctx) |
| |
◆ check_keyword()
Definition at line 106 of file lex.c.
107{
111
112 while(p1 < ctx->
end && *p2) {
116 p1++;
117 p2++;
118 }
119
121 return 1;
122
125 return 0;
126}
BOOL is_identifier_char(WCHAR c)
◆ check_keywords()
Definition at line 128 of file lex.c.
129{
131
134
138
141 else
143 }
144
145 return 0;
146}
GLdouble GLdouble GLdouble r
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static const struct @442 keywords[]
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval)
◆ comment_line()
Definition at line 384 of file lex.c.
385{
389 else
391 return tNL;
392}
_ACRTIMP wchar_t *__cdecl wcspbrk(const wchar_t *, const wchar_t *)
Referenced by parse_next_token().
◆ hex_to_int()
Definition at line 345 of file lex.c.
346{
347 if(
'0' <=
c &&
c <=
'9')
349 if(
'a' <=
c &&
c <=
'f')
351 if(
'A' <=
c &&
c <=
'F')
353 return -1;
354}
◆ is_identifier_char()
◆ parse_date_literal()
Definition at line 211 of file lex.c.
212{
217
218 while(
ctx->ptr <
ctx->end) {
219 if(*
ctx->ptr ==
'\n' || *
ctx->ptr ==
'\r') {
220 FIXME(
"newline inside date literal\n");
221 return 0;
222 }
223
225 break;
227 }
228
229 if(
ctx->ptr ==
ctx->end) {
230 FIXME(
"unterminated date literal\n");
231 return 0;
232 }
233
235
237 if(!rptr)
238 return 0;
239
245 FIXME(
"Invalid date literal\n");
246 return 0;
247 }
248
250 return tDate;
251}
HRESULT WINAPI VarDateFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, DATE *pdateOut)
#define memcpy(s1, s2, n)
Referenced by parse_next_token().
◆ parse_hex_literal()
Definition at line 356 of file lex.c.
357{
360
363
364 if(begin + 9 <
ctx->ptr) {
365 FIXME(
"invalid literal\n");
366 return 0;
367 }
368
369 if(*
ctx->ptr ==
'&') {
372 }else {
374 }
375 return tInt;
376}
Referenced by parse_next_token().
◆ parse_identifier()
Definition at line 148 of file lex.c.
149{
153
157
160 return 0;
161
165 return tIdentifier;
166}
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
◆ parse_next_token()
Definition at line 394 of file lex.c.
395{
397
399 *loc =
ctx->ptr -
ctx->code;
401 return ctx->last_token == tNL ? 0 : tNL;
402
404
405 if(
'0' <=
c &&
c <=
'9')
407
410 if(
ctx->last_token !=
'.' &&
ctx->last_token != tDOT)
417 }
418
420 case '\n':
421 case '\r':
423 return tNL;
424 case '\'':
426 case ':':
427 case ')':
428 case ',':
429 case '+':
430 case '*':
431 case '/':
432 case '^':
433 case '\\':
434 case '_':
436 case '.':
437
438
439
440
441
442 c =
ctx->ptr >
ctx->code ?
ctx->ptr[-1] :
'\n';
445 return '.';
446 }
448 if(
'0' <=
c &&
c <=
'9')
451 return tDOT;
452 case '-':
453 if(
ctx->is_html &&
ctx->ptr[1] ==
'-' &&
ctx->ptr[2] ==
'>')
456 return '-';
457 case '(':
458
459
460
461
464 if(*
ctx->ptr ==
')') {
466 return tEMPTYBRACKETS;
467 }
468
469
470
471
472 if(
ctx->last_token == tIdentifier ||
ctx->last_token ==
')')
473 return '(';
474 return tEXPRLBRACKET;
475 case '"':
477 case '#':
479 case '&':
482 return '&';
483 case '=':
484 switch(*++
ctx->ptr) {
485 case '<':
487 return tLTEQ;
488 case '>':
490 return tGTEQ;
491 }
492 return '=';
493 case '<':
494 switch(*++
ctx->ptr) {
495 case '>':
497 return tNEQ;
498 case '=':
500 return tLTEQ;
501 case '!':
502 if(
ctx->is_html &&
ctx->ptr[1] ==
'-' &&
ctx->ptr[2] ==
'-')
504 }
505 return '<';
506 case '>':
507 switch(*++
ctx->ptr) {
508 case '=':
510 return tGTEQ;
511 case '<':
513 return tNEQ;
514 }
515 return '>';
516 default:
518 }
519
520 return 0;
521}
static BOOL skip_spaces(parser_ctx_t *ctx)
static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval)
static int parse_string_literal(parser_ctx_t *ctx, jsstr_t **ret, WCHAR endch)
static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret)
static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
static int parse_hex_literal(parser_ctx_t *ctx, LONG *ret)
static int comment_line(parser_ctx_t *ctx)
static int parse_date_literal(parser_ctx_t *ctx, DATE *ret)
Referenced by parser_lex().
◆ parse_numeric_literal()
Definition at line 253 of file lex.c.
254{
259
260 if(*
ctx->ptr ==
'0' && !(
'0' <=
ctx->ptr[1] &&
ctx->ptr[1] <=
'9') &&
ctx->ptr[1] !=
'.')
262
264 hlp =
d*10 + *(
ctx->ptr++) -
'0';
267 break;
268 }
269 else
271 }
275 }
276
277 if(*
ctx->ptr ==
'.') {
280
282 hlp =
d*10 + *(
ctx->ptr++) -
'0';
284 break;
285
288 }
291 }
292
293 if(*
ctx->ptr ==
'e' || *
ctx->ptr ==
'E') {
295
297 if(*
ctx->ptr ==
'-') {
300 }
else if(*
ctx->ptr ==
'+') {
302 }
303
305 FIXME(
"Invalid numeric literal\n");
306 return 0;
307 }
308
310
311 do {
312 e =
e*10 + *(
ctx->ptr++) -
'0';
314
318 return tDouble;
319 }
320
322 FIXME(
"Invalid numeric literal\n");
323 return 0;
324 }
326
328 }
329
330 if(use_int && (
LONG)
d ==
d) {
332 return tInt;
333 }
334
337 FIXME(
"Invalid numeric literal\n");
338 return 0;
339 }
340
342 return tDouble;
343}
double pow(double x, double y)
◆ parse_string_literal()
Definition at line 168 of file lex.c.
169{
173
174 while(
ctx->ptr <
ctx->end) {
175 if(*
ctx->ptr ==
'\n' || *
ctx->ptr ==
'\r') {
176 FIXME(
"newline inside string literal\n");
177 return 0;
178 }
179
180 if(*
ctx->ptr ==
'"') {
181 if(
ctx->ptr[1] !=
'"')
182 break;
185 }
187 }
188
189 if(
ctx->ptr ==
ctx->end) {
190 FIXME(
"unterminated string literal\n");
191 return 0;
192 }
193
195
197 if(!rptr)
198 return 0;
199
200 while(ptr < ctx->
ptr) {
204 }
205
206 *rptr = 0;
208 return tString;
209}
◆ parser_lex()
Definition at line 523 of file lex.c.
524{
526
527 if (
ctx->last_token == tEXPRESSION)
528 {
529 ctx->last_token = tNL;
530 return tEXPRESSION;
531 }
532
533 while(1) {
537 if(*
ctx->ptr !=
'\n' && *
ctx->ptr !=
'\r') {
538 FIXME(
"'_' not followed by newline\n");
539 return 0;
540 }
541 if(*
ctx->ptr ==
'\r')
543 if(*
ctx->ptr ==
'\n')
545 continue;
546 }
547 if(
ret != tNL ||
ctx->last_token != tNL)
548 break;
549
551 }
552
553 return (
ctx->last_token =
ret);
554}
static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx)
◆ skip_spaces()
Definition at line 378 of file lex.c.
379{
380 while(*
ctx->ptr ==
' ' || *
ctx->ptr ==
'\t')
382}
◆ WINE_DEFAULT_DEBUG_CHANNEL()
| WINE_DEFAULT_DEBUG_CHANNEL |
( |
vbscript |
| ) |
|
| const struct { ... } keywords[] |
◆ token
Definition at line 37 of file lex.c.
◆ word
Definition at line 36 of file lex.c.