Three big type-in compilers to type in

request software or documentation that you can't find online
Post Reply
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Three big type-in compilers to type in

Post by BigEd »

Jeremy Ruston wrote (at least) three compilers in Basic, published in books which are now online, with commented source code and implementation notes.

But, the listings have not come cleanly through OCR, as ever, and the type-ins need to be typed in if they are to be made available. (Or, if it's been done, please let us know where to find the results!)

There's a Pascal compiler in Pascal For Human Beings (1982) (web) (files, including txt and pdf)
including implementation notes and commented source code for a Pascal compiler, written in Basic and compiling to Basic
And there's a Forth-like FROTH and an Algol-like SLUG in BBC Micro Compendium (web) (files, including txt and pdf)
includes two complete compilers. One compiles FROTH, a threaded language resembling FORTH and the other compiles a new language called SLUG, which is a block structured language based on Algol, BCPL and Pascal. Both these languages can run up to 100 times faster than BBC BASIC.
Any takers? Perhaps some kind of collaboration is possible?
melchett
Posts: 433
Joined: Tue Jan 28, 2003 9:52 am
Contact:

Re: Three big type-in compilers to type in

Post by melchett »

You can cross the Jeremy Ruston's Pascal for Human Being's compiler off the list - I recreated it.

It's quite interesting how it just converts Pascal to BBC Basic. Not quite "compilation" but it's pretty effective. Amazing how long it takes to execute on a BBC Micro (20 seconds) versus a modern machine (almost instant).

Andy
User avatar
colinhoad
Posts: 131
Joined: Fri Mar 15, 2019 2:25 pm
Location: London, UK
Contact:

Re: Three big type-in compilers to type in

Post by colinhoad »

BigEd wrote:
Mon Jun 07, 2021 6:18 pm
Any takers? Perhaps some kind of collaboration is possible?
I'll happily have a go at typing in the FROTH compiler - depending on how I get on (and whether anyone else volunteers) I might take on SLUG as well. Do you have a preferred output format? I'd probably use Richard Russell's editor and save it as .BBC and .BAS files, if that's acceptable.
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Three big type-in compilers to type in

Post by BigEd »

Well done, Andy, that's marvellous!

For myself, Colin, I'd prefer a text file, but a tokenised file is fine too, as it's easy enough to convert from one to the other.
User avatar
jgharston
Posts: 4583
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Three big type-in compilers to type in

Post by jgharston »

BigEd wrote:
Fri Nov 19, 2021 4:29 pm
For myself, Colin, I'd prefer a text file, but a tokenised file is fine too, as it's easy enough to convert from one to the other.
.BAS /is/ a text file.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.36
(C) Copyright J.G.Harston 1989,2005-2020
>_
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Three big type-in compilers to type in

Post by BigEd »

Very good!
User avatar
sweh
Posts: 2601
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Three big type-in compilers to type in

Post by sweh »

I remember, back in the day, typing in a FORTRAN interpreter, written in BASIC.

I'm not sure it was from this book, but it looks familiar
Image

There's even two simple demos...
Attachments
fortran.ssd.zip
(3.6 KiB) Downloaded 16 times
Rgds
Stephen
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Three big type-in compilers to type in

Post by BigEd »

wow - Fortran in a couple of hundred lines of Basic. And with an editor too.
User avatar
colinhoad
Posts: 131
Joined: Fri Mar 15, 2019 2:25 pm
Location: London, UK
Contact:

Re: Three big type-in compilers to type in

Post by colinhoad »

BigEd wrote:
Fri Nov 19, 2021 4:29 pm
For myself, Colin, I'd prefer a text file, but a tokenised file is fine too, as it's easy enough to convert from one to the other.
No problem - I've finished the initial type-in, just need to find a bit of time to test it out and make sure there aren't any bugs (from my own typos or the original published listing!) It's been fun, I'm learning about FORTH in the process, so a valuable learning exercise all round :)
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

I remember reading about FROTH in that book but I never tried it (yet)
User avatar
colinhoad
Posts: 131
Joined: Fri Mar 15, 2019 2:25 pm
Location: London, UK
Contact:

Re: Three big type-in compilers to type in

Post by colinhoad »

I've now finished typing and testing out the compiler! I had to make a few corrections as there were a few errors in the original listing, but I've made those explicit (listing-correction.png in my Git repo). All files, including a plain text version of the listing code, a tokenised .bbc file and a .ssd disk image are available here, along with a readme: https://github.com/colinhoad/bbc-micro-forth-compiler
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Three big type-in compilers to type in

Post by BigEd »

Great!
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

Yeah it works!
froth-session.png
I don't know if I'll get time to work out using BEGIN END
User avatar
colinhoad
Posts: 131
Joined: Fri Mar 15, 2019 2:25 pm
Location: London, UK
Contact:

Re: Three big type-in compilers to type in

Post by colinhoad »

Is anyone else planning on (or already started) typing in the SLUG compiler? I had a read of the introduction to it last night and it looks fascinating (it converts BASIC programs into 6502 assembly code) but I won't start typing it in if someone else is already in the midst of doing so.
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

I am trying to type it in, just halfway by now and must be proof-read but going forward.
We could split the work. I type it and someone else will proof-read it, anyone volunteering?
BTW and not willing to start an argument, the SLUG compiler compiles a subset of ALGOL(-like) language to MC.
Attachments
SLUG.txt
(8.95 KiB) Downloaded 10 times
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

I'll proof-read what you've got so far.
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

Good.
While I will continue, please feel free to mark every error you found or better yet, send me back the corrected listing so I could continue on solid ground.
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

