RobotAssembleCommand.mesa
Created Sunday, June 10, 1984 0:29 am PDT
Last edited by Eric Nickell, June 11, 1984 12:41:42 pm PDT
DIRECTORY
Commander USING [CommandProc, Register],
IO USING [EndOfStream, IDProc, GetTokenRope, RIS, STREAM],
RobotDefs USING [Robot],
RobotEvaluator USING [SymbolTable],
RobotIO USING [WriteRobot],
RobotTParser USING [AssembleRobot],
Rope USING [ROPE];
RobotAssembleCommand:
CEDAR
PROGRAM
IMPORTS Commander, IO, RobotIO, RobotTParser
~ {
Assemble: Commander.CommandProc ~ {
s: IO.STREAM ← IO.RIS[cmd.commandLine];
root: Rope.ROPE ← IO.GetTokenRope[s, IO.IDProc ! IO.EndOfStream => GOTO NoName].token;
robot: RobotDefs.Robot;
sym: RobotEvaluator.SymbolTable;
valid: BOOL;
[robot, valid, sym] ← RobotTParser.AssembleRobot[root, cmd.err];
IF valid
THEN {
result←sym;
RobotIO.WriteRobot[root, robot];
}
ELSE result←$Failure;
EXITS
NoName => RETURN[result: $Failure, msg: "File name needed\n"]
};
Initialization stuff
Commander.Register[key: "Robot", proc: Assemble, doc: "Assemble Robot for RobotWar"];
}.