Skip to content

MeteorDevelopment/starscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 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

Languages