Skip to content

Fast text formatting language for Java.

License

Notifications You must be signed in to change notification settings

ccetl/starscript

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Starscript

Fast text formatting language for Java.

  • Lightweight with no dependencies
  • Faster than String.format (See Benchmark)
  • Standard operators + - * / % ^
  • Ability to call functions defined in java
  • Variables can be different each time they are used
  • Conditional output (ternary operator)
  • Variables can be maps

Examples

  • Hello {name}!
  • Number: {someNumber * 100}
  • FPS: {round(fps)}
  • Today is a {good ? 'good' : 'bad'} day
  • Name: {player.name}

Usage

Gradle:

repositories {
    maven {
        name = "meteor-maven"
        url = "https://maven.meteordev.org/releases"
    }
}

dependencies {
    implementation "meteordevelopment:starscript:0.2.2"
}

Java:

// Parse
Parser.Result result = Parser.parse("Hello {name}!");

// Check for errors
if (result.hasErrors()) {
    for (Error error : result.errors) System.out.println(error);
    return;
}

// Compile
Script script = Compiler.compile(result);

// Create starscript instance
Starscript ss = new Starscript();
StandardLib.init(ss); // Adds a few default functions, not required

ss.set("name", "MineGame159");
// ss.set("name", () -> Value.string("MineGame159"));

// Run
System.out.println(ss.run(script)); // Hello MineGame159!

Documentation

Full syntax and features can be found on wiki.
Javadocs can be found here.

About

Fast text formatting language for Java.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%