ReactOS  0.4.13-dev-235-g7373cb3
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
}
 
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_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_ULONG, EXPR_USHORT,
  EXPR_XOR
}
 

Functions

HRESULT script_parse (script_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 *) 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)
 

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_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_ULONG 
EXPR_USHORT 
EXPR_XOR 

Definition at line 216 of file parser.h.

216  {
217  EXPR_COMMA,
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,
230  EXPR_DELETE,
231  EXPR_VOID,
232  EXPR_TYPEOF,
233  EXPR_MINUS,
234  EXPR_PLUS,
235  EXPR_POSTINC,
236  EXPR_POSTDEC,
237  EXPR_PREINC,
238  EXPR_PREDEC,
239  EXPR_EQ,
240  EXPR_EQEQ,
241  EXPR_NOTEQ,
242  EXPR_NOTEQEQ,
243  EXPR_LESS,
244  EXPR_LESSEQ,
245  EXPR_GREATER,
247  EXPR_BITNEG,
248  EXPR_LOGNEG,
249  EXPR_LSHIFT,
250  EXPR_RSHIFT,
251  EXPR_RRSHIFT,
252  EXPR_ASSIGN,
264  EXPR_COND,
265  EXPR_ARRAY,
266  EXPR_MEMBER,
267  EXPR_NEW,
268  EXPR_CALL,
269  EXPR_THIS,
270  EXPR_FUNC,
271  EXPR_IDENT,
273  EXPR_PROPVAL,
expression_type_t
Definition: parser.h:216

◆ literal_type_t

Enumerator
LT_DOUBLE 
LT_STRING 
LT_BOOL 
LT_NULL 
LT_REGEXP 

Definition at line 71 of file parser.h.

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

◆ 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 

Definition at line 104 of file parser.h.

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

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 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define b
Definition: ke_i.h:79
Definition: parser.h:25

Referenced by init_cc(), try_parse_ccval(), and yyparse().

◆ 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 GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
Definition: parser.h:25

Referenced by init_cc(), try_parse_ccval(), and yyparse().

◆ 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(), skip_code(), and yyparse().

◆ 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 }
const GLdouble * v
Definition: gl.h:2040

Referenced by yyparse().

◆ is_identifier_char()

BOOL is_identifier_char ( WCHAR  )

Definition at line 123 of file lex.c.

124 {
125  return isalnumW(c) || c == '$' || c == '_' || c == '\\';
126 }
const GLubyte * c
Definition: glext.h:8905
WINE_UNICODE_INLINE int isalnumW(WCHAR wc)
Definition: unicode.h:190

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

◆ new_boolean_literal()

literal_t* new_boolean_literal ( parser_ctx_t ,
BOOL   
)

Definition at line 416 of file lex.c.

417 {
418  literal_t *ret = parser_alloc(ctx, sizeof(literal_t));
419 
420  ret->type = LT_BOOL;
421  ret->u.bval = bval;
422 
423  return ret;
424 }
Definition: parser.h:74
int ret
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:57
float bval
Definition: cylfrac.c:48

Referenced by cc_token(), and yyparse().

◆ parse_cc_expr()

BOOL parse_cc_expr ( parser_ctx_t )

Definition at line 1807 of file cc_parser.tab.c.

1808 {
1809  ctx->hres = S_OK;
1810  cc_parser_parse(ctx);
1811  return SUCCEEDED(ctx->hres);
1812 }
#define S_OK
Definition: intsafe.h:59
int cc_parser_parse(parser_ctx_t *ctx)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by cc_token(), and skip_code().

◆ parse_decimal()

HRESULT parse_decimal ( const WCHAR **  ,
const WCHAR ,
double  
)

Definition at line 426 of file lex.c.

