Home » Archimedes archive » Zipped Apps » BCPL » BCPL/b/pp
BCPL/b/pp
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Zipped Apps » BCPL |
Filename: | BCPL/b/pp |
Read OK: | ✔ |
File size: | 0547 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
GET "LibHdr" MANIFEST $( infinity = #x7fffffff $); STATIC $( sourceLineCount = 0; sourceStream = 0; codeStream = 0 $) LET CopyToLine(line) BE $( SelectInput(sourceStream); WHILE line>sourceLineCount DO $( LET ch = RdCh(); IF ch=EndStreamCh THEN RETURN; IF ch='*n' THEN sourceLineCount := sourceLineCount+1; WrCh(ch) $); SelectInput(codeStream) $) AND Start() BE $( LET codeLineBuffer = GetVec(20); LET argv = GetVec(40); LET codeCharCount = 0; RdArgs("code/A,source/A,to/K", argv, 40); codeStream := FindInput(argv!0); sourceStream := FindInput(argv!1); IF argv!2~=0 THEN SelectOutput(FindOutput(argv!2)); sourceLineCount := 0; SelectInput(codeStream); $( LET ch = RdCh(); codeCharCount := 0; WHILE ch~='*n' DO $( IF ch=EndStreamCh THEN GOTO Finished; codeCharCount := codeCharCount+1; codeLineBuffer%codeCharCount := ch; ch := RdCh() $); codeLineBuffer%0 := 10; /*TEST*/IF codeCharCount>10 & CompString(codeLineBuffer, "; -- Line ")=0 THEN $( LET n = 0; FOR i = 11 TO codeCharCount DO $( LET ch = codeLineBuffer%i; IF ~('0'<=ch<='9') THEN BREAK n := n*10+ch-'0' $); CopyToLine(n) $) /* ELSE $( */ FOR i = 1 TO codeCharCount DO WrCh(codeLineBuffer%i); NewLine() /*$)*/ $) REPEAT; Finished: CopyToLine(infinity) $)
00000000 47 45 54 20 22 4c 69 62 48 64 72 22 0a 0a 4d 41 |GET "LibHdr"..MA| 00000010 4e 49 46 45 53 54 20 24 28 0a 20 20 20 69 6e 66 |NIFEST $(. inf| 00000020 69 6e 69 74 79 20 3d 20 23 78 37 66 66 66 66 66 |inity = #x7fffff| 00000030 66 66 20 24 29 3b 0a 0a 53 54 41 54 49 43 20 24 |ff $);..STATIC $| 00000040 28 0a 20 20 20 73 6f 75 72 63 65 4c 69 6e 65 43 |(. sourceLineC| 00000050 6f 75 6e 74 20 3d 20 30 3b 0a 20 20 20 73 6f 75 |ount = 0;. sou| 00000060 72 63 65 53 74 72 65 61 6d 20 3d 20 30 3b 0a 20 |rceStream = 0;. | 00000070 20 20 63 6f 64 65 53 74 72 65 61 6d 20 3d 20 30 | codeStream = 0| 00000080 20 24 29 0a 0a 4c 45 54 20 43 6f 70 79 54 6f 4c | $)..LET CopyToL| 00000090 69 6e 65 28 6c 69 6e 65 29 20 42 45 0a 24 28 20 |ine(line) BE.$( | 000000a0 53 65 6c 65 63 74 49 6e 70 75 74 28 73 6f 75 72 |SelectInput(sour| 000000b0 63 65 53 74 72 65 61 6d 29 3b 0a 20 20 20 57 48 |ceStream);. WH| 000000c0 49 4c 45 20 6c 69 6e 65 3e 73 6f 75 72 63 65 4c |ILE line>sourceL| 000000d0 69 6e 65 43 6f 75 6e 74 20 44 4f 0a 20 20 20 24 |ineCount DO. $| 000000e0 28 20 4c 45 54 20 63 68 20 3d 20 52 64 43 68 28 |( LET ch = RdCh(| 000000f0 29 3b 0a 20 20 20 20 20 20 49 46 20 63 68 3d 45 |);. IF ch=E| 00000100 6e 64 53 74 72 65 61 6d 43 68 20 54 48 45 4e 20 |ndStreamCh THEN | 00000110 52 45 54 55 52 4e 3b 0a 20 20 20 20 20 20 49 46 |RETURN;. IF| 00000120 20 63 68 3d 27 2a 6e 27 20 54 48 45 4e 20 73 6f | ch='*n' THEN so| 00000130 75 72 63 65 4c 69 6e 65 43 6f 75 6e 74 20 3a 3d |urceLineCount :=| 00000140 20 73 6f 75 72 63 65 4c 69 6e 65 43 6f 75 6e 74 | sourceLineCount| 00000150 2b 31 3b 0a 20 20 20 20 20 20 57 72 43 68 28 63 |+1;. WrCh(c| 00000160 68 29 20 24 29 3b 0a 20 20 20 53 65 6c 65 63 74 |h) $);. Select| 00000170 49 6e 70 75 74 28 63 6f 64 65 53 74 72 65 61 6d |Input(codeStream| 00000180 29 0a 24 29 0a 0a 41 4e 44 20 53 74 61 72 74 28 |).$)..AND Start(| 00000190 29 20 42 45 0a 24 28 20 4c 45 54 20 63 6f 64 65 |) BE.$( LET code| 000001a0 4c 69 6e 65 42 75 66 66 65 72 20 3d 20 47 65 74 |LineBuffer = Get| 000001b0 56 65 63 28 32 30 29 3b 0a 20 20 20 4c 45 54 20 |Vec(20);. LET | 000001c0 61 72 67 76 20 3d 20 47 65 74 56 65 63 28 34 30 |argv = GetVec(40| 000001d0 29 3b 0a 20 20 20 4c 45 54 20 63 6f 64 65 43 68 |);. LET codeCh| 000001e0 61 72 43 6f 75 6e 74 20 3d 20 30 3b 0a 20 20 20 |arCount = 0;. | 000001f0 52 64 41 72 67 73 28 22 63 6f 64 65 2f 41 2c 73 |RdArgs("code/A,s| 00000200 6f 75 72 63 65 2f 41 2c 74 6f 2f 4b 22 2c 20 61 |ource/A,to/K", a| 00000210 72 67 76 2c 20 34 30 29 3b 0a 20 20 20 63 6f 64 |rgv, 40);. cod| 00000220 65 53 74 72 65 61 6d 20 3a 3d 20 46 69 6e 64 49 |eStream := FindI| 00000230 6e 70 75 74 28 61 72 67 76 21 30 29 3b 0a 20 20 |nput(argv!0);. | 00000240 20 73 6f 75 72 63 65 53 74 72 65 61 6d 20 3a 3d | sourceStream :=| 00000250 20 46 69 6e 64 49 6e 70 75 74 28 61 72 67 76 21 | FindInput(argv!| 00000260 31 29 3b 0a 20 20 20 49 46 20 61 72 67 76 21 32 |1);. IF argv!2| 00000270 7e 3d 30 20 54 48 45 4e 20 53 65 6c 65 63 74 4f |~=0 THEN SelectO| 00000280 75 74 70 75 74 28 46 69 6e 64 4f 75 74 70 75 74 |utput(FindOutput| 00000290 28 61 72 67 76 21 32 29 29 3b 0a 20 20 20 73 6f |(argv!2));. so| 000002a0 75 72 63 65 4c 69 6e 65 43 6f 75 6e 74 20 3a 3d |urceLineCount :=| 000002b0 20 30 3b 0a 20 20 20 53 65 6c 65 63 74 49 6e 70 | 0;. SelectInp| 000002c0 75 74 28 63 6f 64 65 53 74 72 65 61 6d 29 3b 0a |ut(codeStream);.| 000002d0 20 20 20 24 28 20 4c 45 54 20 63 68 20 3d 20 52 | $( LET ch = R| 000002e0 64 43 68 28 29 3b 0a 20 20 20 20 20 20 63 6f 64 |dCh();. cod| 000002f0 65 43 68 61 72 43 6f 75 6e 74 20 3a 3d 20 30 3b |eCharCount := 0;| 00000300 0a 20 20 20 20 20 20 57 48 49 4c 45 20 63 68 7e |. WHILE ch~| 00000310 3d 27 2a 6e 27 20 44 4f 20 24 28 0a 09 20 49 46 |='*n' DO $(.. IF| 00000320 20 63 68 3d 45 6e 64 53 74 72 65 61 6d 43 68 20 | ch=EndStreamCh | 00000330 54 48 45 4e 20 47 4f 54 4f 20 46 69 6e 69 73 68 |THEN GOTO Finish| 00000340 65 64 3b 0a 09 20 63 6f 64 65 43 68 61 72 43 6f |ed;.. codeCharCo| 00000350 75 6e 74 20 3a 3d 20 63 6f 64 65 43 68 61 72 43 |unt := codeCharC| 00000360 6f 75 6e 74 2b 31 3b 0a 09 20 63 6f 64 65 4c 69 |ount+1;.. codeLi| 00000370 6e 65 42 75 66 66 65 72 25 63 6f 64 65 43 68 61 |neBuffer%codeCha| 00000380 72 43 6f 75 6e 74 20 3a 3d 20 63 68 3b 0a 09 20 |rCount := ch;.. | 00000390 63 68 20 3a 3d 20 52 64 43 68 28 29 20 24 29 3b |ch := RdCh() $);| 000003a0 0a 20 20 20 20 20 20 63 6f 64 65 4c 69 6e 65 42 |. codeLineB| 000003b0 75 66 66 65 72 25 30 20 3a 3d 20 31 30 3b 0a 20 |uffer%0 := 10;. | 000003c0 20 20 20 20 20 2f 2a 54 45 53 54 2a 2f 49 46 20 | /*TEST*/IF | 000003d0 63 6f 64 65 43 68 61 72 43 6f 75 6e 74 3e 31 30 |codeCharCount>10| 000003e0 20 26 0a 09 20 20 20 43 6f 6d 70 53 74 72 69 6e | &.. CompStrin| 000003f0 67 28 63 6f 64 65 4c 69 6e 65 42 75 66 66 65 72 |g(codeLineBuffer| 00000400 2c 20 22 3b 20 2d 2d 20 4c 69 6e 65 20 22 29 3d |, "; -- Line ")=| 00000410 30 20 54 48 45 4e 20 24 28 0a 09 20 4c 45 54 20 |0 THEN $(.. LET | 00000420 6e 20 3d 20 30 3b 0a 09 20 46 4f 52 20 69 20 3d |n = 0;.. FOR i =| 00000430 20 31 31 20 54 4f 20 63 6f 64 65 43 68 61 72 43 | 11 TO codeCharC| 00000440 6f 75 6e 74 20 44 4f 20 24 28 0a 09 20 20 20 20 |ount DO $(.. | 00000450 4c 45 54 20 63 68 20 3d 20 63 6f 64 65 4c 69 6e |LET ch = codeLin| 00000460 65 42 75 66 66 65 72 25 69 3b 0a 09 20 20 20 20 |eBuffer%i;.. | 00000470 49 46 20 7e 28 27 30 27 3c 3d 63 68 3c 3d 27 39 |IF ~('0'<=ch<='9| 00000480 27 29 20 54 48 45 4e 20 42 52 45 41 4b 0a 09 20 |') THEN BREAK.. | 00000490 20 20 20 6e 20 3a 3d 20 6e 2a 31 30 2b 63 68 2d | n := n*10+ch-| 000004a0 27 30 27 20 24 29 3b 0a 09 20 43 6f 70 79 54 6f |'0' $);.. CopyTo| 000004b0 4c 69 6e 65 28 6e 29 20 24 29 0a 2f 2a 09 45 4c |Line(n) $)./*.EL| 000004c0 53 45 20 24 28 20 2a 2f 0a 09 20 46 4f 52 20 69 |SE $( */.. FOR i| 000004d0 20 3d 20 31 20 54 4f 20 63 6f 64 65 43 68 61 72 | = 1 TO codeChar| 000004e0 43 6f 75 6e 74 20 44 4f 20 57 72 43 68 28 63 6f |Count DO WrCh(co| 000004f0 64 65 4c 69 6e 65 42 75 66 66 65 72 25 69 29 3b |deLineBuffer%i);| 00000500 0a 09 20 4e 65 77 4c 69 6e 65 28 29 20 2f 2a 24 |.. NewLine() /*$| 00000510 29 2a 2f 0a 20 20 20 24 29 20 52 45 50 45 41 54 |)*/. $) REPEAT| 00000520 3b 0a 46 69 6e 69 73 68 65 64 3a 0a 20 20 20 43 |;.Finished:. C| 00000530 6f 70 79 54 6f 4c 69 6e 65 28 69 6e 66 69 6e 69 |opyToLine(infini| 00000540 74 79 29 0a 24 29 0a |ty).$).| 00000547