Author Topic: The L-BASIC Interpreter  (Read 23140 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #30 on: July 10, 2020, 11:10:58 pm »
Understood. Thank you for the info.
Logic is the beginning of wisdom.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #31 on: July 11, 2020, 11:10:30 pm »
Nice juicy update for version 0.0.2, now supporting, amongst other things, a bunch of commands beginning with the letter C as well as SCREEN and PLAY. Means you can now draw circles in SCREEN 13 with music to your heart's content.

FellippeHeitor

  • Guest
Re: The 65 BASIC Interpreter
« Reply #32 on: July 12, 2020, 11:40:29 am »
Working great on macOS now with the latest dev build of QB64.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #33 on: January 15, 2021, 08:56:45 am »
Version 0.0.3, featuring a bunch of new commands, user-defined types and experimental support for arrays. See first post for code.

This means it can now run things like:
Code: [Select]
type t
    a as long
    b$
end type

v = 4
dim a(3, v / 2) as t
a(2, 1).a = 4
a(2, 1).b = "hello"

a(3, 2) = a(2, 1)
print a(3, 2).a; a(3, 2).b
Yep, that's a dynamically-sized multi-dimensional array of a user-defined type containing variable length strings.

Arrays are a little untested for now, and you can't resize them. You also can't have arrays in a user-defined type, but that should be coming shortly.

Big thanks again to Ashish for implementing some commands and giving it a good test all round.


Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #34 on: January 15, 2021, 11:11:55 am »
This is great, @luke !  Glad you are continuing with this.  I've got a rather large collection of interpreters written in basic languages - I think yours is one of the best.

- Dav

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #35 on: January 21, 2021, 04:20:32 pm »
Is the make/build process linux only? I'm even having permission/path trouble with *that*, despite chmodding everything and running as admin. Which system(s) is the build process intended for? I'm trying the Linux subsystem for windows 10 and can't even finish the readme.
« Last Edit: January 21, 2021, 04:42:21 pm by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #36 on: January 21, 2021, 06:08:26 pm »
Ashish managed to run the Makefile on Windows using the make that comes with QB64's C++ compiler, but I highly recommend just compiling the file attached to the first post of this thread. You just load it into a recent QB64 version and hit F5.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #37 on: January 21, 2021, 06:16:46 pm »
Myyyy bad, that file was subtle!
You're not done when it works, you're done when it's right.

Offline Ed Davis

  • Newbie
  • Posts: 40
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #38 on: January 21, 2021, 09:00:00 pm »
Makefile on Windows:

For me, all I had to change was this:
From:
# This should point to your QB64 installation
QB64 := /home/luke/comp/git_qb64/qb64 -q -w

To:
# This should point to your QB64 installation
QB64 := $(USERPROFILE)/bin/bas/qb64/qb64 -q -w

And then make does the needful.

Offline Ed Davis

  • Newbie
  • Posts: 40
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #39 on: January 21, 2021, 09:45:19 pm »
I really like the test.bas supplied with 65.  I've been using it for some of my own unit testing, and it works great!

To get it working on Windows, I only had to make a few simple changes:

Code: QB64: [Select]
  1. 'If on Windows, get the temporary path
  2. 'Inserted after line 26
  3.   >if instr(_os$, "WINDOWS") > 0 then
  4.   >    tmpdir$ = environ$("TEMP") + "\"
  5.   >end if
  6.  
  7. 'Windows doesn't like ":" in filenames
  8. 'Changed line 68
  9.   >    filename$ = tmpdir$ + "test-" + date$ + time$ + "-" + rndhex$(4)
  10. 'To
  11.   >    t$ = time$
  12.   >    if instr(_os$, "WINDOWS") > 0 then t$ = replace_char(t$, ":", "_")
  13.   >    filename$ = tmpdir$ + "test-" + date$ + "-" + t$ + "-" + rndhex$(4)
  14.  
  15. 'Get rid of those pesky chr$(13) that Windows uses
  16. 'Inserted after line 86
  17.   >
  18.   >        actual_output$                     = remove_char$(actual_output$, chr$(13))
  19.   >        tests(active_test).expected_output = remove_char$(tests(active_test).expected_output, chr$(13))
  20.   >
  21.  
  22. 'Two simple routines - probably a better way, but these work for now
  23. 'Inserted after line 125
  24.   >
  25.   >function replace_char$(s$, c1$, c2$)
  26.   >    dim p as integer
  27.   >
  28.   >    do
  29.   >        p = instr(s$, c1$)
  30.   >        if p > 0 then mid$(s$, p, 1) = c2$ else exit do
  31.   >    loop
  32.   >    replace_char$ = s$
  33.   >
  34.   >function remove_char$(s$, c$)
  35.   >  dim s2$
  36.   >  dim i as integer
  37.   >
  38.   >  s2$ = ""
  39.   >  for i = 1 to len(s$)
  40.   >    if mid$(s$, i, 1) <> c$ then
  41.   >      s2$ = s2$ + mid$(s$, i, 1)
  42.   >    end if
  43.   >  next
  44.   >  remove_char$ = s2$

Now test.bas works for me on Windows!
« Last Edit: January 21, 2021, 09:49:10 pm by Ed Davis »

Offline Ed Davis

  • Newbie
  • Posts: 40
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #40 on: January 21, 2021, 10:52:32 pm »
I've got a rather large collection of interpreters written in basic languages ...
- Dav

Is this something you are willing to make available?

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #41 on: January 21, 2021, 10:59:27 pm »
Is this something you are willing to make available?

I suppose I could, Ed.  I think I have one by you (I recognize the name).  Didn't you make the Toy Interpreter? Or something named like that...

- Dav
« Last Edit: January 21, 2021, 11:01:36 pm by Dav »

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #42 on: January 22, 2021, 12:00:09 am »
I really like the test.bas supplied with 65.  I've been using it for some of my own unit testing, and it works great!

To get it working on Windows, I only had to make a few simple changes:

Thanks for letting me know, I'll look at adding those changes to make it cross-platform.

Offline Ed Davis

  • Newbie
  • Posts: 40
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #43 on: January 22, 2021, 12:05:38 am »
I suppose I could, Ed.  I think I have one by you (I recognize the name).  Didn't you make the Toy Interpreter? Or something named like that...

- Dav
Yep, I'm guilty of that one.

I also made the infamous tiny interpreter that used to be in the QB64 sample programs directory.   Someone modified it somewhat, but it still has some of my original bugs :)

You can see my original Tiny Basic post here (Feb 19, 2007, 7:16:12 AM) as part of the thread "Recommend a book on how to write a BASIC interpreter?"

https://groups.google.com/g/comp.lang.basic.misc/c/3yflBQV35M8/m/ZrPgEe8564gJ

and here:

https://narkive.com/YC5L5jHK.25

Anyway,  not trying to cause you any extra work.  If it is a pain to do, don't worry about it, I'll survive :)

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: The 65 BASIC Interpreter
« Reply #44 on: January 22, 2021, 10:02:30 am »
Oh yes, I remember seeing that one.  I really appreciate all the interpreters you guys shared with everyone. I used to scour the web for interpreters. Most are not in basic, but i sure felt like finding gold when coming up on one.

I got them all littered on several HD's and thumb drives.  Been meaning put them all in one place one day. Maybe now is a good time....

- Dav