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

Method parse

www/js/_hyperscript.esm.js:7308–7337  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

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