Skip to content

What does syntax_error(incomplete_reduction) mean when appearing from a call of phrase/2? #2196

Answered by triska
razetime asked this question in Q&A
Discussion options

You must be logged in to vote

Regarding debugging: Since we know the error arises from number_chars/2, we can use ($)/1 from library(debug) to get more information about how the predicate is invoked. Simply prepend $ to the goal:

:- 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 [] has no characters that can be parsed to a number:

?- number_chars(A,[]).
   error(syntax_error(incomplete_reduction),number_chars/2:0).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by razetime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants