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

Method parse

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

Source from the content-addressed store, hash-verified

9304 }
9305 }
9306 static parse(parser) {
9307 if (!parser.matchToken("on")) return;
9308 var every = false;
9309 var first = false;
9310 if (parser.matchToken("every")) {
9311 every = true;
9312 } else if (parser.matchToken("first")) {
9313 first = true;
9314 }
9315 var events = [];
9316 var displayName = null;
9317 do {
9318 var on = parser.requireElement("eventName", "Expected event name");
9319 var eventName = on.evalStatically();
9320 if (displayName) {
9321 displayName = displayName + " or " + eventName;
9322 } else {
9323 displayName = "on " + eventName;
9324 }
9325 var args = ParseElement.parseEventArgs(parser);
9326 var filter = null;
9327 if (parser.matchOpToken("[")) {
9328 filter = parser.requireElement("expression");
9329 parser.requireOpToken("]");
9330 }
9331 var startCount, endCount, unbounded;
9332 if (first) {
9333 startCount = 1;
9334 } else if (parser.currentToken().type === "NUMBER") {
9335 var startCountToken = parser.consumeToken();
9336 if (!startCountToken.value) return;
9337 startCount = parseInt(startCountToken.value);
9338 if (parser.matchToken("to")) {
9339 var endCountToken = parser.consumeToken();
9340 if (!endCountToken.value) return;
9341 endCount = parseInt(endCountToken.value);
9342 } else if (parser.matchToken("and")) {
9343 unbounded = true;
9344 parser.requireToken("on");
9345 }
9346 }
9347 var intersectionSpec, mutationSpec, resizeSpec;
9348 if (eventName === "resize") {
9349 resizeSpec = true;
9350 } else if (eventName === "intersection") {
9351 intersectionSpec = {};
9352 if (parser.matchToken("with")) {
9353 intersectionSpec["with"] = parser.requireElement("expression").evalStatically();
9354 }
9355 if (parser.matchToken("having")) {
9356 do {
9357 if (parser.matchToken("margin")) {
9358 intersectionSpec["rootMargin"] = parser.requireElement("stringLike").evalStatically();
9359 } else if (parser.matchToken("threshold")) {
9360 intersectionSpec["threshold"] = parser.requireElement("expression").evalStatically();
9361 } else {
9362 parser.raiseError("Unknown intersection config specification");
9363 }

Callers

nothing calls this directly

Calls 15

matchTokenMethod · 0.45
requireElementMethod · 0.45
evalStaticallyMethod · 0.45
parseEventArgsMethod · 0.45
matchOpTokenMethod · 0.45
requireOpTokenMethod · 0.45
currentTokenMethod · 0.45
consumeTokenMethod · 0.45
requireTokenMethod · 0.45
raiseErrorMethod · 0.45
pushFollowMethod · 0.45
popFollowMethod · 0.45

Tested by

no test coverage detected