Skip to content

QB2C is a single-file C transpiler that converts a subset of QBasic programs into C code using the Ncurses library. It supports basic QBasic features including PRINT, INPUT, IF...THEN...ELSE, FOR loops, CLS, SLEEP, and GOTO statements. Designed for running classic QBasic programs in a modern terminal environment on Linux/Unix systems.

License

Notifications You must be signed in to change notification settings

Cod-e-Codes/qb2c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

QB2C: QBasic to C (Ncurses) Transpiler

QB2C is a single-file C program designed to transpile a subset of QBasic code into C code utilizing the Ncurses library for terminal I/O. This allows simple QBasic programs to be compiled and run on modern Linux/Unix systems.

Workflow

Compile the Transpiler:

gcc qb2c.c -o qb2c

Transpile the QBasic File (.bas):

The transpiler reads the QBasic file and outputs the generated C code to standard output, which should be redirected to a new .c file.

./qb2c demo.bas > demo.c

Compile the Generated C Program:

The generated C code must be linked against the Ncurses library (-lncurses).

gcc demo.c -o demo -lncurses

Run the Executable:

./demo

Supported QBasic Features

  • REM and ' (Comments)
  • CLS (Clear screen)
  • PRINT (Outputting strings and variables; supports ; separator)
  • INPUT (Receiving input for numeric and string variables)
  • LET (Implicit assignments for numeric and string variables)
  • IF...THEN...ELSE...END IF (Conditional blocks)
  • FOR...NEXT Loops (Iterative blocks)
  • SLEEP (Uses napms for pausing execution)
  • GOTO and Labels (Jump statements)

Known Issues (Current State)

  • FOR loops in the demo may not produce correct results.
  • Future enhancements could include support for WHILE/WEND or SUB/END SUB.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

QB2C is a single-file C transpiler that converts a subset of QBasic programs into C code using the Ncurses library. It supports basic QBasic features including PRINT, INPUT, IF...THEN...ELSE, FOR loops, CLS, SLEEP, and GOTO statements. Designed for running classic QBasic programs in a modern terminal environment on Linux/Unix systems.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published