[Turn on line numbering]
arg u, str, next_parser, @other_parsers;
var l, cmd, c, p, obj, exits;
cmd = str.explode();
if (cmd) {
cmd = [str, cmd[1], cmd.subrange(2).join() || ""];
p = [];
if ((c = u.match_shortcut(@cmd))) {
if (c[1] == 'shortcut)
return .shortcut(u, @c[2]);
p = c[2];
}
if ((c = u.match_command(@cmd))) {
if (c[1] == 'command)
return .local(u, @c[2]);
p += c[2];
}
l = u.location();
if ((c = (| l.match_shortcut(@cmd) |))) {
if (c[1] == 'shortcut)
return .shortcut(l, @c[2]);
p += c[2];
}
if ((c = (| l.match_command(@cmd) |))) {
if (c[1] == 'command)
return .local(l, @c[2]);
p += c[2];
}
if ((c = $remote_cache.match_remote_command(@cmd))) {
if (c[1] == 'remote)
return .remote(u, @c[2]);
p += c[2];
}
if ((exits = (| u.location().exits() |) || [])) {
catch any {
obj = exits.match_object(str);
return ['command, obj, 'invoke];
} with {
if (error() == ~ambig) {
exits = traceback()[1][3];
return ['error, "\"" + str + "\" can match " + exits.mmap('namef, 'ref).to_english("", " or ") + "."];
}
}
}
if (p)
return .partial(u, cmd, p);
}
return next_parser.parse(u, str, @other_parsers);
["// Created 31-Mar-1995 as a part of ColdCore, see: @help Credit"]