TrekBasicJ is a BASIC interpreter and compiler.
TrekBasicJ is part of the TrekBasic family of BASIC programming tools.
- TrekBasic - Basic compiler and interpreter in Python
- TrekBasicJ - Basic compiler and interpreter in Java
- BasicRS - Basic compiler written in Rust
- BasicTestSuite - A test suite of BASIC Programs
- TrekBot - A tool to exercise the superstartrek program
All versions, interpreted and compiled, are intended to by byte-by-byte compatible, but are not there yet - but they are close. TrekBot and BasicTestSuite are part of the plan to ensure full compatibility.
The interpreter can run anywhere you can run Java.
Set JAVA_HOME to your JDK.
For example:
export JAVA_HOME=/Users/homedir/Library/Java/JavaVirtualMachines/corretto-23.0.2/Contents/Home
java -cp build/classes/java/main com.worldware.Main superstartrek.bas
java -cp build/classes/java/main com.worldware.BasicShell x.bas
TrekBasicJ is not a full compiler - it generates code that can be processed by a compiler backend to produce an executable.
TrekBasicJ generates intermediate representation for LLVM, and this is compiled with clang, which is availably basically everywhere,
The compiled code can run anywhere you can have clang (c compiler) generate an executable for. This covers dozens of platforms. Every common architecture and a lot of uncommon ones.
% java -Xmx100m -cp build/classes/java/main com.worldware.Tbc x.bas x.exe
/Users/tomhill/Library/Java/JavaVirtualMachines/corretto-23.0.2/Contents/Home/bin/java
-cp build/classes/java/main com.worldware.Main
/Users/tomhill/PycharmProjects/TrekBasic/programs/superstartrek.bas
TO RUN WITH GRADLE (slower, but builds if necessary)
./gradlew run -Pargs="/Users/tomhill/PycharmProjects/TrekBasic/programs/superstartrek.bas"
TO COMPILE (not full Support yet) % java -Xmx100m -cp build/classes/java/main com.worldware.Tbc x.bas x Written LLVM IR to x.ll
clang -o x x.ll warning: overriding the module target triple with arm64-apple-macosx15.0.0 [-Woverride-module] 1 warning generated. % ./x 3