Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 1x 1x 1x 1x 1x 61x 61x 61x 61x 61x 61x 61x 31x 31x 61x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 61x 61x 61x 1x 1x 1x 1x 61x 61x 61x 9x 9x 9x 52x 61x 2x 2x 2x 50x 61x 12x 12x 12x 12x 12x 61x 528x 528x 61x 49x 49x 61x 192x 192x 50x 50x 50x 61x 3x 3x 50x 50x 50x 1x 1x | import { parseLine } from "./parseLine.js";
import { toInternal, nonempty, norm } from "./utils/utils.js";
import { prepro } from "./preprocessor.js";
const emptymask = (xs) => xs.map((lx) => {
let l = lx.line;
let lx2 = {
addr: 0,
line: ";;;EMPTYLINE",
numline: lx.numline
};
while (l[0] == " ") {
l = l.substr(1);
}
return l.length ? lx : lx2;
});
export const beautify = async (s, opts) => {
let i = toInternal(s.split(/\n/));
i = emptymask(i);
i = nonempty(i);
i = norm(i);
let prei = await prepro(i, {
noinclude: true,
...opts
});
i = i.map((line) => {
//console.log(line);
line.line = line.line.replace(/\%\%M/gi, "__m");
return parseLine(line, prei[1], opts);
});
let out = "";
let op, ln;
for (let q = 0; q < i.length; q++) {
op = i[q];
ln = "";
if (op.remark == "EMPTYLINE") {
out += "\n";
continue;
}
if (!op.label && !op.opcode && op.remark) {
out += ";" + op.remark + "\n";
continue;
}
if (op.label) {
ln += op.label;
if (op.opcode != "EQU" && op.opcode != "=" && op.opcode != ".SET")
ln += ":";
ln += " ";
}
while (ln.length < 12) {
ln += " ";
}
if (op.opcode) {
ln += op.opcode + " ";
}
while (ln.length < 20) {
ln += " ";
}
if (op.params) {
ln += op.params + " ";
}
if (op.remark) {
ln += ";" + op.remark;
}
ln = ln.replace(/__m/gi, "%%M");
out += ln + "\n";
}
return out;
}; |