qbjc
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

build

qbjc

qbjc is a QBasic to JavaScript compiler. It compiles a QBasic program into a JavaScript module that can run directly as a standalone program:

Compiling and running a simple program

Usage

# Install from NPM
npm install -g qbjc
# Compile hello.bas and write output to hello.bas.js
qbjc hello.bas
# ...or run hello.bas directly:
qbjc --run hello.bas

Compatibility

What works:

  • Core language features
    • Control flow structures - loops, conditionals, GOTO, GOSUB etc.
    • Data types - primitive types, arrays and user-defined types (a.k.a. records)
    • Expressions - arithmetic, string, comparison, boolean
    • Built-in functions like VAL, STR$, INSTR, MID$ - see full list
    • SUBs and FUNCTIONs
    • DATA constants
  • Text mode
    • Basic text I/O - PRINT, INPUT, INKEY$, INPUT$ etc.
    • Text mode screen manipulation - COLOR, LOCATE etc.
    • Note that the current implementation requires a VT100-compatible terminal emulator. On Windows, this means using WSL or something like PuTTY.

It's just enough to run the original NIBBLES.BAS game that shipped with QBasic:

Compiling and running NIBBLES.BAS

See examples and tests for an idea of what is currently possible.

What doesn't work (yet):

  • Running in the browser
  • Graphics and audio
  • Events - ON ERROR, ON TIMER etc.
  • OS APIs like files I/O, CALL INTERRUPT etc.
  • Direct memory access - PEEK, POKE etc.
  • Less common syntax, inputs or options for statements and built-in functions
  • ...and a lot more - contributions are welcome!

Command line options

Usage: qbjc [options] <file.bas>

Options:
  -V, --version        output the version number
  -o, --output <file>  output file path
  -r, --run            run the compiled program after compilation
  --minify             minify the compiled program
  --source-map         enable source map generation
  --no-bundle          disable bundling with runtime code
  --debug-ast          enable generation of AST file for debugging compilation
  --debug-trace        enable stack trace for debugging compilation
  -h, --help           display help for command

About

qbjc is distributed under the Apache License v2.

Readme

Keywords

none

Package Sidebar

Install

npm i qbjc

Weekly Downloads

1

Version

0.0.3

License

Apache-2.0

Unpacked Size

821 kB

Total Files

123

Last publish

Collaborators

  • jichu4n