MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

www/js/_hyperscript.js:7310–7339  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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