File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ tasks {
1414 withType<JavaCompile >().configureEach {
1515 options.release = 25
1616 }
17- }
17+ }
Original file line number Diff line number Diff line change 1+ plugins {
2+ application
3+ alias(libs.plugins.kotlinJvm)
4+ }
5+
6+ dependencies {
7+ implementation(project(" :interpreter" ))
8+ }
9+
10+ application {
11+ mainClass = " MainKt"
12+ }
Original file line number Diff line number Diff line change 1+ import tech.pacia.starlarkt.interpreter.Interpreter
2+ import tech.pacia.starlarkt.interpreter.StarInterpreterException
3+ import java.io.IOException
4+ import java.nio.file.Files
5+ import java.nio.file.Path
6+ import kotlin.system.exitProcess
7+
8+ fun main (args : Array <String >) {
9+ println (" Hello, World!" )
10+
11+ val verbose = true
12+
13+ if (args.size != 1 ) {
14+ System .err.println (" must pass exactly 1 argument which is a path to a .star file" )
15+ exitProcess(1 )
16+ }
17+
18+ val filePath: Path = Path .of(args[0 ])
19+ val fileContent: String?
20+ try {
21+ fileContent = Files .readString(filePath)
22+ } catch (e: IOException ) {
23+ throw RuntimeException (e)
24+ }
25+
26+ val interpreter = Interpreter ()
27+ try {
28+ interpreter.execute(fileContent)
29+ } catch (e: StarInterpreterException ) {
30+ if (verbose) {
31+ e.printStackTrace()
32+ } else {
33+ System .err.println (e.message)
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher
1010
1111[plugins ]
1212kotlinMultiplatform = { id = " org.jetbrains.kotlin.multiplatform" , version.ref = " kotlin" }
13+ kotlinJvm = { id = " org.jetbrains.kotlin.jvm" , version.ref = " kotlin" }
Original file line number Diff line number Diff line change @@ -20,3 +20,4 @@ dependencyResolutionManagement {
2020include(" app" )
2121include(" interpreter" )
2222include(" :examples:java-sample" )
23+ include(" :examples:kotlin-sample" )
You can’t perform that action at this time.
0 commit comments