public TupleExpr visit(ASTSelect node, Object data)
throws VisitorException
{
TupleExpr result = (TupleExpr)data;
Extension extension = new Extension();
ProjectionElemList projElemList = new ProjectionElemList();
for (ASTProjectionElem projElemNode : node.getProjectionElemList()) {
ValueExpr valueExpr = (ValueExpr)projElemNode.getValueExpr().jjtAccept(this, null);
String alias = projElemNode.getAlias();
if (alias != null) {
// aliased projection element
extension.addElement(new ExtensionElem(valueExpr, alias));
projElemList.addElement(new ProjectionElem(alias));
}
else if (valueExpr instanceof Var) {
// unaliased variable
Var projVar = (Var)valueExpr;
projElemList.addElement(new ProjectionElem(projVar.getName()));
}
else {
throw new IllegalStateException("required alias for non-Var projection elements not found");
}
}
if (!extension.getElements().isEmpty()) {
extension.setArg(result);
result = extension;
}
result = new Projection(result, projElemList);