/************************************************************************
[43] TypeswitchExpr ::= <"typeswitch" "("> Expr ")" CaseClause+
"default" ("$" VarName)? "return" ExprSingle
************************************************************************/
final public TypeswitchExpr parseTypeswitchExpr() throws ParseException, XQueryException {
final TypeswitchExpr switchExpr;
XQExpression expr = null;
CaseClause cc = null;
QualifiedName varName = null;
currentToken = jj_consume_token(TypeswitchLpar);
expr = parseExpr();
switchExpr = new TypeswitchExpr(expr);
locate(switchExpr);
currentToken = jj_consume_token(Rpar);
label_14: while(true) {
cc = parseCaseClause();
switchExpr.addCaseClause(cc);
switch(jj_nt.kind) {
case Case:
;
break;
default:
jj_la1[87] = jj_gen;
break label_14;
}
}
currentModule.pushVarScope();
currentToken = jj_consume_token(Default);
switch(jj_nt.kind) {
case VariableIndicator:
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
varName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
break;
default:
jj_la1[88] = jj_gen;
;
}
currentToken = jj_consume_token(Return);
expr = parseExprSingle();
CaseVariable var = new CaseVariable(varName);
CaseClause dc = new CaseClause(var, expr);
switchExpr.setDefaultClause(dc);
currentModule.popVarScope();
{
if(true)
return switchExpr;
}