Re: [eclipse-clp-users] Consult failure

From: Joachim Schimpf <jschimpf_at_coninfer.com>
Date: Fri, 19 Aug 2011 15:50:22 +0200
Kish Shen wrote:
> Hi Jan,
> 
> On 18/08/2011 17:23, Jan Burse wrote:
>>
>> expr(Z) -->  "-", !, term(X), {Y is -X}, expr_rest(Y,Z).
>> expr(Y) -->  term(X), expr_rest(X,Y).
>>
>> expr_rest(X,T) -->  "+", !, term(Y), {Z is X+Y}, expr_rest(Z,T).
>> expr_rest(X,T) -->  "-", !, term(Y), {Z is X-Y}, expr_rest(Z,T).
>> expr_rest(X,X) -->  [].
>>
...
> 
> So the error is because the grammar rule you wrote is not valid for 
> ECLiPSe -- this is because ECLiPSe have proper strings (as an atomic 
> type), so the strings such as "." are real strings, and not list of 
> ASCII code, and this is causing the error.


To be more concrete: to make your rules work with ECLiPSe,
you can either

(1) use one of the compatibility libraries, i.e. prefix a directive like

:- lib(iso).	% alternatively cprolog,quintus,swi,...


(2) or change the meaning of the quotes explicitly, using

:- local chtab(0'`, string_quote).
:- local chtab(0'", list_quote).


(3) or rewrite your rules using list syntax, e.g. [0'-] instead of "-".


-- Joachim
Received on Fri Aug 19 2011 - 13:50:31 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET