45 lines
1.2 KiB
Kotlin
45 lines
1.2 KiB
Kotlin
import com.sun.org.apache.bcel.internal.util.Args
|
|
import com.xenomachina.argparser.ArgParser
|
|
import com.xenomachina.argparser.mainBody
|
|
import interpreter.FileLoader
|
|
import io.GhentPrologArgParser
|
|
import io.Logger
|
|
import prolog.Program
|
|
import prolog.ast.logic.Clause
|
|
import repl.Repl
|
|
|
|
fun main(args: Array<String>) = mainBody {
|
|
// Parse command line arguments
|
|
val parsedArgs = ArgParser(args).parseInto(::GhentPrologArgParser)
|
|
|
|
parsedArgs.run {
|
|
val loader = FileLoader()
|
|
|
|
// Set the verbosity level
|
|
Logger.level = verbosity
|
|
|
|
// Check if script was provided
|
|
for (file in script) {
|
|
loader.load(file)
|
|
}
|
|
|
|
// Check if REPL was requested
|
|
if (repl) {
|
|
Repl().start()
|
|
} else {
|
|
Logger.warn("REPL not started. Use -r or --repl to start the REPL.")
|
|
}
|
|
}
|
|
}
|
|
|
|
fun help() {
|
|
println("""
|
|
Ghent Prolog: A Prolog interpreter in Kotlin
|
|
|
|
Options:
|
|
-s, --source <file> Specify the source file to load
|
|
-r, --repl Start the REPL (default)
|
|
-v, --verb
|
|
-h, --help Show this help message
|
|
""".trimIndent())
|
|
}
|