ReactOS 0.4.16-dev-297-gc569aee
parser.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ccval_t
 
struct  _parser_ctx_t
 
struct  literal_t
 
struct  _variable_declaration_t
 
struct  _statement_t
 
struct  block_statement_t
 
struct  var_statement_t
 
struct  expression_statement_t
 
struct  if_statement_t
 
struct  while_statement_t
 
struct  for_statement_t
 
struct  forin_statement_t
 
struct  branch_statement_t
 
struct  with_statement_t
 
struct  labelled_statement_t
 
struct  _case_clausule_t
 
struct  switch_statement_t
 
struct  catch_block_t
 
struct  try_statement_t
 
struct  _expression_t
 
struct  _parameter_t
 
struct  _source_elements_t
 
struct  _function_expression_t
 
struct  binary_expression_t
 
struct  unary_expression_t
 
struct  conditional_expression_t
 
struct  member_expression_t
 
struct  _argument_t
 
struct  call_expression_t
 
struct  identifier_expression_t
 
struct  literal_expression_t
 
struct  _array_element_t
 
struct  array_literal_expression_t
 
struct  _property_definition_t
 
struct  property_value_expression_t
 

Typedefs

typedef struct _source_elements_t source_elements_t
 
typedef struct _expression_t expression_t
 
typedef struct _statement_t statement_t
 
typedef struct _parser_ctx_t parser_ctx_t
 
typedef struct _variable_declaration_t variable_declaration_t
 
typedef struct _case_clausule_t case_clausule_t
 
typedef struct _parameter_t parameter_t
 
typedef struct _function_expression_t function_expression_t
 
typedef struct _argument_t argument_t
 
typedef struct _array_element_t array_element_t
 
typedef struct _property_definition_t property_definition_t
 

Enumerations

enum  literal_type_t {
  LT_DOUBLE , LT_STRING , LT_BOOL , LT_NULL ,
  LT_REGEXP
}
 
enum  statement_type_t {
  STAT_BLOCK , STAT_BREAK , STAT_CONTINUE , STAT_EMPTY ,
  STAT_EXPR , STAT_FOR , STAT_FORIN , STAT_IF ,
  STAT_LABEL , STAT_RETURN , STAT_SWITCH , STAT_THROW ,
  STAT_TRY , STAT_VAR , STAT_WHILE , STAT_WITH ,
  STAT_ASSIGN , STAT_CALL , STAT_CONST , STAT_DIM ,
  STAT_DOUNTIL , STAT_DOWHILE , STAT_EXITDO , STAT_EXITFOR ,
  STAT_EXITFUNC , STAT_EXITPROP , STAT_EXITSUB , STAT_FOREACH ,
  STAT_FORTO , STAT_FUNC , STAT_IF , STAT_ONERROR ,
  STAT_SELECT , STAT_SET , STAT_STOP , STAT_UNTIL ,
  STAT_WHILE , STAT_WHILELOOP , STAT_RETVAL
}
 
