}
}
/** Add an OPEN declaration. */
void addOpen(Pos pos, Pos isPrivate, ExprVar name, List<ExprVar> args, ExprVar alias) throws Err {
if (status>2) throw new ErrorSyntax(pos, "The \"open\" declaration must occur before any\n" + "sig/pred/fun/fact/assert/check/run command.");
String as = (alias==null ? "" : alias.label);
if (name.label.length()==0) throw new ErrorSyntax(name.span(), "The filename cannot be empty.");
if (as.indexOf('$')>=0) throw new ErrorSyntax(alias==null ? null : alias.span(), "Alias must not contain the \'$\' character");
if (as.indexOf('@')>=0) throw new ErrorSyntax(alias==null ? null : alias.span(), "Alias must not contain the \'@\' character");
if (as.indexOf('/')>=0) throw new ErrorSyntax(alias==null ? null : alias.span(), "Alias must not contain the \'/\' character");
if (as.length()==0) {
as="open$"+(1+opens.size());
if (args==null || args.size()==0) {
for(int i=0; ; i++) {
if (i>=name.label.length()) { as=name.label; break; }
char c=name.label.charAt(i);
if ((c>='a' && c<='z') || (c>='A' && c<='Z')) continue;
if (i==0) break;
if (!(c>='0' && c<='9') && c!='_' && c!='\'' && c!='\"') break;
}
}
}
final TempList<String> newlist = new TempList<String>(args==null ? 0 : args.size());
if (args!=null) for(int i=0; i<args.size(); i++) {
ExprVar arg=args.get(i);
if (arg.label.length()==0) throw new ErrorSyntax(arg.span(), "Argument cannot be empty.");
if (arg.label.indexOf('@')>=0) throw new ErrorSyntax(arg.span(), "Argument cannot contain the \'@\' chracter.");
newlist.add(arg.label);
}
Open x = opens.get(as);
if (x!=null) {
// we allow this, especially because of util/sequniv
if (x.args.equals(newlist.makeConst()) && x.filename.equals(name.label)) return;
throw new ErrorSyntax(pos, "You cannot import two different modules\n" + "using the same alias.");
}
x = new Open(pos, isPrivate!=null, as, newlist.makeConst(), name.label);
opens.put(as, x);
}