Compare commits
2 commits
8bda3c5af4
...
973365e2ec
Author | SHA1 | Date | |
---|---|---|---|
973365e2ec | |||
e1763e0510 |
3 changed files with 30 additions and 2 deletions
|
@ -63,6 +63,8 @@ open class Preprocessor {
|
||||||
Functor.of("functor/3") -> FunctorOp(args[0], args[1], args[2])
|
Functor.of("functor/3") -> FunctorOp(args[0], args[1], args[2])
|
||||||
Functor.of("arg/3") -> Arg(args[0], args[1], args[2])
|
Functor.of("arg/3") -> Arg(args[0], args[1], args[2])
|
||||||
Functor.of("clause/2") -> ClauseOp(args[0] as Head, args[1] as Body)
|
Functor.of("clause/2") -> ClauseOp(args[0] as Head, args[1] as Body)
|
||||||
|
Functor.of("atomic/1") -> AtomicOp(args[0])
|
||||||
|
Functor.of("compound/1") -> CompoundOp(args[0])
|
||||||
|
|
||||||
// Arithmetic
|
// Arithmetic
|
||||||
Functor.of("inf/0") -> Integer(Int.MAX_VALUE)
|
Functor.of("inf/0") -> Integer(Int.MAX_VALUE)
|
||||||
|
@ -111,7 +113,6 @@ open class Preprocessor {
|
||||||
Functor.of("!/0") -> Cut()
|
Functor.of("!/0") -> Cut()
|
||||||
Functor.of(",/2") -> Conjunction(args[0] as LogicOperand, args[1] as LogicOperand)
|
Functor.of(",/2") -> Conjunction(args[0] as LogicOperand, args[1] as LogicOperand)
|
||||||
Functor.of(";/2") -> Disjunction(args[0] as LogicOperand, args[1] as LogicOperand)
|
Functor.of(";/2") -> Disjunction(args[0] as LogicOperand, args[1] as LogicOperand)
|
||||||
Functor.of("|/2") -> Bar(args[0] as LogicOperand, args[1] as LogicOperand)
|
|
||||||
Functor.of("\\+/1") -> Not(args[0] as Goal)
|
Functor.of("\\+/1") -> Not(args[0] as Goal)
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
|
|
|
@ -137,3 +137,23 @@ class ClauseOp(private val head: Head, private val body: Body) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AtomicOp(private val term: Term) : Operator(Atom("atomic"), null, term) {
|
||||||
|
override fun satisfy(subs: Substitutions): Answers {
|
||||||
|
return if (atomic(term, subs)) {
|
||||||
|
sequenceOf(Result.success(emptyMap()))
|
||||||
|
} else {
|
||||||
|
emptySequence()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CompoundOp(private val term: Term) : Operator(Atom("compound"), null, term) {
|
||||||
|
override fun satisfy(subs: Substitutions): Answers {
|
||||||
|
return if (compound(term, subs)) {
|
||||||
|
sequenceOf(Result.success(emptyMap()))
|
||||||
|
} else {
|
||||||
|
emptySequence()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -55,7 +55,14 @@ class Repl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"a" -> return
|
"" -> {
|
||||||
|
io.checkNewLine()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
"a" -> {
|
||||||
|
io.checkNewLine()
|
||||||
|
return
|
||||||
|
}
|
||||||
"." -> {
|
"." -> {
|
||||||
io.checkNewLine()
|
io.checkNewLine()
|
||||||
return
|
return
|
||||||
|
|
Reference in a new issue