-
A minimal example: ?- [user]. cube(Num) --> seq(StrNum), { number_chars(Num, StrNum) }. ?- phrase(cube(X),"1"). error(syntax_error(incomplete_reduction),number_chars/2:0). ?- phrase(cube(X),"1",Y). error(syntax_error(incomplete_reduction),number_chars/2:0). I'd like to know how to fix errors like this, that come from within metapredicates, and how best to go about debugging them and finding what's wrong with my logic. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Top of my head, |
Beta Was this translation helpful? Give feedback.
-
Regarding debugging: Since we know the error arises from :- use_module(library(debug)). :- use_module(library(dcgs)). cube(N) --> seq(Cs), { $ number_chars(N, Cs) }. Yielding: ?- phrase(cube(X),"1"). call:number_chars(A,[]). exception:error(syntax_error(incomplete_reduction),number_chars/2:0):number_chars(A,[]). So, yes, as @mthom already mentioned, the empty list ?- number_chars(A,[]). error(syntax_error(incomplete_reduction),number_chars/2:0). |
Beta Was this translation helpful? Give feedback.
Regarding debugging: Since we know the error arises from
number_chars/2
, we can use($)/1
fromlibrary(debug)
to get more information about how the predicate is invoked. Simply prepend$
to the goal:Yielding:
So, yes, as @mthom already mentioned, the empty list
[]
has no characters that can be parsed to a number: