Majestik is an attempt to implement the Magik programming language1, using ANTLR42 and Java's Class-File API3. It is currently in the very early stages of development and lacks most features.
Majestik is composed of three core components:
-
Lexer/Parser: This component parses the Magik source code and constructs an Abstract Syntax Tree (AST).
Currently, the ANTLR4 grammar only understands the literal types
string
,integer
andfloat
; the expressioninvoke
andblock
statements, as well as simple assignments (<<
). All other tokens are ignored. -
Compiler: This component translates the AST into JVM bytecode using the Class-File API.
Currently, only supports literal types
string
,integer
andfloat
; as well as theinvoke
expressions. -
Runtime: provides a standard library with basic functionality to run a Magik program.
As of now, only the
write
variable in thesw
package has a barebones implementation.
In the project's current state, it is possible (and pretty much limited just to) run a Magik "Hello World" example program4.
_block
world << "World!"
write("Hello")
write(world)
int << 12345
write(int)
flt << 5.4321
write(flt)
_endblock
mvn package
java --enable-preview -jar target/majestik-0.0.0-SNAPSHOT.jar helloworld.magik
-
Q: Why does Majestik require JDK 23? A: Majestik uses the Class-File API3, which was introduced as a preview feature in Java 23.
-
Q: Can generated class files be used in a (Smallworld) Magik session? A: Yes, they can be used in a Magik session, provided the Magik session is started with JDK 23 and preview features are enabled.