REPL checkpoint
This commit is contained in:
parent
69c156024a
commit
1b3280a947
21 changed files with 503 additions and 34 deletions
23
src/interpreter/SourceFileReader.kt
Normal file
23
src/interpreter/SourceFileReader.kt
Normal file
|
@ -0,0 +1,23 @@
|
|||
package interpreter
|
||||
|
||||
import better_parser.PrologParser
|
||||
|
||||
class SourceFileReader {
|
||||
private val parser = PrologParser()
|
||||
|
||||
fun readFile(filePath: String) {
|
||||
return try {
|
||||
val file = java.io.File(filePath)
|
||||
if (!file.exists()) {
|
||||
throw IllegalArgumentException("File not found: $filePath")
|
||||
}
|
||||
|
||||
val content = file.readText()
|
||||
|
||||
// Parse the content using SimpleSourceParser
|
||||
parser.parse(content)
|
||||
} catch (e: Exception) {
|
||||
throw RuntimeException("Error reading file: $filePath", e)
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue