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

Method parse

tools/common/_hyperscript.iife.js:7215–7260  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

7213 }
7214 }
7215 static parse(parser) {
7216 if (!parser.matchToken("add")) return;
7217 var classRef = parser.parseElement("classRef");
7218 var attributeRef = null;
7219 var cssDeclaration = null;
7220 var valueExpr = null;
7221 if (classRef == null) {
7222 attributeRef = parser.parseElement("attributeRef");
7223 if (attributeRef == null) {
7224 cssDeclaration = parser.parseElement("styleLiteral");
7225 if (cssDeclaration == null) {
7226 parser.pushFollow("to");
7227 try {
7228 valueExpr = parser.parseElement("expression");
7229 } finally {
7230 parser.popFollow();
7231 }
7232 if (valueExpr == null || !parser.currentToken() || parser.currentToken().value !== "to") {
7233 parser.raiseError("Expected either a class reference or attribute expression");
7234 }
7235 }
7236 }
7237 } else {
7238 var classRefs = [classRef];
7239 while (classRef = parser.parseElement("classRef")) {
7240 classRefs.push(classRef);
7241 }
7242 }
7243 if (parser.matchToken("to")) {
7244 var toExpr = parser.requireElement("expression");
7245 } else {
7246 var toExpr = parser.requireElement("implicitMeTarget");
7247 }
7248 if (parser.matchToken("when")) {
7249 var when = parser.requireElement("expression");
7250 }
7251 if (classRefs) {
7252 return new _AddCommand("class", classRefs, null, null, toExpr, when);
7253 } else if (attributeRef) {
7254 return new _AddCommand("attribute", null, attributeRef, null, toExpr, when);
7255 } else if (cssDeclaration) {
7256 return new _AddCommand("css", null, null, cssDeclaration, toExpr, null);
7257 } else {
7258 return new _AddCommand("collection", null, null, null, toExpr, null, valueExpr);
7259 }
7260 }
7261 resolve(context, { to, classRefs, css, value }) {
7262 var runtime2 = context.meta.runtime;
7263 var cmd = this;

Callers

nothing calls this directly

Calls 7

matchTokenMethod · 0.45
parseElementMethod · 0.45
pushFollowMethod · 0.45
popFollowMethod · 0.45
currentTokenMethod · 0.45
raiseErrorMethod · 0.45
requireElementMethod · 0.45

Tested by

no test coverage detected