UNPKG

siphon-cli

Version:

Simple bundler for web applications. 📦🔧🧡

135 lines (134 loc) • 5.09 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var types_1 = require("../../../../types"); var utils_1 = require("../../../../utils"); var base_1 = require("./base"); base_1.ezra.reparse = function (node, context) { if ((0, types_1.isValidExpression)(node)) { var pos = this.i; this.outerspace(); switch (true) { case this.eat("//"): case this.eat("/*"): this.skip(); break; case this.text[this.i] === ",": if (this.requireComma()) { return node; } else { this.belly.push(this.text[this.i++]); return this.sequenceExpression(node); } case this.eat("."): case this.eat("?."): if (context === "number") this.raise("ID_FOLLOWS_LITERAL"); case this.eat("["): return this.memberExpression(node); case this.text[this.i] === "(": if (this.contexts.top() === "new") return node; else return this.callExpression(node); case this.eat("++"): case this.eat("--"): if (/\n/.test(this.text.slice(pos, this.i))) { this.belly.pop(); this.i = pos; return node; } else { return this.updateExpression(node, false); } case this.eat("=>"): return this.arrowFunctionExpression(node); case this.eat(">>="): case this.eat(">>>="): case this.eat("**="): case this.eat("<<="): case this.eat("&&="): case this.eat("||="): case this.eat("??="): case this.eat("*="): case this.eat("+="): case this.eat("-="): case this.eat("/="): case this.eat("%="): case this.eat("&="): case this.eat("^="): case this.eat("|="): return this.assignmentExpression(node); case this.eat("&&"): case this.eat("||"): case this.eat("??"): return this.logicalExpression(node); case this.match("of"): var arr = __assign({}, this.contexts).arr; if (!arr.includes("for_params")) this.raise("JS_UNEXP_KEYWORD_OR_IDENTIFIER"); case this.eat("**"): case this.eat("*"): case this.eat("/"): case this.eat("%"): case this.eat("+"): case this.eat("-"): case this.eat(">>>"): case this.eat("<<"): case this.eat(">>"): case this.eat("<="): case this.eat(">="): case this.eat(">"): case this.eat("<"): case this.match("instanceof"): case this.match("in"): case this.eat("==="): case this.eat("!=="): case this.eat("=="): case this.eat("!="): case this.eat("&"): case this.eat("|"): case this.eat("^"): return this.binaryExpression(node); case this.eat("?"): return this.conditionalExpression(node); case this.eat("="): return this.assignmentExpression(node); case this.text[this.i] === "{": if (this.contexts.top() === "super_class") { this.recede(); return node; } case (0, utils_1.isValidIdentifierCharacter)(this.text[this.i]): case /'|`|"/.test(this.text[this.i]): case (0, utils_1.isDigit)(this.text[this.i]): if (/\n/.test(this.text.slice(pos, this.i))) { this.i = pos; return node; } else { this.raise("JS_UNEXP_KEYWORD_OR_IDENTIFIER"); } } if ((0, types_1.isChainExpression)(node) || (node instanceof types_1.CallExpression && (0, types_1.isChainExpression)(node.callee))) { return this.chainExpression(node); } if (this.text[this.i] === ";") return node; } if (node === undefined) this.raise("EXPRESSION_EXPECTED"); return node; };