MCPcopy Create free account
hub / github.com/BaseXdb/basex / iff

Method iff

basex-core/src/main/java/org/basex/query/QueryParser.java:1658–1684  ·  view source on GitHub ↗

Parses the "IfExpr" rule. @return query expression or null @throws QueryException query exception

()

Source from the content-addressed store, hash-verified

1656 * @throws QueryException query exception
1657 */
1658 private Expr iff() throws QueryException {
1659 if(!wsConsumeWs(IF, IFPAR, "(")) return null;
1660
1661 final LinkedList<InputInfo> infos = new LinkedList<>();
1662 infos.add(info());
1663 final ExprList list = new ExprList(3).add(ifCond());
1664 if(wsConsumeWs(THEN)) {
1665 list.add(check(single(), NOIF));
1666 if(wsConsumeWs(ELSE)) list.add(check(single(), NOIF));
1667 } else {
1668 list.add(enclosedExpr());
1669 while(wsConsume(ELSE)) {
1670 if(!wsConsume(IF)) {
1671 list.add(enclosedExpr());
1672 break;
1673 }
1674 infos.add(info());
1675 list.add(ifCond()).add(enclosedExpr());
1676 }
1677 }
1678 Expr expr = (list.size() & 1) == 0 ? Empty.VALUE : list.pop();
1679 while(!list.isEmpty()) {
1680 final Expr thn = list.pop(), cond = list.pop();
1681 expr = new If(infos.removeLast(), cond, thn, expr);
1682 }
1683 return expr;
1684 }
1685
1686 /**
1687 * Parses the if condition.

Callers 1

singleMethod · 0.95

Calls 12

wsConsumeWsMethod · 0.95
infoMethod · 0.95
ifCondMethod · 0.95
checkMethod · 0.95
singleMethod · 0.95
enclosedExprMethod · 0.95
wsConsumeMethod · 0.95
removeLastMethod · 0.80
addMethod · 0.65
sizeMethod · 0.65
popMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected