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

Method parse

www/js/_hyperscript.js:7027–7050  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

7025 this.args = { value: expr };
7026 }
7027 static parse(parser) {
7028 if (!parser.matchToken("if")) return;
7029 var expr = parser.requireElement("expression");
7030 parser.matchToken("then");
7031 var trueBranch = parser.parseElement("commandList");
7032 var nestedIfStmt = false;
7033 let elseToken = parser.matchToken("else") || parser.matchToken("otherwise");
7034 if (elseToken) {
7035 let elseIfIfToken = parser.peekToken("if");
7036 nestedIfStmt = elseIfIfToken != null && elseIfIfToken.line === elseToken.line;
7037 if (nestedIfStmt) {
7038 var falseBranch = parser.parseElement("command");
7039 } else {
7040 var falseBranch = parser.parseElement("commandList");
7041 }
7042 }
7043 if (parser.hasMore() && !nestedIfStmt) {
7044 parser.requireToken("end");
7045 }
7046 var ifCmd = new _IfCommand(expr, trueBranch, falseBranch);
7047 parser.setParent(trueBranch, ifCmd);
7048 parser.setParent(falseBranch, ifCmd);
7049 return ifCmd;
7050 }
7051 resolve(context, { value: exprValue }) {
7052 if (exprValue) {
7053 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