MCPcopy Create free account
hub / github.com/node-inspector/node-inspector / tokenizer

Function tokenizer

front-end/UglifyJS/parse-js.js:255–547  ·  view source on GitHub ↗
($TEXT)

Source from the content-addressed store, hash-verified

253var EX_EOF = {};
254
255function tokenizer($TEXT) {
256
257 var S = {
258 text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
259 pos : 0,
260 tokpos : 0,
261 line : 0,
262 tokline : 0,
263 col : 0,
264 tokcol : 0,
265 newline_before : false,
266 regex_allowed : false,
267 comments_before : []
268 };
269
270 function peek() { return S.text.charAt(S.pos); };
271
272 function next(signal_eof) {
273 var ch = S.text.charAt(S.pos++);
274 if (signal_eof && !ch)
275 throw EX_EOF;
276 if (ch == "\n") {
277 S.newline_before = true;
278 ++S.line;
279 S.col = 0;
280 } else {
281 ++S.col;
282 }
283 return ch;
284 };
285
286 function eof() {
287 return !S.peek();
288 };
289
290 function find(what, signal_eof) {
291 var pos = S.text.indexOf(what, S.pos);
292 if (signal_eof && pos == -1) throw EX_EOF;
293 return pos;
294 };
295
296 function start_token() {
297 S.tokline = S.line;
298 S.tokcol = S.col;
299 S.tokpos = S.pos;
300 };
301
302 function token(type, value, is_comment) {
303 S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) ||
304 (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
305 (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
306 var ret = {
307 type : type,
308 value : value,
309 line : S.tokline,
310 col : S.tokcol,
311 pos : S.tokpos,
312 nlb : S.newline_before

Callers 2

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…