Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
61
Task/Subleq/Draco/subleq.draco
Normal file
61
Task/Subleq/Draco/subleq.draco
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
\util.g
|
||||
|
||||
proc nonrec rdch() byte:
|
||||
char c;
|
||||
if read(c) then
|
||||
pretend(c, byte)
|
||||
else
|
||||
case ioerror()
|
||||
incase CH_MISSING: readln(); 10
|
||||
default: 0
|
||||
esac
|
||||
fi
|
||||
corp
|
||||
|
||||
proc nonrec wrch(byte b) void:
|
||||
if b=10
|
||||
then writeln()
|
||||
else write(pretend(b, char))
|
||||
fi
|
||||
corp
|
||||
|
||||
proc nonrec main() void:
|
||||
[16384] int mem;
|
||||
file() srcfile;
|
||||
channel input text srcch;
|
||||
*char fname;
|
||||
int a, b, c, i;
|
||||
byte iob;
|
||||
|
||||
BlockFill(pretend(&mem[0], *byte), sizeof(byte), 0);
|
||||
|
||||
fname := GetPar();
|
||||
if fname = nil then
|
||||
writeln("usage: SUBLEQ filename");
|
||||
exit(1);
|
||||
fi;
|
||||
|
||||
if not open(srcch, srcfile, fname) then
|
||||
writeln("Cannot open input file");
|
||||
exit(1)
|
||||
fi;
|
||||
|
||||
i := 0;
|
||||
while read(srcch; mem[i]) do i := i + 1 od;
|
||||
close(srcch);
|
||||
|
||||
i := 0;
|
||||
while i>=0 do
|
||||
a := mem[i];
|
||||
b := mem[i+1];
|
||||
c := mem[i+2];
|
||||
i := i + 3;
|
||||
|
||||
if a=-1 then mem[b] := rdch()
|
||||
elif b=-1 then wrch(mem[a])
|
||||
else
|
||||
mem[b] := mem[b] - mem[a];
|
||||
if mem[b] <= 0 then i := c fi
|
||||
fi
|
||||
od
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue