You are browsing as a guest. Sign up (or log in) to start making projects!

Dartmouth BASIC Interpreter

  • 6 Devlogs
  • 14 Total hours

An interpreter for Dartmouth BASIC

Open comments for this post

1h 50m 21s logged

Terminal Done!

I have added a recreation of the original terminal interface, where you
type HELLO answer questions like your student number, problem number,
and then you can write the program in the terminal, run it, save it, etc!

Readme

I also created the readme

0
0
5
Open comments for this post

3h 24m 26s logged

Basically finished

I added a bunch of the orignal error messages from a 1964 manual, and now it is feature complete (minus DIM and DEF)

Next

What i’d like to do next is create the terminal interface as described in this manual, on pages 16-18.
It would be cool to say HELLO and then type in a user id, program id, write the program and save it, and even run it. I think it would feel very fitting!

0
0
3
Open comments for this post

40m 34s logged

I implemented the skipping FOR loops if they are invalid. ex for i = 0 to 10 step -1
I also created a few test programs and ran then to see if they worked (they did)

Here is my pythagarian triangle finder:

10 FOR A = 1 TO 50 STEP 1
20 FOR B = 1 TO 50 STEP 1
30 LET C2 = A*A + B*B
40 LET C = SQR(C2)
50 IF INT(C)=C THEN 70
60 GOTO 80
70 GOSUB 500
80 NEXT B
90 NEXT A
100 STOP

500 PRINT "PYTHAGARIAN TRIANGLE FOUND";A;B;C
510 RETURN

1000 STOP

I’m highkey a lazy bum and dont want to implement DEF and DIM for my own sanity’s sake, and making better debug screens? goodness no! I’ll be making an interface to type in basic programs now

0
0
2
Open comments for this post

3h 11m 38s logged

It is like 90% complete, and like works REALLY well

Lexer

I updated this a little bit. I changed how the functions are called so instead of doing execute the interpreter calls __str__ on it and it will return the python function to do that operation inside of eval.
As well I updated the parsing so you can put as many spaces or as little between operations as you want and it will still read just fine. like before you could only do ( A * 3 ) / 5 but now things like (A*3)/ 5 work just fine!
I also made strings get read in entirely
Also print statements now can use semicolons to seperate parts of a message on 1 line. like you can do
10 PRINT "A = "; A; " B = ";B
and it will print out “A = {A} B = {B}” with {A} and {B} being replaced with their actual runtime values!

Interpreter

I added some error catching and the global DATA array so the DATA statement can put its data in there
It now catches when you try to NEXT from a for loop that doesnt exist
also it catches when you try to RETURN from a subroutine when you never called a subroutine, as well as making sure that setting the program counter, via things like IF/THEN and GOTO are an actual line defined in the program

Up Next

I want to finish making sure all the functions and statements work as intended, as well as implementing DEF and DIM
I also REALLY want to get more details error reports, by also giving the line number where an error occurred, possible typo/solutions, etc

0
0
2
Open comments for this post

2h 42m 49s logged

Interpreter is basically done, I’ve only got to implement data def dim and read instructions.
I’m highkey fearing making def since my current syntax parsing is fucking abysmal and this will only make it worse.
I’ve also got to work on reading strings in for print statement and highkey most of my syntax reading in ngl
But it does work for some programs like this Fibonacci sequence generator I made

10 LET A = 0
20 LET B = 1
30 LET C = A + B
40 IF C > 144 THEN 100
50 PRINT C
60 LET A = B
70 LET B = C
80 GOTO 30
100 STOP
0
0
2
Open comments for this post

2h 12m 41s logged

Lexer

I’ve got the lexer basically done, maybe a few tweaks a bit later but for the most part i can take in each line of Dartmouth Original BASIC and turn it into a list of lines and symbols to then parse

Interpreter

Currently it keeps track of all the variables and the program counter and runs through each line of BASIC executing it. Atm it looks fine, I just need to create and add the execute function to all of the BASIC statements like STOP, PRINT, IF, and LET

Pratt Parser

Currently I am working on the a pratt parser to determine the value of math operations for PRINT and LET and possible other stuff

0
0
4

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…