[mercury-users] moose: input variables for the rules

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Tue Oct 29 04:46:18 AEDT 2002


Hi.

I wonder, whether I can send some 'global' data down to the rules of
moose. Imagine a large lexicon of 'keywords', so that the lexicon is
loaded once at startup from an external file. In the input file for the
parser, one should write for example `keyword_name` that would convert to
a single token of type keyword_name(string). Then, the parser should have
access to the lexicon and convert the token keyword_name(Name) to
keyword(Data_from_the_lexicon). Is it possible to write such a rule for
moose?

:- type keyword.
:- type lexicon == map(string, keyword).
:- type token ---> ...
          keyword_name(string);
          ...
:- type expression ---> ...
          keyword(keyword);
          ...

:- rule expr(lexicon, expression).
...
expr(Lex, keyword(KW))  ---> keyword_name(Name), { map__search(Lex, Name,
KW) }.
...

The crucial thing is that expr/2 has mode (in, out). Moose successfully
compiles the .moo to .m, but the .m has then instantiation problems,
because moose assumed all the variables were 'free'.

Is there a way to workaround this?

Thanks, Andrew.

--------------------------------------------------------------------------
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