enum  expression_type_t {
  EXPR_COMMA , EXPR_OR , EXPR_AND , EXPR_BOR ,
  EXPR_BXOR , EXPR_BAND , EXPR_INSTANCEOF , EXPR_IN ,
  EXPR_ADD , EXPR_SUB , EXPR_MUL , EXPR_DIV ,
  EXPR_MOD , EXPR_DELETE , EXPR_VOID , EXPR_TYPEOF ,
  EXPR_MINUS , EXPR_PLUS , EXPR_POSTINC , EXPR_POSTDEC ,
  EXPR_PREINC , EXPR_PREDEC , EXPR_EQ , EXPR_EQEQ ,
  EXPR_NOTEQ , EXPR_NOTEQEQ , EXPR_LESS , EXPR_LESSEQ ,
  EXPR_GREATER , EXPR_GREATEREQ , EXPR_BITNEG , EXPR_LOGNEG ,
  EXPR_LSHIFT , EXPR_RSHIFT , EXPR_RRSHIFT , EXPR_ASSIGN ,
  EXPR_ASSIGNLSHIFT , EXPR_ASSIGNRSHIFT , EXPR_ASSIGNRRSHIFT , EXPR_ASSIGNADD ,
  EXPR_ASSIGNSUB , EXPR_ASSIGNMUL , EXPR_ASSIGNDIV , EXPR_ASSIGNMOD ,
  EXPR_ASSIGNAND , EXPR_ASSIGNOR , EXPR_ASSIGNXOR , EXPR_COND ,
  EXPR_ARRAY , EXPR_MEMBER , EXPR_NEW , EXPR_CALL ,
  EXPR_THIS , EXPR_FUNC , EXPR_IDENT , EXPR_ARRAYLIT ,
  EXPR_PROPVAL , EXPR_LITERAL , EXPR_ADD , EXPR_AND ,
  EXPR_BOOL , EXPR_BRACKETS , EXPR_CONCAT , EXPR_DIV ,
  EXPR_DOUBLE , EXPR_EMPTY , EXPR_EQUAL , EXPR_EQV ,
  EXPR_EXP , EXPR_GT , EXPR_GTEQ , EXPR_IDIV ,
  EXPR_IMP , EXPR_INT , EXPR_IS , EXPR_LT ,
  EXPR_LTEQ , EXPR_ME , EXPR_MEMBER , EXPR_MOD ,
  EXPR_MUL , EXPR_NEG , EXPR_NEQUAL , EXPR_NEW ,
  EXPR_NOARG , EXPR_NOT , EXPR_NOTHING , EXPR_NULL ,
  EXPR_OR , EXPR_STRING , EXPR_SUB , EXPR_XOR
}
 

Functions

HRESULT script_parse (script_ctx_t *, struct _compiler_ctx_t *, const WCHAR *, const WCHAR *, BOOL, parser_ctx_t **) DECLSPEC_HIDDEN
 
void parser_release (parser_ctx_t *) DECLSPEC_HIDDEN
 
int parser_lex (void *, parser_ctx_t *) DECLSPEC_HIDDEN
 
static voidparser_alloc (parser_ctx_t *ctx, DWORD size)
 
static voidparser_alloc_tmp (parser_ctx_t *ctx, DWORD size)
 
BOOL is_identifier_char (WCHAR) DECLSPEC_HIDDEN
 
BOOL unescape (WCHAR *, size_t *) DECLSPEC_HIDDEN
 
HRESULT parse_decimal (const WCHAR **, const WCHAR *, double *) DECLSPEC_HIDDEN
 
literal_tparse_regexp (parser_ctx_t *) DECLSPEC_HIDDEN
 
literal_tnew_boolean_literal (parser_ctx_t *, BOOL) DECLSPEC_HIDDEN
 
BOOL try_parse_ccval (parser_ctx_t *, ccval_t *) DECLSPEC_HIDDEN
 
BOOL parse_cc_expr (parser_ctx_t *) DECLSPEC_HIDDEN
 
static ccval_t ccval_num (double n)
 
static ccval_t ccval_bool (BOOL b)
 
static BOOL get_ccbool (ccval_t v)
 
static double get_ccnum (ccval_t v)
 
jsstr_tcompiler_alloc_string_len (struct _compiler_ctx_t *, const WCHAR *, unsigned) DECLSPEC_HIDDEN
 

Typedef Documentation

◆ argument_t

◆ array_element_t

◆ case_clausule_t

◆ expression_t

Definition at line 22 of file parser.h.

◆ function_expression_t

◆ parameter_t

◆ parser_ctx_t

◆ property_definition_t

◆ source_elements_t

Definition at line 21 of file parser.h.

◆ statement_t

Definition at line 23 of file parser.h.

◆ variable_declaration_t

Enumeration Type Documentation

◆ expression_type_t

