Skip to content

krn-robin/majestik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Majestik - a Magik implementation

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.

Components

Majestik is composed of three core components:

  1. 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 and float; the expression invoke and block statements, as well as simple assignments (<<). All other tokens are ignored.

  2. Compiler: This component translates the AST into JVM bytecode using the Class-File API.

    Currently, only supports literal types string, integer and float; as well as the invoke expressions.

  3. Runtime: provides a standard library with basic functionality to run a Magik program.

    As of now, only the write variable in the sw package has a barebones implementation.

Features

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

Compiling

mvn package

Running

java --enable-preview -jar target/majestik-0.0.0-SNAPSHOT.jar helloworld.magik

FAQ

  • 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.

Footnotes

  1. Magik (programming language) on Wikipedia

  2. ANTLR4

  3. Class-File API 2

  4. Magik Hello World example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published