feat: implement CLI for parser

This commit is contained in:
Gleb Koval 2025-02-02 13:48:54 +00:00
parent d4b410bca9
commit 3aae08ffd4
Signed by: cyclane
GPG Key ID: 15E168A8B332382C

View File

@ -31,14 +31,18 @@ val cliParser = {
def compile(contents: String): Int = { def compile(contents: String): Int = {
parser.parse(contents) match { parser.parse(contents) match {
case Success(x) => 0 case Success(ast) =>
case Failure(msg) => 100 // TODO: Do semantics things
0
case Failure(msg) =>
println(msg)
100
} }
} }
def main(args: Array[String]): Unit = def main(args: Array[String]): Unit =
OParser.parse(cliParser, args, CliConfig()) match { OParser.parse(cliParser, args, CliConfig()) match {
case Some(config) => case Some(config) =>
System.exit(scala.util.Random.between(0, 3) * 100) System.exit(compile(os.read(os.Path(config.file.getAbsolutePath))))
case None => case None =>
} }