MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript-max.js:7309–7338  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

7307 this.exposedFunctionNames = exposedFunctionNames;
7308 }
7309 static parse(parser) {
7310 var jsSourceStart = parser.currentToken().start;
7311 var jsLastToken = parser.currentToken();
7312 var funcNames = [];
7313 var funcName = "";
7314 var expectFunctionDeclaration = false;
7315 while (parser.hasMore()) {
7316 jsLastToken = parser.consumeToken();
7317 var peek = parser.token(0, true);
7318 if (peek.type === "IDENTIFIER" && peek.value === "end") {
7319 break;
7320 }
7321 if (expectFunctionDeclaration) {
7322 if (jsLastToken.type === "IDENTIFIER" || jsLastToken.type === "NUMBER") {
7323 funcName += jsLastToken.value;
7324 } else {
7325 if (funcName !== "") funcNames.push(funcName);
7326 funcName = "";
7327 expectFunctionDeclaration = false;
7328 }
7329 } else if (jsLastToken.type === "IDENTIFIER" && jsLastToken.value === "function") {
7330 expectFunctionDeclaration = true;
7331 }
7332 }
7333 var jsSourceEnd = jsLastToken.end + 1;
7334 return new _JsBody(
7335 parser.source.substring(jsSourceStart, jsSourceEnd),
7336 funcNames
7337 );
7338 }
7339 };
7340 var JsCommand = class _JsCommand extends Command {
7341 static keyword = "js";

Callers

nothing calls this directly

Calls 4

currentTokenMethod · 0.45
hasMoreMethod · 0.45
consumeTokenMethod · 0.45
tokenMethod · 0.45

Tested by

no test coverage detected