Skip to content

quarkiverse/quarkus-bon-jova-rockstar

Repository files navigation

Bon Jova

An implementation of Rockstar as a JVM language

Rockstar is an example of an “esoteric language,” designed to be interesting rather than intuitive, efficient or especially functional. Rockstar’s interesting feature is that its programs use the lyrical conventions of eighties rock ballads. Rockstar has been implemented in many languages, but not as a JVM language. (There are existing Java implementations, but they rely on interpretation, rather than compilation to bytecode.) This is clearly (clearly!) a gap that needed fixing.

This implementation uses the Antlr grammar for Rockstar by Andreas Scheja as a starting point.

Using the extension

Create a Quarkus app, and add the extension to your pom; it will then compile .rock files from src/main/rockstar and any other <sourceDirectory> defined in the pom.xml.

Developing the extension

Getting started

In the top-level directory, run

mvn install

This will build the Rockstar parser, the Quarkus extension, and the sample app. You can then run the sample app with

cd samples
mvn quarkus:dev

(To test out your local extension changes, make sure to change the extension version in the app pom to -SNAPSHOT.)

IDE integration

After cloning the repo, you will need to run mvn compile in the bon-jova-rockstar-compiler folder to generate the Antlr Java classes, or your IDE will report compile failures and missing classes. (A top-level mvn install will also work.) The generated classes will appear in target/generated-sources, so you may also need to configure your IDE to treat that folder as a generated sources folder.

What's implemented

See the spec for details and the definitive list of capabilites. Some of these may work but have not been validated with tests.

General

  • Enforcement of the file extension and encoding
  • Comments

✓ Variables and constants

  • Simple variables
  • Common variables
  • Proper variables
  • Dynamic typing of variables
  • Case insensitivity of variable names
  • Pronoun variable references
  • Number literals
  • Poetic number literals
  • String literals
  • Poetic string literals

✓ Types

  • Mysterious
  • Null equality to 0 and false
  • Null aliases nothing, nowhere, nobody, gone
  • True aliases right, yes, ok
  • False aliases wrong, no, lies

Arrays

  • Reading at numerical indexes
  • Array initialisation by setting a value at an index
  • Non-numeric array keys
  • Use the array index syntax to read (but not write) specific characters from a string

Queue operations

  • Pushing
  • Popping
  • Special roll x into y syntax for removing the first element from an array and assigning it to a variable
  • Special syntax for pushing poetic literals onto a queue

Splitting and joining strings

  • Split a string in Rockstar, use the cut mutation (aliases split and shatter)
  • Split strings in place
  • Delimiters
  • The join support

✓ Casting

  • Casting strings to doubles
  • Casting using bases other than 10
  • Casting expressions into a variable
  • Casting numbers to strings using UTF-8 conversions

✓ Single quotes

  • Equivalency to `is'
  • Ignoring in other cases

Number operations

  • Incrementing and decrementing
  • Arithmetic operators
  • Aliases for arithmetic operators
  • Compound assignment using let
  • Rounding
  • Rounding with pronouns
  • List arithmetic
  • Operator precedence

✓ Comparison and logical operations

  • Equality tests
  • Comparisons to mysterious and null
  • Conjunction
  • Disjunction
  • Joint denial
  • Negation

✓ Input and output

  • Input from stdin
  • Output to stdout

✓ Flow control

  • Conditionals
  • Loops
  • Blocks, break, and continue
  • Functions
  • The with keyword for parameters