(code, options)
| 9890 | } |
| 9891 | |
| 9892 | function parse(code, options) { |
| 9893 | var program, toString; |
| 9894 | |
| 9895 | toString = String; |
| 9896 | if (typeof code !== 'string' && !(code instanceof String)) { |
| 9897 | code = toString(code); |
| 9898 | } |
| 9899 | |
| 9900 | delegate = SyntaxTreeDelegate; |
| 9901 | source = code; |
| 9902 | index = 0; |
| 9903 | lineNumber = (source.length > 0) ? 1 : 0; |
| 9904 | lineStart = 0; |
| 9905 | length = source.length; |
| 9906 | lookahead = null; |
| 9907 | state = { |
| 9908 | allowKeyword: false, |
| 9909 | allowIn: true, |
| 9910 | labelSet: new StringMap(), |
| 9911 | parenthesizedCount: 0, |
| 9912 | inFunctionBody: false, |
| 9913 | inIteration: false, |
| 9914 | inSwitch: false, |
| 9915 | inJSXChild: false, |
| 9916 | inJSXTag: false, |
| 9917 | inType: false, |
| 9918 | lastCommentStart: -1, |
| 9919 | yieldAllowed: false, |
| 9920 | awaitAllowed: false |
| 9921 | }; |
| 9922 | |
| 9923 | extra = {}; |
| 9924 | if (typeof options !== 'undefined') { |
| 9925 | extra.range = (typeof options.range === 'boolean') && options.range; |
| 9926 | extra.loc = (typeof options.loc === 'boolean') && options.loc; |
| 9927 | extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; |
| 9928 | |
| 9929 | if (extra.loc && options.source !== null && options.source !== undefined) { |
| 9930 | delegate = extend(delegate, { |
| 9931 | 'postProcess': function (node) { |
| 9932 | node.loc.source = toString(options.source); |
| 9933 | return node; |
| 9934 | } |
| 9935 | }); |
| 9936 | } |
| 9937 | |
| 9938 | extra.sourceType = options.sourceType; |
| 9939 | if (typeof options.tokens === 'boolean' && options.tokens) { |
| 9940 | extra.tokens = []; |
| 9941 | } |
| 9942 | if (typeof options.comment === 'boolean' && options.comment) { |
| 9943 | extra.comments = []; |
| 9944 | } |
| 9945 | if (typeof options.tolerant === 'boolean' && options.tolerant) { |
| 9946 | extra.errors = []; |
| 9947 | } |
| 9948 | if (extra.attachComment) { |
| 9949 | extra.range = true; |
no test coverage detected