[mercury-users] strange mmc behavior
Holger Krug
hkrug at rationalizer.com
Thu Jul 26 16:43:40 AEST 2001
On Thu, Jul 26, 2001 at 07:32:33AM +1000, Fergus Henderson wrote:
> On 25-Jul-2001, Holger Krug <hkrug at rationalizer.com> wrote:
> > :- module lex.
> >
> > :- implementation.
> >
> > :- pred live_lexeme_in_accepting_state(list(live_lexeme(Tok)),
> > annotated_token(Tok)).
> > :- mode live_lexeme_in_accepting_state(in(live_lexeme_list),
> > out(annotated_token)) is semidet.
> >
> > live_lexeme_in_accepting_state([L | Ls], Token) :- % line 412
> > ( if in_accepting_state(L) % line 413
> > then Token = L ^ clxm_token
> > else live_lexeme_in_accepting_state(Ls, Token) % line 415
> > ).
> >
> > If the called predicate `in_accepting_state' is placed in module `lex'
> > all works fine. Difficulties arise immediately when I place
> > `in_accepting_state' into the separate sub-module `lex__lexeme'. In
> > this case the following error occurs:
> >
> > lex.m:415: In clause for `live_lexeme_in_accepting_state(in((lex:live_lexeme_list)), out((lex:annotated_token)))':
> > lex.m:415: mode error in conjunction. The next 2 error messages
> > lex.m:415: indicate possible causes of this error.
> > lex.m:413: In clause for `live_lexeme_in_accepting_state(in((lex:live_lexeme_list)), out((lex:annotated_token)))':
> > lex.m:413: in argument 1 of call to predicate `lex:lexeme:in_accepting_state/1':
> > lex.m:413: mode error: variable `L' has instantiatedness `bound((lex:lexeme):compiled_lexeme(bound((lex:ignore) ; lex:t((func((ground -> ground)) = (free -> ground) is det))), ground, ground))',
> > lex.m:413: expected instantiatedness was `(lex:live_lexeme)'.
> >
> > What is strange in that error message is that both modes:
> > `(lex:live_lexeme)'
> > and
> > `bound((lex:lexeme):compiled_lexeme(bound((lex:ignore) ; lex:t((func((ground -> ground)) = (free -> ground) is det))), ground, ground))'
> > are exactly the same !
>
> Those are insts, not modes.
It was late yesterday.
> Are you sure they are the same? You didn't post the definitions of the
> live_lexeme inst or the live_lexeme_list inst.
Here they are:
%---- file lex.m -------------------------------------------------------------
:- module lex.
:- interface.
:- inst token_creator == (func(in)=out is det).
:- inst annotated_token == bound( t(token_creator); ignore).
:- implementation.
:- include_module lex__lexeme.
:- inst live_lexeme == compiled_lexeme(annotated_token).
%---- file lex.lexeme.m ------------------------------------------------------
:- module lex__lexeme.
:- interface.
:- inst compiled_lexeme(Inst) ==
bound(compiled_lexeme(Inst,ground,ground)).
%-----------------------------------------------------------------------------
Additional remark:
The error message is inconsistent with the language reference in that `->'
is deprecated in favor of `>>' in mode declarations.
--
Holger Krug
hkrug at rationalizer.com
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list