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.
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
.
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
.)
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.
See the spec for details and the definitive list of capabilites. Some of these may work but have not been validated with tests.
- Enforcement of the file extension and encoding
- Comments
- 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
- Mysterious
- Null equality to 0 and false
- Null aliases
nothing
,nowhere
,nobody
,gone
- True aliases
right
,yes
,ok
- False aliases
wrong
,no
,lies
- 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
- 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
- Split a string in Rockstar, use the
cut
mutation (aliasessplit
andshatter
) - Split strings in place
- Delimiters
- The
join
support
- Casting strings to doubles
- Casting using bases other than 10
- Casting expressions into a variable
- Casting numbers to strings using UTF-8 conversions
- Equivalency to `is'
- Ignoring in other cases
- Incrementing and decrementing
- Arithmetic operators
- Aliases for arithmetic operators
- Compound assignment using
let
- Rounding
- Rounding with pronouns
- List arithmetic
- Operator precedence
- Equality tests
- Comparisons to mysterious and null
- Conjunction
- Disjunction
- Joint denial
- Negation
- Input from stdin
- Output to stdout
- Conditionals
- Loops
- Blocks, break, and continue
- Functions
- The
with
keyword for parameters