-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add implementation of trace/0 #323
Comments
I would suggest to instead include With |
HI, @Thihup! Thank you for the request! Let me break down your request first. Let's say our version of If you want an interactive debugger, I'm afraid it's probably out of the scope of this project. Since it's an embeddable scripting engine decoupled from the UI, It's not always connected to the terminal or it might not have any user interactions at all. The best we can do along this line is to provide hooks like If you just want logs, why don't we go with package main
import (
"os"
"github.com/ichiban/prolog"
)
func main() {
i := prolog.New(nil, os.Stdout)
// Simplified version of https://github.com/mthom/scryer-prolog/blob/master/src/lib/debug.pl
if err := i.Exec(`
:- op(900, fx, $).
:- op(900, fx, $-).
:- op(950, fy, *).
$-Goal :-
catch(Goal, Exception, (portray_clause(exception:Exception:Goal), throw(Exception))).
$Goal :-
portray_clause(call:Goal),
$-Goal,
portray_clause(exit:Goal).
* _.
portray_clause(Clause) :-
write(Clause),
nl.
`); err != nil {
panic(err)
}
if err := i.Exec(`
classIsTypeSafe(Class) :-
$ classClassName(Class, Name),
$ classDefiningLoader(Class, L),
$ superclassChain(Name, L, Chain),
$ Chain \= [],
$ classSuperClassName(Class, SuperclassName),
$ loadedClass(SuperclassName, L, Superclass),
$ classIsNotFinal(Superclass),
$ classMethods(Class, Methods),
$ checklist(methodIsTypeSafe(Class), Methods).
classClassName(foo, 'com.example.foo.Foo').
`); err != nil {
panic(err)
}
_ = i.QuerySolution(`classIsTypeSafe(foo).`)
}
|
I think the |
Hi.
Thanks for this project!
I'm considering using it as the interpreter for the Bytecode verifier of the Java Virtual Machine Specification.
However, as this specification is very dense, sometimes it is hard to know why some predicates failed.
So my request would be to add
trace/0
like SWI-Prolog and GNU Prolog include.I also tried to use
:- set_prolog_flag(debug, on).
but it didn't help in the tracing.The text was updated successfully, but these errors were encountered: