This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../src/Main.kt
2025-04-28 13:36:24 +02:00

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())
}