(parser)
| 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; |
nothing calls this directly
no test coverage detected