Preprocessing
This commit is contained in:
parent
82a8fccf87
commit
174855d7a3
5 changed files with 284 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
package repl
|
||||
|
||||
import interpreter.Preprocessor
|
||||
import io.Logger
|
||||
import io.Terminal
|
||||
import parser.ReplParser
|
||||
|
@ -9,6 +10,7 @@ import prolog.Answers
|
|||
class Repl {
|
||||
private val io = Terminal()
|
||||
private val parser = ReplParser()
|
||||
private val preprocessor = Preprocessor()
|
||||
|
||||
fun start() {
|
||||
io.say("Prolog REPL. Type '^D' to quit.\n")
|
||||
|
@ -23,7 +25,8 @@ class Repl {
|
|||
|
||||
fun query(): Answers {
|
||||
val queryString = io.prompt("?-", { "" })
|
||||
val query = parser.parse(queryString)
|
||||
val simpleQuery = parser.parse(queryString)
|
||||
val query = preprocessor.preprocess(simpleQuery)
|
||||
return query.satisfy(emptyMap())
|
||||
}
|
||||
|
||||
|
@ -46,7 +49,10 @@ class Repl {
|
|||
}
|
||||
|
||||
when (command) {
|
||||
";" -> previous = iterator.next()
|
||||
";" -> {
|
||||
previous = iterator.next()
|
||||
io.say(prettyPrint(previous))
|
||||
}
|
||||
"a" -> return
|
||||
"." -> return
|
||||
"h" -> {
|
||||
|
@ -55,8 +61,6 @@ class Repl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
io.say(prettyPrint(previous))
|
||||
}
|
||||
|
||||
io.say("\n")
|
||||
|
|
Reference in a new issue