[mercury-users] Mercury example programs

Ralph Becket rafe at cs.mu.OZ.AU
Wed Jun 15 14:49:46 AEST 2005


brogoff, Tuesday, 14 June 2005:
>     Is there a repository of Mercury sample programs available somewhere?
> I know about the examples dir in the distribution, but it's a bit lean.
> I tend to learn by hacking a working example.

There's the extras part of the distribution which you have to download
separately from the web site.  That contains code written in different
styles as the language has evolved.  The library code provides some
good, fairly modern coding examples.

>     In particular, I'm interested in small, well documented  examples of the
> standard transformational programs that everyone writes (parse a file, maybe
> build an AST, emit transformed data) that often involve lex and yacc, and
> which make use of Mercury's IO libraries. Anything like that available?

Sure.  Look at lexer.m and term_io.m and parser.m and pprint.m in the
library directory.  The samples directory contains lex.m, which is a
pretty decent generic lexer, and xml.m, which is a direct
transliteration of the XML spec. into Mercury (it won't win any prizes
for speed, but it is as correct as can be given the state of the XML
`spec').

If you have specific examples in mind, I'd like to hear about them.  I
think the tutorial could be usefully extended with some more realistic
example programs.

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