(code, options)
| 4328 | } |
| 4329 | |
| 4330 | function tokenize(code, options) { |
| 4331 | var toString, |
| 4332 | tokens; |
| 4333 | |
| 4334 | toString = String; |
| 4335 | if (typeof code !== 'string' && !(code instanceof String)) { |
| 4336 | code = toString(code); |
| 4337 | } |
| 4338 | |
| 4339 | source = code; |
| 4340 | index = 0; |
| 4341 | lineNumber = (source.length > 0) ? 1 : 0; |
| 4342 | lineStart = 0; |
| 4343 | startIndex = index; |
| 4344 | startLineNumber = lineNumber; |
| 4345 | startLineStart = lineStart; |
| 4346 | length = source.length; |
| 4347 | lookahead = null; |
| 4348 | state = { |
| 4349 | allowIn: true, |
| 4350 | labelSet: {}, |
| 4351 | inFunctionBody: false, |
| 4352 | inIteration: false, |
| 4353 | inSwitch: false, |
| 4354 | lastCommentStart: -1 |
| 4355 | }; |
| 4356 | |
| 4357 | extra = {}; |
| 4358 | |
| 4359 | // Options matching. |
| 4360 | options = options || {}; |
| 4361 | |
| 4362 | // Of course we collect tokens here. |
| 4363 | options.tokens = true; |
| 4364 | extra.tokens = []; |
| 4365 | extra.tokenize = true; |
| 4366 | // The following two fields are necessary to compute the Regex tokens. |
| 4367 | extra.openParenToken = -1; |
| 4368 | extra.openCurlyToken = -1; |
| 4369 | |
| 4370 | extra.range = (typeof options.range === 'boolean') && options.range; |
| 4371 | extra.loc = (typeof options.loc === 'boolean') && options.loc; |
| 4372 | |
| 4373 | if (typeof options.comment === 'boolean' && options.comment) { |
| 4374 | extra.comments = []; |
| 4375 | } |
| 4376 | if (typeof options.tolerant === 'boolean' && options.tolerant) { |
| 4377 | extra.errors = []; |
| 4378 | } |
| 4379 | |
| 4380 | try { |
| 4381 | peek(); |
| 4382 | if (lookahead.type === Token.EOF) { |
| 4383 | return extra.tokens; |
| 4384 | } |
| 4385 | |
| 4386 | lex(); |
| 4387 | while (lookahead.type !== Token.EOF) { |
nothing calls this directly
no test coverage detected