427 {
428  const WCHAR *ptr = *iter;
429  LONGLONG d = 0, hlp;
430  int exp = 0;
431 
432  while(ptr < end && isdigitW(*ptr)) {
433  hlp = d*10 + *(ptr++) - '0';
434  if(d>MAXLONGLONG/10 || hlp<0) {
435  exp++;
436  break;
437  }
438  else
439  d = hlp;
440  }
441  while(ptr < end && isdigitW(*ptr)) {
442  exp++;
443  ptr++;
444  }
445 
446  if(*ptr == '.') {
447  ptr++;
448 
449  while(ptr < end && isdigitW(*ptr)) {
450  hlp = d*10 + *(ptr++) - '0';
451  if(d>MAXLONGLONG/10 || hlp<0)
452  break;
453 
454  d = hlp;
455  exp--;
456  }
457  while(ptr < end && isdigitW(*ptr))
458  ptr++;
459  }
460 
461  if(ptr < end && (*ptr == 'e' || *ptr == 'E')) {
462  int sign = 1, e = 0;
463 
464  if(++ptr < end) {
465  if(*ptr == '+') {
466  ptr++;
467  }else if(*ptr == '-') {
468  sign = -1;
469  ptr++;
470  }else if(!isdigitW(*ptr)) {
471  WARN("Expected exponent part\n");
472  return E_FAIL;
473  }
474  }
475 
476  if(ptr == end) {
477  WARN("unexpected end of file\n");
478  return E_FAIL;
479  }
480 
481  while(ptr < end && isdigitW(*ptr)) {
482  if(e > INT_MAX/10 || (e = e*10 + *ptr++ - '0')<0)
483  e = INT_MAX;
484  }
485  e *= sign;
486 
487  if(exp<0 && e<0 && e+exp>0) exp = INT_MIN;
488  else if(exp>0 && e>0 && e+exp<0) exp = INT_MAX;
489  else exp += e;
490  }
491 
492  if(is_identifier_char(*ptr)) {
493  WARN("wrong char after zero\n");
494  return JS_E_MISSING_SEMICOLON;
495  }
496 
497  *ret = exp>=0 ? d*pow(10, exp) : d/pow(10, -exp);
498  *iter = ptr;
499  return S_OK;
500 }
static size_t double int int int * sign
Definition: printf.c:64
#define INT_MAX
Definition: limits.h:40
BOOL is_identifier_char(WCHAR c)
Definition: lex.c:123
#define WARN(fmt,...)
Definition: debug.h:111
GLuint GLuint end
Definition: gl.h:1545
#define MAXLONGLONG
#define E_FAIL
Definition: ddrawi.h:102
float pow(float __x, int __y)
Definition: _cmath.h:458
#define e
Definition: ke_i.h:82
static PVOID ptr
Definition: dispmode.c:27
int64_t LONGLONG
Definition: typedefs.h:66
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define JS_E_MISSING_SEMICOLON
Definition: jscript.h:538
int ret
#define INT_MIN
Definition: limits.h:39
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
DWORD exp
Definition: msg.c:15681

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

◆ parse_regexp()

literal_t* parse_regexp ( parser_ctx_t )

Definition at line 1155 of file lex.c.

1156 {
1157  const WCHAR *re, *flags_ptr;
1158  BOOL in_class = FALSE;
1159  DWORD re_len, flags;
1160  literal_t *ret;
1161  HRESULT hres;
1162 
1163  TRACE("\n");
1164 
1165  while(*--ctx->ptr != '/');
1166 
1167  /* Simple regexp pre-parser; '/' if used in char class does not terminate regexp literal */
1168  re = ++ctx->ptr;
1169  while(ctx->ptr < ctx->end) {
1170  if(*ctx->ptr == '\\') {
1171  if(++ctx->ptr == ctx->end)
1172  break;
1173  }else if(in_class) {
1174  if(*ctx->ptr == '\n')
1175  break;
1176  if(*ctx->ptr == ']')
1177  in_class = FALSE;
1178  }else {
1179  if(*ctx->ptr == '/')
1180  break;
1181 
1182  if(*ctx->ptr == '[')
1183  in_class = TRUE;
1184  }
1185  ctx->ptr++;
1186  }
1187 
1188  if(ctx->ptr == ctx->end || *ctx->ptr != '/') {
1189  WARN("pre-parsing failed\n");
1190  return NULL;
1191  }
1192 
1193  re_len = ctx->ptr-re;
1194 
1195  flags_ptr = ++ctx->ptr;
1196  while(ctx->ptr < ctx->end && isalnumW(*ctx->ptr))
1197  ctx->ptr++;
1198 
1199  hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags);
1200  if(FAILED(hres))
1201  return NULL;
1202 
1203  ret = parser_alloc(ctx, sizeof(literal_t));
1204  ret->type = LT_REGEXP;
1205  ret->u.regexp.str = re;
1206  ret->u.regexp.str_len = re_len;
1207  ret->u.regexp.flags = flags;
1208  return ret;
1209 }
HRESULT parse_regexp_flags(const WCHAR *, DWORD, DWORD *) DECLSPEC_HIDDEN
Definition: jsregexp.c:1022
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
#define in_class(found, pat, c)
Definition: match.c:168
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
WINE_UNICODE_INLINE int isalnumW(WCHAR wc)
Definition: unicode.h:190
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:57

