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

Method parse

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

Source from the content-addressed store, hash-verified

7420 }
7421 }
7422 static parse(parser) {
7423 let lookAhead = parser.token(1);
7424 if (!(lookAhead && lookAhead.op && (lookAhead.value === "." || lookAhead.value === "("))) {
7425 return null;
7426 }
7427 var expr = parser.requireElement("primaryExpression");
7428 var rootRoot = expr.root;
7429 var root = expr;
7430 while (rootRoot.root != null) {
7431 root = root.root;
7432 rootRoot = rootRoot.root;
7433 }
7434 if (expr.type !== "functionCall") {
7435 parser.raiseError("Pseudo-commands must be function calls");
7436 }
7437 if (root.type === "functionCall" && root.root.root == null) {
7438 if (parser.matchAnyToken("the", "to", "on", "with", "into", "from", "at")) {
7439 var realRoot = parser.requireElement("expression");
7440 } else if (parser.matchToken("me")) {
7441 var realRoot = parser.requireElement("implicitMeTarget");
7442 }
7443 }
7444 if (realRoot) {
7445 return new _PseudoCommand("target", expr, realRoot, root);
7446 } else {
7447 return new _PseudoCommand("simple", expr, null, null);
7448 }
7449 }
7450 resolve(context, { target, argVals, result }) {
7451 if (this.variant === "target") {
7452 context.meta.runtime.nullCheck(target, this._realRoot);

Callers

nothing calls this directly

Calls 5

tokenMethod · 0.45
requireElementMethod · 0.45
raiseErrorMethod · 0.45
matchAnyTokenMethod · 0.45
matchTokenMethod · 0.45

Tested by

no test coverage detected