BASIC Interpreter
-
I'm currently working on a BASIC interpreter which is a complete port of the old BASIC. Where the famous "HELLO WORLD" program stems from.
10 PRINT "HELLO WORLD" 20 GOTO 10
So far the interpreter is behaving itself and not giving me any issues. The next step is adding IF statements, FOR and WHILE loops and adding the built in functions.
https://twitter.com/Lucas1904875369/status/1380138762085146632?s=20
Hope to finish this soon and move on to compiling Fuze in Fuze. :D
-
Hey, i like your project ! ( : It's a very good idea ! eagerly that you finish it !
but won't the variable system be too difficult to implement? -
@EvanTropFun the variable system isn't too difficult. I have already got strings in place. Just need to check expressions such as if a string is added to a string
-
Improved the Terminal so now it can deal with accurate colors when changing them. Still need to add FOR and WHILE loops to the interpreter but for now the IF statement has been added.
https://twitter.com/Lucas1904875369/status/1380299468583493634?s=20
-
OK Type checking is down (Sort of). I need to do a lot of tests.
-
I've split my project into 2 different directions. 1) Keeping it as an interpreter. 2) Turning it into a compiler and translating the code line by line into an IR. Where the entire code will be translated into bytecode and run on a VM.
-
@NextWithoutFor Special characters can be used in the Terminal as this is mainly adding functionality to the Terminal.
However, Fuze's Fonts are limited and thus a lot of the ascii characters are not all available. Which means one would need to create their own fonts.
So what I can do is split the project into two.
One project will only have text and the other will incorporate graphics into it.The text version will be released first then the graphics version. (Though this would requre a lot more functionality but can be done).
Also, I wanted to point out that the version of BASIC I'm interpreting is the GW-BASIC version. This is a slightly upgraded version of C64 BASIC.
for example:
C64 BASIC FunctionsDEF FN foo(x) = x*x
GW-BASIC Functions
//GW-BASIC Functions can have more arguments //While C64 BASIC only allows one Numerical argument. DEF FNmax(x,y) = x*(x>y)+(y>x)*y
So for example, to move the cursor in GW-BASIC you just need to use the
LOCATE x,y
built in Function which moves the cursor atx,y
coords. -
@NextWithoutFor yes.
-
Ok. Managed to get this interpreter working. Still needs to be tested. But so far it works just like the old BASIC. Hope you guys have fun making text games with this. Arrays and user functions have not been implemented yet. I'm still learning how to build interpreters and compilers which is a pretty huge field but getting there slowly.
SHARE CODE: B6Y73MND9K (pending)
https://twitter.com/Lucas1904875369/status/1387147463203516417?s=19
EDIT: Changed the syntax of the language a bit. Arrays are now supported but now all variable must be declared once.
10 DIM A AS STRING 20 DIM B AS INTEGER
The same is done for arrays.
30 DIM C(10) AS STRING 40 DIM D(20) AS INTEGER
-
I just downloaded this, it’s a shame there’s no built-in keyboard as I don’t have one. I was wondering if I could animate Dizzy with binary and about 300 lines of code, as I used to do on my ZX!
-
@AndyG1985 I'll see what i can do concerning a built in keyboard. More built in functions will be added soon.