Fix double printing
This commit is contained in:
parent
bfb509f41f
commit
1e087c8339
3 changed files with 12 additions and 6 deletions
|
@ -2,6 +2,7 @@ package interpreter
|
|||
|
||||
import io.Logger
|
||||
import prolog.ast.arithmetic.Expression
|
||||
import prolog.ast.arithmetic.Integer
|
||||
import prolog.ast.logic.Clause
|
||||
import prolog.ast.logic.Fact
|
||||
import prolog.ast.logic.LogicOperand
|
||||
|
@ -56,6 +57,8 @@ open class Preprocessor {
|
|||
Structure(Atom("fail"), emptyList()) -> Fail
|
||||
Atom("!") -> Cut()
|
||||
Structure(Atom("!"), emptyList()) -> Cut()
|
||||
Atom("inf") -> Integer(Int.MAX_VALUE)
|
||||
Atom("nl") -> Nl
|
||||
is Structure -> {
|
||||
// Preprocess the arguments first to recognize builtins
|
||||
val args = term.arguments.map { preprocess(it) }
|
||||
|
@ -115,6 +118,10 @@ open class Preprocessor {
|
|||
Between(args[0] as Expression, args[1] as Expression, args[2] as Expression)
|
||||
}
|
||||
|
||||
// Other
|
||||
term.functor == "write/1" -> Write(args[0])
|
||||
term.functor == "read/1" -> Read(args[0])
|
||||
|
||||
else -> term
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue