(code, options)
| 4416 | } |
| 4417 | |
| 4418 | function parse(code, options) { |
| 4419 | var program, toString; |
| 4420 | |
| 4421 | toString = String; |
| 4422 | if (typeof code !== 'string' && !(code instanceof String)) { |
| 4423 | code = toString(code); |
| 4424 | } |
| 4425 | |
| 4426 | source = code; |
| 4427 | index = 0; |
| 4428 | lineNumber = (source.length > 0) ? 1 : 0; |
| 4429 | lineStart = 0; |
| 4430 | startIndex = index; |
| 4431 | startLineNumber = lineNumber; |
| 4432 | startLineStart = lineStart; |
| 4433 | length = source.length; |
| 4434 | lookahead = null; |
| 4435 | state = { |
| 4436 | allowIn: true, |
| 4437 | labelSet: {}, |
| 4438 | inFunctionBody: false, |
| 4439 | inIteration: false, |
| 4440 | inSwitch: false, |
| 4441 | lastCommentStart: -1 |
| 4442 | }; |
| 4443 | |
| 4444 | extra = {}; |
| 4445 | if (typeof options !== 'undefined') { |
| 4446 | extra.range = (typeof options.range === 'boolean') && options.range; |
| 4447 | extra.loc = (typeof options.loc === 'boolean') && options.loc; |
| 4448 | extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; |
| 4449 | |
| 4450 | if (extra.loc && options.source !== null && options.source !== undefined) { |
| 4451 | extra.source = toString(options.source); |
| 4452 | } |
| 4453 | |
| 4454 | if (typeof options.tokens === 'boolean' && options.tokens) { |
| 4455 | extra.tokens = []; |
| 4456 | } |
| 4457 | if (typeof options.comment === 'boolean' && options.comment) { |
| 4458 | extra.comments = []; |
| 4459 | } |
| 4460 | if (typeof options.tolerant === 'boolean' && options.tolerant) { |
| 4461 | extra.errors = []; |
| 4462 | } |
| 4463 | if (extra.attachComment) { |
| 4464 | extra.range = true; |
| 4465 | extra.comments = []; |
| 4466 | extra.bottomRightStack = []; |
| 4467 | extra.trailingComments = []; |
| 4468 | extra.leadingComments = []; |
| 4469 | } |
| 4470 | } |
| 4471 | |
| 4472 | try { |
| 4473 | program = parseProgram(); |
| 4474 | if (typeof extra.comments !== 'undefined') { |
| 4475 | program.comments = extra.comments; |
nothing calls this directly
no test coverage detected