MCPcopy
hub / github.com/livebud/bud / Parser

Function Parser

package/svelte/compiler.js:425–472  ·  view source on GitHub ↗
(options, input, startPos)

Source from the content-addressed store, hash-verified

423 var BIND_SIMPLE_CATCH = 4;
424 var BIND_OUTSIDE = 5;
425 var Parser = function Parser2(options, input, startPos) {
426 this.options = options = getOptions(options);
427 this.sourceFile = options.sourceFile;
428 this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
429 var reserved2 = "";
430 if (options.allowReserved !== true) {
431 reserved2 = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
432 if (options.sourceType === "module") {
433 reserved2 += " await";
434 }
435 }
436 this.reservedWords = wordsRegexp(reserved2);
437 var reservedStrict = (reserved2 ? reserved2 + " " : "") + reservedWords.strict;
438 this.reservedWordsStrict = wordsRegexp(reservedStrict);
439 this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
440 this.input = String(input);
441 this.containsEsc = false;
442 if (startPos) {
443 this.pos = startPos;
444 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
445 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
446 } else {
447 this.pos = this.lineStart = 0;
448 this.curLine = 1;
449 }
450 this.type = types.eof;
451 this.value = null;
452 this.start = this.end = this.pos;
453 this.startLoc = this.endLoc = this.curPosition();
454 this.lastTokEndLoc = this.lastTokStartLoc = null;
455 this.lastTokStart = this.lastTokEnd = this.pos;
456 this.context = this.initialContext();
457 this.exprAllowed = true;
458 this.inModule = options.sourceType === "module";
459 this.strict = this.inModule || this.strictDirective(this.pos);
460 this.potentialArrowAt = -1;
461 this.potentialArrowInForAwait = false;
462 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
463 this.labels = [];
464 this.undefinedExports = /* @__PURE__ */ Object.create(null);
465 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
466 this.skipLineComment(2);
467 }
468 this.scopeStack = [];
469 this.enterScope(SCOPE_TOP);
470 this.regexpState = null;
471 this.privateNameStack = [];
472 };
473 var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, inNonArrowFunction: { configurable: true } };
474 Parser.prototype.parse = function parse() {
475 var node2 = this.options.program || this.startNode();

Callers

nothing calls this directly

Calls 3

getOptionsFunction · 0.85
wordsRegexpFunction · 0.85
StringStruct · 0.50

Tested by

no test coverage detected