137 |
TOK_SEQ = 82, /* synthetic sequence of statements, |
TOK_SEQ = 82, /* synthetic sequence of statements, |
138 |
not a block */ |
not a block */ |
139 |
TOK_FORHEAD = 83, /* head of for(;;)-style loop */ |
TOK_FORHEAD = 83, /* head of for(;;)-style loop */ |
140 |
|
TOK_ARGSBODY = 84, /* formal args in list + body at end */ |
141 |
|
TOK_UPVARS = 85, /* lexical dependencies as JSAtomList |
142 |
|
of definitions paired with a parse |
143 |
|
tree full of uses of those names */ |
144 |
TOK_RESERVED, /* reserved keywords */ |
TOK_RESERVED, /* reserved keywords */ |
145 |
TOK_LIMIT /* domain size */ |
TOK_LIMIT /* domain size */ |
146 |
} JSTokenType; |
} JSTokenType; |
149 |
((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME)) |
((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME)) |
150 |
|
|
151 |
#define TOKEN_TYPE_IS_XML(tt) \ |
#define TOKEN_TYPE_IS_XML(tt) \ |
152 |
(tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME) |
((tt) == TOK_AT || (tt) == TOK_DBLCOLON || (tt) == TOK_ANYNAME) |
153 |
|
|
154 |
|
#define TREE_TYPE_IS_XML(tt) \ |
155 |
|
((tt) == TOK_XMLCOMMENT || (tt) == TOK_XMLCDATA || (tt) == TOK_XMLPI || \ |
156 |
|
(tt) == TOK_XMLELEM || (tt) == TOK_XMLLIST) |
157 |
|
|
158 |
#if JS_HAS_BLOCK_SCOPE |
#if JS_HAS_BLOCK_SCOPE |
159 |
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET) |
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET) |
180 |
extern void |
extern void |
181 |
js_FinishStringBuffer(JSStringBuffer *sb); |
js_FinishStringBuffer(JSStringBuffer *sb); |
182 |
|
|
183 |
|
static inline void |
184 |
|
js_RewindStringBuffer(JSStringBuffer *sb) |
185 |
|
{ |
186 |
|
JS_ASSERT(STRING_BUFFER_OK(sb)); |
187 |
|
sb->ptr = sb->base; |
188 |
|
} |
189 |
|
|
190 |
|
#define ENSURE_STRING_BUFFER(sb,n) \ |
191 |
|
((sb)->ptr + (n) <= (sb)->limit || sb->grow(sb, n)) |
192 |
|
|
193 |
|
/* |
194 |
|
* NB: callers are obligated to test STRING_BUFFER_OK(sb) after this returns, |
195 |
|
* before calling it again -- but not necessarily before calling other sb ops |
196 |
|
* declared in this header file. |
197 |
|
* |
198 |
|
* Thus multiple calls, to ops other than this one that check STRING_BUFFER_OK |
199 |
|
* and suppress updating sb if true, can consolidate the final STRING_BUFFER_OK |
200 |
|
* test that conditions a JS_ReportOutOfMemory (if necessary -- the grow hook |
201 |
|
* can report OOM early, obviating the need for the callers to report). |
202 |
|
* |
203 |
|
* This style of error checking is not obviously better, and it could be worse |
204 |
|
* in efficiency, than the propagated failure return code style used elsewhere |
205 |
|
* in the engine. I view it as a failed experiment. /be |
206 |
|
*/ |
207 |
|
static inline void |
208 |
|
js_FastAppendChar(JSStringBuffer *sb, jschar c) |
209 |
|
{ |
210 |
|
JS_ASSERT(STRING_BUFFER_OK(sb)); |
211 |
|
if (!ENSURE_STRING_BUFFER(sb, 1)) |
212 |
|
return; |
213 |
|
*sb->ptr++ = c; |
214 |
|
} |
215 |
|
|
216 |
extern void |
extern void |
217 |
js_AppendChar(JSStringBuffer *sb, jschar c); |
js_AppendChar(JSStringBuffer *sb, jschar c); |
218 |
|
|
229 |
js_AppendJSString(JSStringBuffer *sb, JSString *str); |
js_AppendJSString(JSStringBuffer *sb, JSString *str); |
230 |
|
|
231 |
struct JSTokenPtr { |
struct JSTokenPtr { |
232 |
uint16 index; /* index of char in physical line */ |
uint32 index; /* index of char in physical line */ |
233 |
uint16 lineno; /* physical line number */ |
uint32 lineno; /* physical line number */ |
234 |
|
|
235 |
|
bool operator <(const JSTokenPtr& bptr) { |
236 |
|
return lineno < bptr.lineno || |
237 |
|
(lineno == bptr.lineno && index < bptr.index); |
238 |
|
} |
239 |
|
|
240 |
|
bool operator <=(const JSTokenPtr& bptr) { |
241 |
|
return lineno < bptr.lineno || |
242 |
|
(lineno == bptr.lineno && index <= bptr.index); |
243 |
|
} |
244 |
|
|
245 |
|
bool operator >(const JSTokenPtr& bptr) { |
246 |
|
return !(*this <= bptr); |
247 |
|
} |
248 |
|
|
249 |
|
bool operator >=(const JSTokenPtr& bptr) { |
250 |
|
return !(*this < bptr); |
251 |
|
} |
252 |
}; |
}; |
253 |
|
|
254 |
struct JSTokenPos { |
struct JSTokenPos { |
255 |
JSTokenPtr begin; /* first character and line of token */ |
JSTokenPtr begin; /* first character and line of token */ |
256 |
JSTokenPtr end; /* index 1 past last char, last line */ |
JSTokenPtr end; /* index 1 past last char, last line */ |
257 |
|
|
258 |
|
bool operator <(const JSTokenPos& bpos) { |
259 |
|
return begin < bpos.begin; |
260 |
|
} |
261 |
|
|
262 |
|
bool operator <=(const JSTokenPos& bpos) { |
263 |
|
return begin <= bpos.begin; |
264 |
|
} |
265 |
|
|
266 |
|
bool operator >(const JSTokenPos& bpos) { |
267 |
|
return !(*this <= bpos); |
268 |
|
} |
269 |
|
|
270 |
|
bool operator >=(const JSTokenPos& bpos) { |
271 |
|
return !(*this < bpos); |
272 |
|
} |
273 |
}; |
}; |
274 |
|
|
275 |
struct JSToken { |
struct JSToken { |
316 |
uintN ungetpos; /* next free char slot in ungetbuf */ |
uintN ungetpos; /* next free char slot in ungetbuf */ |
317 |
jschar ungetbuf[6]; /* at most 6, for \uXXXX lookahead */ |
jschar ungetbuf[6]; /* at most 6, for \uXXXX lookahead */ |
318 |
uintN flags; /* flags -- see below */ |
uintN flags; /* flags -- see below */ |
319 |
ptrdiff_t linelen; /* physical linebuf segment length */ |
uint32 linelen; /* physical linebuf segment length */ |
320 |
ptrdiff_t linepos; /* linebuf offset in physical line */ |
uint32 linepos; /* linebuf offset in physical line */ |
321 |
JSTokenBuf linebuf; /* line buffer for diagnostics */ |
JSTokenBuf linebuf; /* line buffer for diagnostics */ |
322 |
JSTokenBuf userbuf; /* user input buffer if !file */ |
JSTokenBuf userbuf; /* user input buffer if !file */ |
323 |
JSStringBuffer tokenbuf; /* current token string buffer */ |
JSStringBuffer tokenbuf; /* current token string buffer */ |
373 |
/* Ignore keywords and return TOK_NAME instead to the parser. */ |
/* Ignore keywords and return TOK_NAME instead to the parser. */ |
374 |
#define TSF_KEYWORD_IS_NAME 0x4000 |
#define TSF_KEYWORD_IS_NAME 0x4000 |
375 |
|
|
376 |
|
/* Parsing a destructuring object or array initialiser pattern. */ |
377 |
|
#define TSF_DESTRUCTURING 0x8000 |
378 |
|
|
379 |
/* Unicode separators that are treated as line terminators, in addition to \n, \r */ |
/* Unicode separators that are treated as line terminators, in addition to \n, \r */ |
380 |
#define LINE_SEPARATOR 0x2028 |
#define LINE_SEPARATOR 0x2028 |
381 |
#define PARA_SEPARATOR 0x2029 |
#define PARA_SEPARATOR 0x2029 |