compile

fun compile(program: MiniKotlinParser.ProgramContext, className: String = "MiniProgram"): String

Compiles an entire MiniKotlin program to a single Java source file.

The output is a public class [className] containing one public static method per MiniKotlin function. If the program declares a main(): Unit function, an additional standard Java entry point public static void main(String[] args) is emitted that bootstraps the CPS main with a no-op terminal continuation.

SharedCounters are reset before compilation begins so that output is deterministic for a given input.

Return

A complete Java source file as a String.

Parameters

program

The root of the ANTLR parse tree produced by MiniKotlinParser.program.

className

The name of the generated Java class. Defaults to "MiniProgram". The caller is responsible for writing the output to a file named <className>.java.