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

Method parse

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

Source from the content-addressed store, hash-verified

6637 this.args = { value: expr };
6638 }
6639 static parse(parser) {
6640 if (!parser.matchToken("if")) return;
6641 var expr = parser.requireElement("expression");
6642 parser.matchToken("then");
6643 var trueBranch = parser.parseElement("commandList");
6644 var nestedIfStmt = false;
6645 let elseToken = parser.matchToken("else") || parser.matchToken("otherwise");
6646 if (elseToken) {
6647 let elseIfIfToken = parser.peekToken("if");
6648 nestedIfStmt = elseIfIfToken != null && elseIfIfToken.line === elseToken.line;
6649 if (nestedIfStmt) {
6650 var falseBranch = parser.parseElement("command");
6651 } else {
6652 var falseBranch = parser.parseElement("commandList");
6653 }
6654 }
6655 if (parser.hasMore() && !nestedIfStmt) {
6656 parser.requireToken("end");
6657 }
6658 var ifCmd = new _IfCommand(expr, trueBranch, falseBranch);
6659 parser.setParent(trueBranch, ifCmd);
6660 parser.setParent(falseBranch, ifCmd);
6661 return ifCmd;
6662 }
6663 resolve(context, { value: exprValue }) {
6664 if (exprValue) {
6665 return this.trueBranch;

Callers

nothing calls this directly

Calls 7

matchTokenMethod · 0.45
requireElementMethod · 0.45
parseElementMethod · 0.45
peekTokenMethod · 0.45
hasMoreMethod · 0.45
requireTokenMethod · 0.45
setParentMethod · 0.45

Tested by

no test coverage detected