Enumerator
EXPR_COMMA 
EXPR_OR 
EXPR_AND 
EXPR_BOR 
EXPR_BXOR 
EXPR_BAND 
EXPR_INSTANCEOF 
EXPR_IN 
EXPR_ADD 
EXPR_SUB 
EXPR_MUL 
EXPR_DIV 
EXPR_MOD 
EXPR_DELETE 
EXPR_VOID 
EXPR_TYPEOF 
EXPR_MINUS 
EXPR_PLUS 
EXPR_POSTINC 
EXPR_POSTDEC 
EXPR_PREINC 
EXPR_PREDEC 
EXPR_EQ 
EXPR_EQEQ 
EXPR_NOTEQ 
EXPR_NOTEQEQ 
EXPR_LESS 
EXPR_LESSEQ 
EXPR_GREATER 
EXPR_GREATEREQ 
EXPR_BITNEG 
EXPR_LOGNEG 
EXPR_LSHIFT 
EXPR_RSHIFT 
EXPR_RRSHIFT 
EXPR_ASSIGN 
EXPR_ASSIGNLSHIFT 
EXPR_ASSIGNRSHIFT 
EXPR_ASSIGNRRSHIFT 
EXPR_ASSIGNADD 
EXPR_ASSIGNSUB 
EXPR_ASSIGNMUL 
EXPR_ASSIGNDIV 
EXPR_ASSIGNMOD 
EXPR_ASSIGNAND 
EXPR_ASSIGNOR 
EXPR_ASSIGNXOR 
EXPR_COND 
EXPR_ARRAY 
EXPR_MEMBER 
EXPR_NEW 
EXPR_CALL 
EXPR_THIS 
EXPR_FUNC 
EXPR_IDENT 
EXPR_ARRAYLIT 
EXPR_PROPVAL 
EXPR_LITERAL 
EXPR_ADD 
EXPR_AND 
EXPR_BOOL 
EXPR_BRACKETS 
EXPR_CONCAT 
EXPR_DIV 
EXPR_DOUBLE 
EXPR_EMPTY 
EXPR_EQUAL 
EXPR_EQV 
EXPR_EXP 
EXPR_GT 
EXPR_GTEQ 
EXPR_IDIV 
EXPR_IMP 
EXPR_INT 
EXPR_IS 
EXPR_LT 
EXPR_LTEQ 
EXPR_ME 
EXPR_MEMBER 
EXPR_MOD 
EXPR_MUL 
EXPR_NEG 
EXPR_NEQUAL 
EXPR_NEW 
EXPR_NOARG 
EXPR_NOT 
EXPR_NOTHING 
EXPR_NULL 
EXPR_OR 
EXPR_STRING 
EXPR_SUB 
EXPR_XOR 

Definition at line 216 of file parser.h.

