[116] TypeDeclaration ::= "as" SequenceType
[35] PositionalVar ::= "at" "$" VarName
************************************************************************/
final public List<Binding> parseForClause() throws ParseException, XQueryException {
final List<Binding> fors;
ForClause clause;
ForVariable var;
Type varType = null;
XQExpression expr;
currentToken = jj_consume_token(ForVariable);
currentToken = jj_consume_token(VarName);
QualifiedName varName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
var = new ForVariable(varName);
currentModule.putVariable(varName, var);
clause = new ForClause(var);
locate(clause);
switch(jj_nt.kind) {
case As:
//TypeDeclaration?
currentToken = jj_consume_token(As);
varType = parseSequenceType();
var.setType(varType);
break;
default:
jj_la1[68] = jj_gen;
;
}
switch(jj_nt.kind) {
case AtWord:
//PositionalVar?
currentToken = jj_consume_token(AtWord);
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
QualifiedName posVarName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
PositionalVariable posVar = new PositionalVariable(posVarName);
currentModule.putVariable(posVarName, posVar);
clause.setPositionVariable(posVar);
break;
default:
jj_la1[69] = jj_gen;
;
}
currentToken = jj_consume_token(In);
expr = parseExprSingle();
clause.setInExpr(expr);
fors = new LinkedList<Binding>();
fors.add(clause);
label_10: while(true) {
switch(jj_nt.kind) {
case Comma:
;
break;
default:
jj_la1[70] = jj_gen;
break label_10;
}
//("," "$" VarName TypeDeclaration? PositionalVar? "in" ExprSingle)*
currentToken = jj_consume_token(Comma);
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
varName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
var = new ForVariable(varName);
currentModule.putVariable(varName, var);
clause = new ForClause(var);
switch(jj_nt.kind) {
case As:
//TypeDeclaration?
currentToken = jj_consume_token(As);
varType = parseSequenceType();
var.setType(varType);
break;
default:
jj_la1[71] = jj_gen;
;
}
switch(jj_nt.kind) {
case AtWord:
//PositionalVar?
currentToken = jj_consume_token(AtWord);
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
QualifiedName posVarName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
PositionalVariable posVar = new PositionalVariable(posVarName);
currentModule.putVariable(posVarName, posVar);
clause.setPositionVariable(posVar);
break;
default:
jj_la1[72] = jj_gen;
;
}
currentToken = jj_consume_token(In);
expr = parseExprSingle();
clause.setInExpr(expr);
fors.add(clause);
}
{
if(true)
return fors;