IMPORTS
BasicTime, Commander, CommandTool, IO, Rope,
MicroDefs, MicroGlobalVars, MicroOps, MicroUtils
StartMicro:
ENTRY Commander.CommandProc = {
ENABLE {
UNWIND => NULL;
Failure => {
IF reportStrm#NIL THEN reportStrm.PutRope[explanation];
result ← $Failure;
RESUME;
};
};
wDir: ROPE ← CommandTool.CurrentWorkingDirectory[];
argv: CommandTool.ArgumentVector ← CommandTool.Parse[cmd];
cmdLine: ROPE = Rope.Concat["Micro", cmd.commandLine];
srcFileList: MicroDefs.SrcFile;
ok: BOOL;
start: BasicTime.GMT = BasicTime.Now[];
fileExtnMB: ROPE = "MB";
dumpSymStartIndex: INTEGER ← -1;
[srcFileList, ok] ← MicroOps.InitMicroVars[cmdLine, wDir, argv];
MicroUtils.RestartAcc[];
MicroUtils.RestartBuiltins[];
IF ~ok THEN RETURN;
IF restoreSymbolsFile =
NIL
THEN {
MicroOps.InitSymbolTable[];
[] ← DefineBuiltIn[$BUILTIN, biBUILTIN];
[] ← DefineBuiltIn[$INSERT, biINSERT];
MicroOps.InitMacroOps[];
}
ELSE {
IF NOT MicroOps.RecoverSymbols[restoreSymbolsFile] THEN MicroOps.ReportError[msg: IO.PutFR["\n Can't recover symbols from %g\n", IO.rope[restoreSymbolsFile]], abort: TRUE];
restoreSymbolsFile ← NIL;
};
MicroOps.InitAcc[];
MicroOps.InitIn[];
IF mbExtn = NIL THEN mbExtn ← fileExtnMB; -- MicroOps.InitOut[fileExtnMB];
FOR sfl: SrcFile ← srcFileList, sfl.next
UNTIL sfl =
NIL
DO
MicroOps.InitReadStmt[convertToUpperFlag OR sfl.upperCaseFlag];
IF ~MicroOps.InPush[sfl]
THEN {
MicroOps.ReportError[
IO.PutFR["\n Source file %g doesn't exist - continuing\n",
IO.rope[sfl.fullName] ],
FALSE];
LOOP;
};
WHILE MicroOps.ReadStmt[]
DO
first: INTEGER = MicroOps.GetStmtInteger[1];
IF (first >= 0)
AND (first < 256)
AND (MicroOps.GetStmtChar[1] = ':)
THEN {
MicroOps.PutStmtChar[1, endc];
MicroOps.Assemble[]; -- ignore :, always process
}
ELSE IF ~ignore THEN MicroOps.Assemble[]; -- don't process if ignoring
ENDLOOP; -- statement loop
ENDLOOP; -- files loop
IF symbolsFileRec #
NIL
THEN {
[ , dumpSymStartIndex] ← MicroOps.DumpSymbols[symbolsFileRec];
symbolsFileRec.strm.Close[];
symbolsFileRec ← NIL;
};
MicroOps.EndOutput[dumpSymStartIndex];
MicroOps.EndListing[expandedListingFlag];
BEGIN
now: BasicTime.GMT = BasicTime.Now[];
secs: INT = BasicTime.Period[start, now];
reportStrm.PutF["Finished at %g, (%g seconds)\n", IO.time[now], IO.int[secs]];
reportStrm.PutF["There were %g error(s) and %g warning(s)\n",
IO.int[errorCount], IO.int[warningCount] ];
IF errorFileRec.strm #
NIL
THEN
errorFileRec.strm.PutF["There were %g error(s) and %g warning(s)\n",
IO.int[errorCount], IO.int[warningCount] ];
IF errorCount#0 THEN result ← $Failure;
END;
IF errorFileRec.strm #
NIL
THEN {
errorFileRec.strm.Close[];
errorFileRec.strm ← NIL;
};
};