[m-dev.] would like some help getting acquainted with the compiler
jfischer at opturion.com
Fri Jun 21 16:26:22 AEST 2013
On Fri, 14 Jun 2013, Christopher Perez wrote:
> I took some interest in logical programming after an AI course
> introduced me to lisp, which helped me discover other programming
> paradigms. I've since then picked up Scala and Prolog, but have been
> disappointed to see lack of support for Mercury. Instead of simply
> using Mercury though, I would like to learn how it ticks. If anyone
> would like to help me get started, even naming some good math books as
> preliminaries, my email is Christopher.Perez100 at gmail.com
> My goal is to advance the theory of logical programming (which I find
> beautiful), help others settle into the language as well, and also
> create a Mercury to Verilog compiler.
>From a theoretical perspective, any of the standard descriptions of logic
programming apply to Mercury, for example Lloyd's Foundations of Logic Programming.
Where Mercury differs, from say Prolog, here is that the unification
algorithm is more restricted (the trade-off being that Mercury programs
should, in general, execute faster).
The basic ideas behind Mercury's LLDS backend (i.e. the low-level C backend)
are described in the following paper:
The execution algorithm of Mercury: an efficient purely declarative logic programming language
Zoltan Somogyi, Fergus Henderson and Thomas Conway. JLP, 1996.
The basic ideas behind Mercury's MLDS backend (i.e. the compilation approach
used for the high-level C, Java and C# backends) are described in:
Compiling Mercury to high-level C code
Fergus Henderson and Zoltan Somogyi. CC'02, Grenoble, France.
(At the moment, there is nothing published that describes the Erlang backend.)
Specific details of the implementation have changed over time, but the
fundamentals are still broadly identical to what is described in the above papers.
In terms of the actual source code itself, at the top-level the Mercury system
is divided up like this:
runtime - The C (both high- and low-level) versions of the Mercury runtime.
java/runtime - The Java version of the Mercury runtime.
library - The standard library source code
compiler - The compiler source code.
mdbcomp - A library of stuff that is common to the compiler and debugger.
util - Various utility programs used by the compiler. (Implemented in C).
mjavafiltercc - Another utility program used by the compiler. (Implemented in Mercury).
browser - The parts of the debugger that are implemented in Mercury.
trace - The parts of the debugger that are implemented in C.
profiler - The profiler (e.g. mprof)
slice - Various tools related to program slicing (mslice etc)
deep_profiler - The deep profiler and related tools.
scripts - Wrapper scripts (e.g. mmc, mgnuc and ml) and configuration files.
The overall structure of the Mercury compiler itself (i.e the contents of the
compiler directory) are described in the file: compiler/notes/compiler_design.html.
Since that file is regularly updated, there's no point me repeating its
contents in this mail.
More information about the developers