Next: , Previous: , Up: Top   [Contents]


2 Syntax

A Mercury program consists of a set of modules. Each module is a file written using the UTF-8 encoding of the Unicode character set, and contains a sequence of items. Each item is a term followed by a period, and is interpreted as either a declaration or a clause depending on the form it takes.

Mercury’s term syntax is similar to that of Prolog, with some notable distinctions:

Mercury’s clause syntax for defining predicates is also similar to that of Prolog, including the use of Definite Clause Grammar (DCG) notation. Mercury clauses, however, can additionally define functions that users may invoke in expressions.