/************************************************************************
[44] CaseClause ::= "case" ("$" VarName "as")? SequenceType "return" ExprSingle
************************************************************************/
final public CaseClause parseCaseClause() throws ParseException, XQueryException {
QualifiedName varName = null;
CaseVariable caseVar = null;
final Type varType;
final XQExpression retExpr;
currentModule.pushVarScope();
currentToken = jj_consume_token(Case);
switch(jj_nt.kind) {
case VariableIndicator:
// ("$" VarName "as")?
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
varName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
caseVar = new CaseVariable(varName);
currentModule.putVariable(varName, caseVar);
currentToken = jj_consume_token(As);
break;
default:
jj_la1[89] = jj_gen;
;
}
if(caseVar == null) {
caseVar = new CaseVariable(null);
}
varType = parseSequenceType();
caseVar.setType(varType);
currentToken = jj_consume_token(Return);
retExpr = parseExprSingle();
currentModule.popVarScope();
final CaseClause cc = new CaseClause(caseVar, retExpr);
locate(cc);