Here's the revised version
Attachments
SLUG_revised.txt
(8.95 KiB) Downloaded 6 times
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

Thanks, I'll add it the the already typed and post the remaining in the same way.
User avatar
BigEd
Posts: 4538
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Three big type-in compilers to type in

Post by BigEd »

Great stuff - thanks!
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

Here is the SLUG listing in text format. Has been typed-in and proof-read by me (and by caspian until row 3390 (thanks caspian!)) but surely some typo will remain. Before even trying to commit to the Beeb I'd like to have someone verifying it.

BTW: it is my browser (Firefox) or there is something wrong with the forum messages dates? Shown are the day of the week, the month and the year but it is missing the day of the month. (?)
Attachments
SLUG.txt
(17.16 KiB) Downloaded 11 times
User avatar
colinhoad
Posts: 131
Joined: Fri Mar 15, 2019 2:25 pm
Location: London, UK
Contact:

Re: Three big type-in compilers to type in

Post by colinhoad »

nicolagiacobbe wrote:
Wed Dec 01, 2021 2:28 pm
BTW and not willing to start an argument, the SLUG compiler compiles a subset of ALGOL(-like) language to MC.
Ah, yes - my mistake. I misread the introduction! :oops:
User avatar
baz4096
Posts: 252
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Three big type-in compilers to type in

Post by baz4096 »

nicolagiacobbe wrote:
Fri Dec 03, 2021 8:57 am
BTW: it is my browser (Firefox) or there is something wrong with the forum messages dates? Shown are the day of the week, the month and the year but it is missing the day of the month. (?)
Seem to be working fine for me. Your last message says: "Fri Dec 03, 2021 8:57 am" for example.
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

This is what I see when logged in. If I browse the forum as a guest it is ok but when logged on the date is messed up.
Anyway better stop it here before the forum police will come and tell us we are OT.
Attachments
Screen Shot 2021-12-03 at 12.10.08.png
User avatar
baz4096
Posts: 252
Joined: Sat Apr 10, 2021 3:51 pm
Location: Baildon, West Yorkshire
Contact:

Re: Three big type-in compilers to type in

Post by baz4096 »

Have you tried looking at your Board Preferences?

ucp.php?i=165

You may have a custom date format set. This is mine:
Screenshot 2021-12-03 at 14.12.33.png
(To get back on-topic, we can always delete these last few messages.)
Last edited by baz4096 on Fri Dec 03, 2021 2:17 pm, edited 1 time in total.
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

nicolagiacobbe wrote:
Fri Dec 03, 2021 8:57 am
Here is the SLUG listing in text format. Has been typed-in and proof-read by me (and by caspian until row 3390 (thanks caspian!)) but surely some typo will remain. Before even trying to commit to the Beeb I'd like to have someone verifying it.

BTW: it is my browser (Firefox) or there is something wrong with the forum messages dates? Shown are the day of the week, the month and the year but it is missing the day of the month. (?)
Found one, when I searched for "AS" in place of "A$". Line 1490 has one I must have missed when doing the proofreading line by line.
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

Good, and nice trick to search for 'AS'.
Once finished your check, please send the code back so that I (and everybody else) could check it again and try to make it work.
I am especially wary of 'IAC1'/'IAC2' mishap.
caspian
Posts: 87
Joined: Sat Nov 24, 2018 5:15 am
Contact:

Re: Three big type-in compilers to type in

Post by caspian »

I did another search, looking for strings of letters numbers and underscore (i.e. probably a symbol) that only appeared once, and then checking whether they looked wrong. Apart from AS, I found several others, fixed in the attached copy (LEFTS for LEFT$, PROCIeveL_4, PROCworc_ind ... I think about 8 altogether).

That's all I'm doing for now.

[editing to add] I did notice PROCdiv and PROCmod were used but never defined anywhere, but I think that's how they appear in the book.
Attachments
SLUG-3.txt
(17.16 KiB) Downloaded 7 times
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

Yes these two procedures are called (in lines 3650, 3660) but are nowhere defined, probably they could be rewritten using these lines as templates:
4620 DEF PROCtimes
4630 LOCAL OLT%,OLT$,BRN$
4640 IF RLT%=1 AND RLT$="IAC1" THEN PROCpush_iac
4650 OLT%=RLT%:OLT$=RLT$
4660 PROClevel_4
4670 PROCdo_it("MULTIPLY")
4680 ENDPROC

The problem is that the procedure PROCdo_it needs a piece of machine code to do the operation (probably to be put before line 1060), any (integer) division/remainder code at hand as of now?

BTW that seems to imply that no one ever used the compiler operators DIV and REM. Probably wasn't doble checked and it is likely containing errors (apart from the OCRing ones)
nicolagiacobbe
Posts: 103
Joined: Tue Jul 03, 2007 10:40 am
Location: italy
Contact:

Re: Three big type-in compilers to type in

Post by nicolagiacobbe »

I have read the SLUG specifications and it says:

Code: Select all

...The following binary operators are used:
OR
EOR
AND
=
<>
>=
<=
>
<
+
-
*
This list is in reverse order of precedence
The unary operators allowed are:
-
+
?
!
So I would say that it is not a bug but a feature that the PROCdiv and PROCmod are never called, probably Ruston intended to include them in but the rush or some problem made him put them aside.
The best thing now would be to remove these procedures from the parsing code (lines 3650 and 3660) and then to add them later as an improvement of the SLUG compiler. I will try to do that once the basic code is working, just remember to never use the 'DIV' and 'MOD' operators.
Post Reply

Return to “archive requests”