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

Method parse

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

Source from the content-addressed store, hash-verified

4546 this.args = { lhs, rhs };
4547 }
4548 static parse(parser) {
4549 var expr = parser.parseElement("collectionExpression");
4550 var mathOp, initialMathOp = null;
4551 mathOp = parser.matchAnyOpToken("+", "-", "*", "/") || parser.matchToken("mod");
4552 while (mathOp) {
4553 initialMathOp = initialMathOp || mathOp;
4554 var operator = mathOp.value;
4555 if (initialMathOp.value !== operator) {
4556 parser.raiseError("You must parenthesize math operations with different operators");
4557 }
4558 var rhs = parser.parseElement("collectionExpression");
4559 expr = new _MathOperator(expr, operator, rhs);
4560 mathOp = parser.matchAnyOpToken("+", "-", "*", "/") || parser.matchToken("mod");
4561 }
4562 return expr;
4563 }
4564 resolve(context, { lhs: lhsVal, rhs: rhsVal }) {
4565 if (this.operator === "+") {
4566 if (Array.isArray(lhsVal)) return lhsVal.concat(rhsVal);

Callers

nothing calls this directly

Calls 4

parseElementMethod · 0.45
matchAnyOpTokenMethod · 0.45
matchTokenMethod · 0.45
raiseErrorMethod · 0.45

Tested by

no test coverage detected