[loose parser] Ignore shebang lines

Closes marijnh/tern#408
This commit is contained in:
Marijn Haverbeke 2014-10-21 12:35:06 +02:00
parent ad69446c0a
commit 437ce2d9be

View File

@ -43,9 +43,11 @@
exports.parse_dammit = function(inpt, opts) { exports.parse_dammit = function(inpt, opts) {
if (!opts) opts = {}; if (!opts) opts = {};
input = String(inpt); input = String(inpt);
if (/^#!.*/.test(input)) input = "//" + input.slice(2);
options = opts; options = opts;
if (!opts.tabSize) opts.tabSize = 4; if (!opts.tabSize) opts.tabSize = 4;
fetchToken = acorn.tokenize(inpt, opts); fetchToken = acorn.tokenize(input, opts);
sourceFile = options.sourceFile || null; sourceFile = options.sourceFile || null;
context = []; context = [];
nextLineStart = 0; nextLineStart = 0;