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