216 {
218 EXPR_OR,
219 EXPR_AND,
220 EXPR_BOR,
221 EXPR_BXOR,
222 EXPR_BAND,
224 EXPR_IN,
225 EXPR_ADD,
226 EXPR_SUB,
227 EXPR_MUL,
228 EXPR_DIV,
229 EXPR_MOD,
231 EXPR_VOID,
234 EXPR_PLUS,
239 EXPR_EQ,
240 EXPR_EQEQ,
243 EXPR_LESS,
264 EXPR_COND,
267 EXPR_NEW,
268 EXPR_CALL,
269 EXPR_THIS,
270 EXPR_FUNC,
expression_type_t
Definition: parser.h:216
@ EXPR_MEMBER
Definition: parser.h:266
@ EXPR_PREDEC
Definition: parser.h:238
@ EXPR_RSHIFT
Definition: parser.h:250
@ EXPR_LESS
Definition: parser.h:243
@ EXPR_ASSIGNADD
Definition: parser.h:256
@ EXPR_GREATER
Definition: parser.h:245
@ EXPR_THIS
Definition: parser.h:269
@ EXPR_BOR
Definition: parser.h:220
@ EXPR_LITERAL
Definition: parser.h:274
@ EXPR_EQEQ
Definition: parser.h:240
@ EXPR_ASSIGNRRSHIFT
Definition: parser.h:255
@ EXPR_ASSIGNDIV
Definition: parser.h:259
@ EXPR_ARRAY
Definition: parser.h:265
@ EXPR_ASSIGNMUL
Definition: parser.h:258
@ EXPR_BXOR
Definition: parser.h:221
@ EXPR_ASSIGNMOD
Definition: parser.h:260
@ EXPR_MOD
Definition: parser.h:229
@ EXPR_FUNC
Definition: parser.h:270
@ EXPR_BAND
Definition: parser.h:222
@ EXPR_VOID
Definition: parser.h:231
@ EXPR_NEW
Definition: parser.h:267
@ EXPR_POSTDEC
Definition: parser.h:236
@ EXPR_ASSIGNOR
Definition: parser.h:262
@ EXPR_GREATEREQ
Definition: parser.h:246
@ EXPR_ASSIGNLSHIFT
Definition: parser.h:253
@ EXPR_CALL
Definition: parser.h:268
@ EXPR_LSHIFT
Definition: parser.h:249
@ EXPR_LOGNEG
Definition: parser.h:248
@ EXPR_PROPVAL
Definition: parser.h:273
@ EXPR_DELETE
Definition: parser.h:230
@ EXPR_ARRAYLIT
Definition: parser.h:272
@ EXPR_DIV
Definition: parser.h:228
@ EXPR_ADD
Definition: parser.h:225
@ EXPR_ASSIGN
Definition: parser.h:252
@ EXPR_TYPEOF
Definition: parser.h:232
@ EXPR_IDENT
Definition: parser.h:271
@ EXPR_IN
Definition: parser.h:224
@ EXPR_INSTANCEOF
Definition: parser.h:223
@ EXPR_PLUS
Definition: parser.h:234
@ EXPR_MUL
Definition: parser.h:227
@ EXPR_BITNEG
Definition: parser.h:247
@ EXPR_COND
Definition: parser.h:264
@ EXPR_PREINC
Definition: parser.h:237
@ EXPR_OR
Definition: parser.h:218
@ EXPR_NOTEQ
Definition: parser.h:241
@ EXPR_NOTEQEQ
Definition: parser.h:242
@ EXPR_POSTINC
Definition: parser.h:235
@ EXPR_ASSIGNAND
Definition: parser.h:261
@ EXPR_RRSHIFT
Definition: parser.h:251
@ EXPR_ASSIGNSUB
Definition: parser.h:257
@ EXPR_SUB
Definition: parser.h:226
@ EXPR_EQ
Definition: parser.h:239
@ EXPR_ASSIGNRSHIFT
Definition: parser.h:254
@ EXPR_LESSEQ
Definition: parser.h:244
@ EXPR_MINUS
Definition: parser.h:233
@ EXPR_COMMA
Definition: parser.h:217
@ EXPR_ASSIGNXOR
Definition: parser.h:263
@ EXPR_AND
Definition: parser.h:219

◆ literal_type_t

Enumerator
LT_DOUBLE 
LT_STRING 
LT_BOOL 
LT_NULL 
LT_REGEXP 

Definition at line 72 of file parser.h.

72 {
75 LT_BOOL,
76 LT_NULL,
literal_type_t
Definition: parser.h:72
@ LT_BOOL
Definition: parser.h:75
@ LT_STRING
Definition: parser.h:74
@ LT_NULL
Definition: parser.h:76
@ LT_REGEXP
Definition: parser.h:77
@ LT_DOUBLE
Definition: parser.h:73

◆ statement_type_t

Enumerator
STAT_BLOCK 
STAT_BREAK 
STAT_CONTINUE 
STAT_EMPTY 
STAT_EXPR 
STAT_FOR 
STAT_FORIN 
STAT_IF 
STAT_LABEL 
STAT_RETURN 
STAT_SWITCH 
STAT_THROW 
STAT_TRY 
STAT_VAR 
STAT_WHILE 
STAT_WITH 
STAT_ASSIGN 
STAT_CALL 
STAT_CONST 
STAT_DIM 
STAT_DOUNTIL 
STAT_DOWHILE 
STAT_EXITDO 
STAT_EXITFOR 
STAT_EXITFUNC 
STAT_EXITPROP 
STAT_EXITSUB 
STAT_FOREACH 
STAT_FORTO 
STAT_FUNC 
STAT_IF 
STAT_ONERROR 
STAT_SELECT 
STAT_SET 
STAT_STOP 
STAT_UNTIL 
STAT_WHILE 
STAT_WHILELOOP 
STAT_RETVAL 

Definition at line 104 of file parser.h.

104 {
109 STAT_EXPR,
110 STAT_FOR,
112 STAT_IF,
117 STAT_TRY,
118 STAT_VAR,
statement_type_t
Definition: parser.h:104
@ STAT_CONTINUE
Definition: parser.h:107
@ STAT_FOR
Definition: parser.h:110
@ STAT_EMPTY
Definition: parser.h:108
@ STAT_THROW
Definition: parser.h:116
@ STAT_SWITCH
Definition: parser.h:115
@ STAT_VAR
Definition: parser.h:118
@ STAT_EXPR
Definition: parser.h:109
@ STAT_TRY
Definition: parser.h:117
@ STAT_RETURN
Definition: parser.h:114
@ STAT_BLOCK
Definition: parser.h:105
@ STAT_WITH
Definition: parser.h:120
@ STAT_IF
Definition: parser.h:112
@ STAT_FORIN
Definition: parser.h:111
@ STAT_BREAK
Definition: parser.h:106
@ STAT_LABEL
Definition: parser.h:113
@ STAT_WHILE
Definition: parser.h:119

Function Documentation

◆ ccval_bool()

static ccval_t ccval_bool ( BOOL  b)
inlinestatic

Definition at line 387 of file parser.h.

388{
389 ccval_t r;
390 r.is_num = FALSE;
391 r.u.b = b;
392 return r;
393}
#define FALSE
Definition: types.h:117
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define b
Definition: ke_i.h:79
Definition: parser.h:25

Referenced by init_cc(), and try_parse_ccval().

◆ ccval_num()

static ccval_t ccval_num ( double  n)
inlinestatic

Definition at line 379 of file parser.h.

380{
381 ccval_t r;
382 r.is_num = TRUE;
383 r.u.n = n;
384 return r;
385}
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729

Referenced by init_cc(), and try_parse_ccval().

◆ compiler_alloc_string_len()

jsstr_t * compiler_alloc_string_len ( struct _compiler_ctx_t ctx,
const WCHAR str,
unsigned  len 
)

Definition at line 133 of file compile.c.

134{
135 jsstr_t *new_str;
136
137 if(!ctx->code->str_pool_size) {
138 ctx->code->str_pool = heap_alloc(8 * sizeof(jsstr_t*));
139 if(!ctx->code->str_pool)
140 return NULL;
141 ctx->code->str_pool_size = 8;
142 }else if(ctx->code->str_pool_size == ctx->code->str_cnt) {
143 jsstr_t **new_pool;
144
145 new_pool = heap_realloc(ctx->code->str_pool, ctx->code->str_pool_size*2*sizeof(jsstr_t*));
146 if(!new_pool)
147 return NULL;
148
149 ctx->code->str_pool = new_pool;
150 ctx->code->str_pool_size *= 2;
151 }
152
153 new_str = jsstr_alloc_len(str, len);
154 if(!new_str)
155 return NULL;
156
157 ctx->code->str_pool[ctx->code->str_cnt++] = new_str;
158 return new_str;
159}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define NULL
Definition: types.h:112
GLenum GLsizei len
Definition: glext.h:6722
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
const WCHAR * str
Definition: jsstr.h:39

Referenced by compiler_alloc_string(), parse_regexp(), and parse_string_literal().

◆ get_ccbool()

static BOOL get_ccbool ( ccval_t  v)
inlinestatic

Definition at line 395 of file parser.h.

396{
397 return v.is_num ? v.u.n != 0 : v.u.b;
398}
const GLdouble * v
Definition: gl.h:2040

Referenced by cc_token(), and skip_code().

◆ get_ccnum()

static double get_ccnum ( ccval_t  v)
inlinestatic

Definition at line 400 of file parser.h.

401{
402 return v.is_num ? v.u.n : v.u.b;
403}

◆ is_identifier_char()

BOOL is_identifier_char ( WCHAR  c)

Definition at line 81 of file lex.c.

82{
83 return iswalnum(c) || c == '$' || c == '_' || c == '\\';
84}
const GLubyte * c
Definition: glext.h:8905
#define iswalnum(_c)
Definition: ctype.h:671

Referenced by cc_token(), check_keyword(), is_keyword(), parse_cc_identifier(), parse_decimal(), parse_hex_literal(), parse_identifier(), parse_numeric_literal(), and skip_comment().

◆ new_boolean_literal()

literal_t * new_boolean_literal ( parser_ctx_t ctx,
BOOL  bval 
)

Definition at line 387 of file lex.c.

388{
390
391 ret->type = LT_BOOL;
392 ret->u.bval = bval;
393
394 return ret;
395}
float bval
Definition: cylfrac.c:48
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:58
int ret

Referenced by cc_token().

◆ parse_cc_expr()

BOOL parse_cc_expr ( parser_ctx_t )

Referenced by cc_token(), and skip_code().

◆ parse_decimal()

HRESULT parse_decimal ( const WCHAR **  iter,
const WCHAR end,
double ret 
)

Definition at line 397 of file lex.c.

398{
399 const WCHAR *ptr = *iter;
400 LONGLONG d = 0, hlp;
401 int exp = 0;
402
403 while(ptr < end && iswdigit(*ptr)) {
404 hlp = d*10 + *(ptr++) - '0';
405 if(d>MAXLONGLONG/10 || hlp<0) {
406 exp++;
407 break;
408 }
409 else
410 d = hlp;
411 }
412 while(ptr < end && iswdigit(*ptr)) {
413 exp++;
414 ptr++;
415 }
416
417 if(*ptr == '.') {
418 ptr++;
419
420 while(ptr < end && iswdigit(*ptr)) {
421 hlp = d*10 + *(ptr++) - '0';
422 if(d>MAXLONGLONG/10 || hlp<0)
423 break;
424
425 d = hlp;
426 exp--;
427 }
428 while(ptr < end && iswdigit(*ptr))
429 ptr++;
430 }
431
432 if(ptr < end && (*ptr == 'e' || *ptr == 'E')) {
433 int sign = 1, e = 0;
434
435 if(++ptr < end) {
436 if(*ptr == '+') {
437 ptr++;
438 }else if(*ptr == '-') {
439 sign = -1;
440 ptr++;
441 }else if(!iswdigit(*ptr)) {
442 WARN("Expected exponent part\n");
443 return E_FAIL;
444 }
445 }
446
447 if(ptr == end) {
448 WARN("unexpected end of file\n");
449 return E_FAIL;
450 }
451
452 while(ptr < end && iswdigit(*ptr)) {
453 if(e > INT_MAX/10 || (e = e*10 + *ptr++ - '0')<0)
454 e = INT_MAX;
455 }
456 e *= sign;
457
458 if(exp<0 && e<0 && e+exp>0) exp = INT_MIN;
459 else if(exp>0 && e>0 && e+exp<0) exp = INT_MAX;
460 else exp += e;
461 }
462
463 if(is_identifier_char(*ptr)) {
464 WARN("wrong char after zero\n");
466 }
467
468 *ret = exp>=0 ? d*pow(10, exp) : d/pow(10, -exp);
469 *iter = ptr;
470 return S_OK;
471}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_FAIL
Definition: ddrawi.h:102
double pow(double x, double y)
Definition: freeldr.c:110
GLuint GLuint end
Definition: gl.h:1545
#define iswdigit(_c)
Definition: ctype.h:667
#define S_OK
Definition: intsafe.h:52
#define INT_MIN
Definition: intsafe.h:123
#define INT_MAX
Definition: intsafe.h:150
BOOL is_identifier_char(WCHAR c)
Definition: lex.c:81
#define JS_E_MISSING_SEMICOLON
Definition: jscript.h:537
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define sign(x)
Definition: mapdesc.cc:613
static PVOID ptr
Definition: dispmode.c:27
DWORD exp
Definition: msg.c:16058
#define MAXLONGLONG
int64_t LONGLONG
Definition: typedefs.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by next_token(), parse_json_value(), and parse_numeric_literal().

◆ parse_regexp()

literal_t * parse_regexp ( parser_ctx_t ctx)

Definition at line 1115 of file lex.c.

1116{
1117 const WCHAR *re, *flags_ptr;
1119 DWORD re_len, flags;
1120 literal_t *ret;
1121 HRESULT hres;
1122
1123 TRACE("\n");
1124
1125 while(*--ctx->ptr != '/');
1126
1127 /* Simple regexp pre-parser; '/' if used in char class does not terminate regexp literal */
1128 re = ++ctx->ptr;
1129 while(ctx->ptr < ctx->end) {
1130 if(*ctx->ptr == '\\') {
1131 if(++ctx->ptr == ctx->end)
1132 break;
1133 }else if(in_class) {
1134 if(*ctx->ptr == '\n')
1135 break;
1136 if(*ctx->ptr == ']')
1137 in_class = FALSE;
1138 }else {
1139 if(*ctx->ptr == '/')
1140 break;
1141
1142 if(*ctx->ptr == '[')
1143 in_class = TRUE;
1144 }
1145 ctx->ptr++;
1146 }
1147
1148 if(ctx->ptr == ctx->end || *ctx->ptr != '/') {
1149 WARN("pre-parsing failed\n");
1150 return NULL;
1151 }
1152
1153 re_len = ctx->ptr-re;
1154
1155 flags_ptr = ++ctx->ptr;
1156 while(ctx->ptr < ctx->end && iswalnum(*ctx->ptr))
1157 ctx->ptr++;
1158
1159 hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags);
1160 if(FAILED(hres))
1161 return NULL;
1162
1163 ret = parser_alloc(ctx, sizeof(literal_t));
1164 ret->type = LT_REGEXP;
1165 ret->u.regexp.str = compiler_alloc_string_len(ctx->compiler, re, re_len);
1166 ret->u.regexp.flags = flags;
1167 return ret;
1168}
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define FAILED(hr)
Definition: intsafe.h:51
jsstr_t * compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len)
Definition: compile.c:133
HRESULT parse_regexp_flags(const WCHAR *, DWORD, DWORD *) DECLSPEC_HIDDEN
Definition: jsregexp.c:1022
#define in_class(found, pat, c)
Definition: match.c:168
HRESULT hres
Definition: protocol.c:465
#define TRACE(s)
Definition: solgame.cpp:4

◆ parser_alloc()

static void * parser_alloc ( parser_ctx_t ctx,
DWORD  size 
)
inlinestatic

Definition at line 58 of file parser.h.

59{
60 return heap_pool_alloc(&ctx->heap, size);
61}
GLsizeiptr size
Definition: glext.h:5919
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:77

Referenced by new_boolean_literal(), new_double_literal(), parse_identifier(), parse_regexp(), and parse_string_literal().

◆ parser_alloc_tmp()

static void * parser_alloc_tmp ( parser_ctx_t ctx,
DWORD  size 
)
inlinestatic

Definition at line 63 of file parser.h.

64{
65 return heap_pool_alloc(&ctx->script->tmp_heap, size);
66}

◆ parser_lex()

int parser_lex ( void lval,
parser_ctx_t ctx 
)

Definition at line 1102 of file lex.c.

1103{
1104 int ret;
1105
1106 ctx->nl = ctx->ptr == ctx->begin;
1107
1108 do {
1109 ret = next_token(ctx, lval);
1110 } while(ret == '@' && !(ret = cc_token(ctx, lval)));
1111
1112 return ret;
1113}
static int cc_token(parser_ctx_t *ctx, void *lval)
Definition: lex.c:1003
static int next_token(parser_ctx_t *ctx, void *lval)
Definition: lex.c:546

◆ parser_release()

void parser_release ( parser_ctx_t )

Referenced by compile_script(), and release_compiler().

◆ script_parse()

HRESULT script_parse ( script_ctx_t ,
struct _compiler_ctx_t ,
const WCHAR ,
const WCHAR ,
BOOL  ,
parser_ctx_t **   
)

Referenced by compile_script().

◆ try_parse_ccval()

BOOL try_parse_ccval ( parser_ctx_t ctx,
ccval_t r 
)

Definition at line 907 of file lex.c.

908{
909 if(!skip_spaces(ctx))
910 return -1;
911
912 if(iswdigit(*ctx->ptr)) {
913 double n;
914
916 return -1;
917
918 *r = ccval_num(n);
919 return 1;
920 }
921
922 if(*ctx->ptr == '@') {
923 const WCHAR *ident;
924 unsigned ident_len;
925 cc_var_t *cc_var;
926
928 return -1;
929
930 cc_var = find_cc_var(ctx->script->cc, ident, ident_len);
931 *r = cc_var ? cc_var->val : ccval_num(NAN);
932 return 1;
933 }
934
935 if(!check_keyword(ctx, L"true", NULL)) {
936 *r = ccval_bool(TRUE);
937 return 1;
938 }
939
940 if(!check_keyword(ctx, L"false", NULL)) {
941 *r = ccval_bool(FALSE);
942 return 1;
943 }
944
945 return 0;
946}
static ccval_t ccval_bool(BOOL b)
Definition: parser.h:387
static ccval_t ccval_num(double n)
Definition: parser.h:379
static BOOL skip_spaces(parser_ctx_t *ctx)
Definition: lex.c:217
static cc_var_t * find_cc_var(cc_ctx_t *cc, const WCHAR *name, unsigned name_len)
Definition: lex.c:848
static BOOL parse_cc_identifier(parser_ctx_t *ctx, const WCHAR **ret, unsigned *ret_len)
Definition: lex.c:889
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval)
Definition: lex.c:91
static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
Definition: lex.c:473
#define NAN
Definition: mesh.c:39
#define L(x)
Definition: ntvdm.h:50
static INT ident_len(LPCTSTR p)
Definition: set.c:266
Definition: lex.c:810
ccval_t val
Definition: lex.c:811
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3994

