|
|
|
|
|
by z5h
605 days ago
|
|
> How do you debug DCGs? I get "false." instead of "syntax error at line 23", which is unacceptable for bigger inputs. I also sympathize. "false" as the default failure mode is a challenge with Prolog. Most Prologs I've used have good debugging/stepping features (see spy and trace predicates), logical debugging of pure monotonic Prolog can often help (explained by Markus Triska), you can easily write (use existing) meta predicates that assert a called predicate must not fail otherwise throw an exception. For example: here the ./ is supposed to look like a checkmark. So `./ true.` is true. `./ false` throws an exception. :- op(920, fy, './').
:- meta_predicate './'(0).
'./'(X) :- call(X) *-> true ; prolog_debug:assertion_failed(fail, X).
|
|