ReactOS  0.4.14-dev-554-g2f8d847
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  {
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 72 of file parser.h.

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

◆ 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  {
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().

◆ compiler_alloc_string_len()

jsstr_t* compiler_alloc_string_len ( struct _compiler_ctx_t ,
const WCHAR ,
unsigned   
)

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 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
Definition: jsstr.h:39
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722

Referenced by compiler_alloc_string(), parse_regexp(), parse_string_literal(), 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 81 of file lex.c.

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

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 ,
BOOL   
)

Definition at line 387 of file lex.c.

388 {
389  literal_t *ret = parser_alloc(ctx, sizeof(literal_t));
390 
391  ret->type = LT_BOOL;
392  ret->u.bval = bval;
393 
394  return ret;
395 }
Definition: parser.h:75
int ret
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:58
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 1841 of file cc_parser.tab.c.

1842 {
1843  ctx->hres = S_OK;
1844  cc_parser_parse(ctx);
1845  return SUCCEEDED(ctx->hres);
1846 }
#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 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");
465  return JS_E_MISSING_SEMICOLON;
466  }
467 
468  *ret = exp>=0 ? d*pow(10, exp) : d/pow(10, -exp);
469  *iter = ptr;
470  return S_OK;
471 }
static size_t double int int int * sign
Definition: printf.c:69
#define INT_MAX
Definition: limits.h:40
BOOL is_identifier_char(WCHAR c)
Definition: lex.c:81
#define iswdigit(_c)
Definition: ctype.h:667
#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:537
int ret
#define INT_MIN
Definition: limits.h:39
#define S_OK
Definition: intsafe.h:59
DWORD exp
Definition: msg.c:16038

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

◆ parse_regexp()

literal_t* parse_regexp ( parser_ctx_t )

Definition at line 1115 of file lex.c.

1116 {
1117  const WCHAR *re, *flags_ptr;
1118  BOOL in_class = FALSE;
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 }
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
#define iswalnum(_c)
Definition: ctype.h:671
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
jsstr_t * compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len)
Definition: compile.c:133
static void * parser_alloc(parser_ctx_t *ctx, DWORD size)
Definition: parser.h:58

Referenced by yyparse().

◆ 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 }
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:77
heap_pool_t heap
Definition: parse.h:276
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 63 of file parser.h.

64 {
65  return heap_pool_alloc(&ctx->script->tmp_heap, size);
66 }
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN
Definition: jsutils.c:77
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 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
int ret
static int next_token(parser_ctx_t *ctx, void *lval)
Definition: lex.c:546

◆ parser_release()

void parser_release ( parser_ctx_t )

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

4362 {
4363  script_release(ctx->script);
4364  heap_pool_free(&ctx->heap);
4365  heap_free(ctx);
4366 }
void script_release(script_ctx_t *ctx)
Definition: jscript.c:67
void heap_pool_free(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:169
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 ,
struct _compiler_ctx_t ,
const WCHAR ,
const WCHAR ,
BOOL  ,
parser_ctx_t **   
)

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

4370 {
4371  parser_ctx_t *parser_ctx;
4372  heap_pool_t *mark;
4373  HRESULT hres;
4374 
4375  const WCHAR html_tagW[] = {'<','/','s','c','r','i','p','t','>',0};
4376 
4377  parser_ctx = heap_alloc_zero(sizeof(parser_ctx_t));
4378  if(!parser_ctx)
4379  return E_OUTOFMEMORY;
4380 
4381  parser_ctx->hres = JS_E_SYNTAX;
4382  parser_ctx->is_html = delimiter && !wcsicmp(delimiter, html_tagW);
4383 
4384  parser_ctx->begin = parser_ctx->ptr = code;
4385  parser_ctx->end = parser_ctx->begin + lstrlenW(parser_ctx->begin);
4386 
4387  script_addref(ctx);
4388  parser_ctx->script = ctx;
4389 
4390  mark = heap_pool_mark(&ctx->tmp_heap);
4391  heap_pool_init(&parser_ctx->heap);
4392 
4393  parser_ctx->compiler = compiler;
4394  parser_parse(parser_ctx);
4395  parser_ctx->compiler = NULL;
4396 
4397  heap_pool_clear(mark);
4398  hres = parser_ctx->hres;
4399  if(FAILED(hres)) {
4400  WARN("parser failed around %s\n",
4401  debugstr_w(parser_ctx->begin+20 > parser_ctx->ptr ? parser_ctx->begin : parser_ctx->ptr-20));
4402  parser_release(parser_ctx);
4403  return hres;
4404  }
4405 
4406  *ret = parser_ctx;
4407  return S_OK;
4408 }
#define WARN(fmt,...)
Definition: debug.h:111
void parser_release(parser_ctx_t *ctx)
Definition: parser.tab.c:4361
#define lstrlenW
Definition: compat.h:415
#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:261
smooth NULL
Definition: ftsmooth.c:416
const char * delimiter
Definition: string.c:1566
heap_pool_t heap
Definition: parse.h:276
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:262
int code
Definition: i386-dis.c:3591
void heap_pool_init(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:71
#define wcsicmp
Definition: string.h:1152
#define S_OK
Definition: intsafe.h:59
static void script_addref(script_ctx_t *ctx)
Definition: jscript.h:465
#define JS_E_SYNTAX
Definition: jscript.h:536
HRESULT hres
Definition: parse.h:267
BOOL is_html
Definition: parse.h:266
heap_pool_t * heap_pool_mark(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:182
void heap_pool_clear(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:146

Referenced by compile_script().

◆ try_parse_ccval()

BOOL try_parse_ccval ( parser_ctx_t ,
ccval_t  
)

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 
915  if(!parse_numeric_literal(ctx, &n))
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 
927  if(!parse_cc_identifier(ctx, &ident, &ident_len))
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 }
#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:848
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define iswdigit(_c)
Definition: ctype.h:667
GLdouble n
Definition: glext.h:7729
static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret)
Definition: lex.c:473
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:811
#define NAN
Definition: misc.c:46
static const WCHAR L[]
Definition: oid.c:1250
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:889
Definition: lex.c:810
static BOOL skip_spaces(parser_ctx_t *ctx)
Definition: lex.c:217
static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval)
Definition: lex.c:91

Referenced by cc_parser_lex().

◆ unescape()

BOOL unescape ( WCHAR ,
size_t  
)

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 }
#define TRUE
Definition: types.h:120
static int hex_to_int(WCHAR c)
Definition: lex.c:118
#define iswdigit(_c)
Definition: ctype.h:667
GLuint GLuint end
Definition: gl.h:1545
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
GLenum GLsizei len
Definition: glext.h:6722
#define c
Definition: ke_i.h:80
GLfloat GLfloat p
Definition: glext.h:8902

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