Referenced by yyparse().

◆ parser_alloc()

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

Definition at line 57 of file parser.h.

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

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 62 of file parser.h.

63 {
64  return heap_pool_alloc(&ctx->script->tmp_heap, size);
65 }
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:75
GLsizeiptr size
Definition: glext.h:5919

Referenced by new_argument_list(), new_case_list(), new_element_list(), new_parameter_list(), new_property_list(), new_statement_list(), and new_variable_list().

◆ parser_lex()

int parser_lex ( void ,
parser_ctx_t  
)

Definition at line 1142 of file lex.c.

1143 {
1144  int ret;
1145 
1146  ctx->nl = ctx->ptr == ctx->begin;
1147 
1148  do {
1149  ret = next_token(ctx, lval);
1150  } while(ret == '@' && !(ret = cc_token(ctx, lval)));
1151 
1152  return ret;
1153 }
static int cc_token(parser_ctx_t *ctx, void *lval)
Definition: lex.c:1040
int ret
static int next_token(parser_ctx_t *ctx, void *lval)
Definition: lex.c:575

◆ parser_release()

void parser_release ( parser_ctx_t )

Definition at line 4330 of file parser.tab.c.

4331 {
4332  script_release(ctx->script);
4333  heap_pool_free(&ctx->heap);
4334  heap_free(ctx);
4335 }
void script_release(script_ctx_t *ctx)
Definition: jscript.c:67
void heap_pool_free(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:167
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by compile_script(), and release_compiler().

◆ script_parse()

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

Definition at line 4337 of file parser.tab.c.

4339 {
4340  parser_ctx_t *parser_ctx;
4341  heap_pool_t *mark;
4342  HRESULT hres;
4343 
4344  const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
4345 
4346  parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
4347  if(!parser_ctx)
4348  return E_OUTOFMEMORY;
4349 
4350  parser_ctx->hres = JS_E_SYNTAX;
4351  parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW);
4352 
4353  parser_ctx->begin = parser_ctx->ptr = code;
4354  parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin);
4355 
4356  script_addref(ctx);
4357  parser_ctx->script = ctx;
4358 
4359  mark = heap_pool_mark(&ctx->tmp_heap);
4360  heap_pool_init(&parser_ctx->heap);
4361 
4362  parser_parse(parser_ctx);
4363  heap_pool_clear(mark);
4364  hres = parser_ctx->hres;
4365  if(FAILED(hres)) {
4366  WARN("parser failed around %s\n",
4367  debugstr_w(parser_ctx->begin+20 > parser_ctx->ptr ? parser_ctx->begin : parser_ctx->ptr-20));
4368  parser_release(parser_ctx);
4369  return hres;
4370  }
4371 
4372  *ret = parser_ctx;
4373  return S_OK;
4374 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WARN(fmt,...)
Definition: debug.h:111
void parser_release(parser_ctx_t *ctx)
Definition: parser.tab.c:4330
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
int parser_parse(parser_ctx_t *ctx)
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * ptr
Definition: parse.h:256
const char * delimiter
Definition: string.c:1523
heap_pool_t heap
Definition: parse.h:271
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
const WCHAR * end
Definition: parse.h:257
int code
Definition: i386-dis.c:3591
void heap_pool_init(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:69
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define S_OK
Definition: intsafe.h:59
static void script_addref(script_ctx_t *ctx)
Definition: jscript.h:459
#define JS_E_SYNTAX
Definition: jscript.h:537
HRESULT hres
Definition: parse.h:262
BOOL is_html
Definition: parse.h:261
heap_pool_t * heap_pool_mark(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:180
void heap_pool_clear(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:144

Referenced by compile_script().

◆ try_parse_ccval()

BOOL try_parse_ccval ( parser_ctx_t ,
ccval_t  
)

Definition at line 944 of file lex.c.

945 {
946  if(!skip_spaces(ctx))
947  return -1;
948 
949  if(isdigitW(*ctx->ptr)) {
950  double n;
951 
952  if(!parse_numeric_literal(ctx, &n))
953  return -1;
954 
955  *r = ccval_num(n);
956  return 1;
957  }
958 
959  if(*ctx->ptr == '@') {
960  const WCHAR *ident;
961  unsigned ident_len;
962  cc_var_t *cc_var;
963 
964  if(!parse_cc_identifier(ctx, &ident, &ident_len))
965  return -1;
966 
967  cc_var = find_cc_var(ctx->script->cc, ident, ident_len);
968  *r = cc_var ? cc_var->val : ccval_num(NAN);
969  return 1;
970  }
971 
972  if(!check_keyword(ctx, trueW, NULL)) {
973  *r = ccval_bool(TRUE);
974  return 1;
975  }
976 
977  if(!check_keyword(ctx, falseW, NULL)) {
978  *r = ccval_bool(FALSE);
979  return 1;
980  }
981 
982  return 0;
983 }
#define TRUE
Definition: types.h:120
static cc_var_t * find_cc_var(cc_ctx_t *cc, const WCHAR *name, unsigned name_len)
Definition: lex.c:877
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
Definition: lex.c:502
static ccval_t ccval_bool(BOOL b)
Definition: parser.h:387
static ccval_t ccval_num(double n)
Definition: parser.h:379
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3993
__wchar_t WCHAR
Definition: xmlstorage.h:180
ccval_t val
Definition: lex.c:840
#define NAN
Definition: misc.c:46
static INT ident_len(LPCTSTR p)
Definition: set.c:208
static BOOL parse_cc_identifier(parser_ctx_t *ctx, const WCHAR **ret, unsigned *ret_len)
Definition: lex.c:926
static const WCHAR falseW[]
Definition: lex.c:51
Definition: lex.c:839
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
static BOOL skip_spaces(parser_ctx_t *ctx)
Definition: lex.c:259
static const WCHAR trueW[]
Definition: lex.c:66
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval)
Definition: lex.c:133

Referenced by cc_parser_lex().

◆ unescape()

BOOL unescape ( WCHAR )

Definition at line 269 of file lex.c.

270 {
271  WCHAR *pd, *p, c;
272  int i;
273 
274  pd = p = str;
275  while(*p) {
276  if(*p != '\\') {
277  *pd++ = *p++;
278  continue;
279  }
280 
281  p++;
282 
283  switch(*p) {
284  case '\'':
285  case '\"':
286  case '\\':
287  c = *p;
288  break;
289  case 'b':
290  c = '\b';
291  break;
292  case 't':
293  c = '\t';
294  break;
295  case 'n':
296  c = '\n';
297  break;
298  case 'f':
299  c = '\f';
300  break;
301  case 'r':
302  c = '\r';
303  break;
304  case 'x':
305  i = hex_to_int(*++p);
306  if(i == -1)
307  return FALSE;
308  c = i << 4;
309 
310  i = hex_to_int(*++p);
311  if(i == -1)
312  return FALSE;
313  c += i;
314  break;
315  case 'u':
316  i = hex_to_int(*++p);
317  if(i == -1)
318  return FALSE;
319  c = i << 12;
320 
321  i = hex_to_int(*++p);
322  if(i == -1)
323  return FALSE;
324  c += i << 8;
325 
326  i = hex_to_int(*++p);
327  if(i == -1)
328  return FALSE;
329  c += i << 4;
330 
331  i = hex_to_int(*++p);
332  if(i == -1)
333  return FALSE;
334  c += i;
335  break;
336  default:
337  if(isdigitW(*p)) {
338  c = *p++ - '0';
339  if(isdigitW(*p)) {
340  c = c*8 + (*p++ - '0');
341  if(isdigitW(*p))
342  c = c*8 + (*p++ - '0');
343  }
344  p--;
345  }
346  else
347  c = *p;
348  }
349 
350  *pd++ = c;
351  p++;
352  }
353 
354  *pd = 0;
355  return TRUE;
356 }
#define TRUE
Definition: types.h:120
static int hex_to_int(WCHAR c)
Definition: lex.c:160
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
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
#define c
Definition: ke_i.h:80
GLfloat GLfloat p
Definition: glext.h:8902

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