TrekBasicJ is a BASIC interpreter and compiler.
TrekBasic is part of the TrekBasic family of BASIC programming tools.
| LOGO | Project | Description | Language | Interpreter | Compiler |
|---|---|---|---|---|---|
| TrekBasic | Basic compiler and interpreter | Python | Yes | Yes | |
| TrekBasicJ | Basic compiler and interpreter | Java | Yes | Yes | |
| BasicRS | Basic compiler and interpreter | Rust | Yes | Yes | |
| BasicTestSuite | A test suite for Basic | BASIC | - | - | |
| TrekBot | A tool to exercise the superstartrek program | Rust | - | - |
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
/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
./gradlew test
Looks like we have to carefully match gradle and java verisons. this worked:
% ./gradlew --version
------------------------------------------------------------
Gradle 8.13
------------------------------------------------------------
Build time: 2025-02-25 09:22:14 UTC
Revision: 073314332697ba45c16c0a0ce1891fa6794179ff
Kotlin: 2.0.21
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024
Launcher JVM: 23.0.2 (Amazon.com Inc. 23.0.2+7-FR)
Daemon JVM: /Users/tomhill/Library/Java/JavaVirtualMachines/corretto-23.0.2/Contents/Home (no JDK specified, using current Java home)
OS: Mac OS X 15.5 aarch64
the message
> Could not create an instance of type org.gradle.api.reporting.internal.DefaultReportContainer.
> Type T not present
Seems to indicate a version mismatch.
export JAVA_HOME="/Users/tomhill/Library/Java/JavaVirtualMachines/corretto-23.0.2/Contents/Home"
./gradlew --stop
./gradlew clean
./gradlew build
./gradlew test