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

Method parse

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

Source from the content-addressed store, hash-verified

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