◆ unescape()

BOOL unescape ( WCHAR str,
size_t len 
)

Definition at line 227 of file lex.c.

228{
229 WCHAR *pd, *p, c, *end = str + *len;
230 int i;
231
232 pd = p = str;
233 while(p < end) {
234 if(*p != '\\') {
235 *pd++ = *p++;
236 continue;
237 }
238
239 if(++p == end)
240 return FALSE;
241
242 switch(*p) {
243 case '\'':
244 case '\"':
245 case '\\':
246 c = *p;
247 break;
248 case 'b':
249 c = '\b';
250 break;
251 case 't':
252 c = '\t';
253 break;
254 case 'n':
255 c = '\n';
256 break;
257 case 'f':
258 c = '\f';
259 break;
260 case 'r':
261 c = '\r';
262 break;
263 case 'x':
264 if(p + 2 >= end)
265 return FALSE;
266 i = hex_to_int(*++p);
267 if(i == -1)
268 return FALSE;
269 c = i << 4;
270
271 i = hex_to_int(*++p);
272 if(i == -1)
273 return FALSE;
274 c += i;
275 break;
276 case 'u':
277 if(p + 4 >= end)
278 return FALSE;
279 i = hex_to_int(*++p);
280 if(i == -1)
281 return FALSE;
282 c = i << 12;
283
284 i = hex_to_int(*++p);
285 if(i == -1)
286 return FALSE;
287 c += i << 8;
288
289 i = hex_to_int(*++p);
290 if(i == -1)
291 return FALSE;
292 c += i << 4;
293
294 i = hex_to_int(*++p);
295 if(i == -1)
296 return FALSE;
297 c += i;
298 break;
299 default:
300 if(iswdigit(*p)) {
301 c = *p++ - '0';
302 if(p < end && iswdigit(*p)) {
303 c = c*8 + (*p++ - '0');
304 if(p < end && iswdigit(*p))
305 c = c*8 + (*p++ - '0');
306 }
307 p--;
308 }
309 else
310 c = *p;
311 }
312
313 *pd++ = c;
314 p++;
315 }
316
317 *len = pd - str;
318 return TRUE;
319}
GLfloat GLfloat p
Definition: glext.h:8902
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
Definition: glfuncs.h:248
static int hex_to_int(WCHAR c)
Definition: lex.c:118
#define c
Definition: ke_i.h:80

Referenced by parse_json_string(), parse_string_literal(), and PathCreateFromUrlW().