google / wwwbasic

wwwBASIC is an implementation of BASIC that runs on Node.js and the Web.
Apache License 2.0
1.14k stars 61 forks source link

Support for BASIC dialects #22

Open cactysman opened 6 years ago

cactysman commented 6 years ago

I'm not experienced with BASIC, but QBASIC and GWBASIC seem to be dialects of BASIC with diverging functionality.

Maybe it would be wise to modularize the dialect specific code and make it two separate functions to allow explicitly running BASIC using the .Basic() function and e.g. QBASIC using .QBasic()

   var basic = require('wwwbasic')
-- basic.Basic(`
++ basic.QBasic(`
     10 PRINT "HELLO WORLD"
     20 GOTO 10
   `)

Otherwise maybe add an optional option parameter to specify support for certain extensions / dialects / whatever.

var basic = require('wwwbasic')
basic.Basic({ qbasic: true }, `
  10 PRINT "HELLO WORLD"
  20 GOTO 10
`)

Related to #10 #11 #12 #21

FellippeHeitor commented 6 years ago

The original look of the output screens indicated an earlier version of BASIC as target, but since we're aiming at Nibbles and Gorillas, I understand QBasic is going to be the broader goal, so maybe it'd be the case to indicate when an older command set is to be supported instead.

thomasmcneill commented 6 years ago

Why not have a type of preprocessor command that allows us to indicate which version of BASIC the code is targeting? This would allow us to implement certain PEEK/POKE instructions based on the target.

10 TARGET=QB45 10 TARGET=PCDOS 10 TARGET=TRS80III <--- where I started

flagxor commented 6 years ago

I imagine we'll likely want a few different ways to specify dialect:

Theoretically QBasic is a superset of GWBASIC which is a superset of BASICA, but that's not entirely true as each has a definition defined by a single implementation and there are quirks + intentional breaks in compat.

FreeBasic I believe mushes together things by default, but has options for specific dialects.

Probably some thought needs to go into:

FellippeHeitor commented 6 years ago

In QB64, we have QBasic/QuickBASIC 4.5 as a goal for compatibility. Eventual retrocompatibility was indirectly implemented because of them being a superset of GWBASIC (namely the syntax for the OPEN command for one). I know Freebasic has a #lang switch right?