Files
mercury/samples
Julien Fischer a0833441e1 Add two new options to the compiler for querying what flags are passed to the
Branches: main

Add two new options to the compiler for querying what flags are passed to the
C compiler at a finer level of detail than that provided by --output-cflags.
The first new option, --output-grade-defines, prints the flags passed to the C
compiler to define the macros that specify the current compilation grade.
The second new option, --output-c-include-dir-flags, prints the flags passed
to C compiler that tell it where to search for C header files.

The rationale for the addition of the new options is that when compiling C++ or
Objective-C programs that call exported Mercury procedures via a standalone
interface we need both the flags for the grade defines and the include search
directories but other flags that we usually pass the C compiler may not be
appropriate for either a C++ or Objective-C compiler.

compiler/options.m:
	Recognise the new options.

compiler/mercury_compile.m:
	Handle the new options.

compiler/compile_target_code.m:
	Separate out the code that generates the grade macro define
	flags into a separate predicate.

	Do likewise with the code that generates the flags for specifying
	C compiler include search directories.

doc/use_guide.texi:
	Document the new options.

samples/c_interface/standalone_c/Makefile:
	Illustrate how to use the new options when compiling a program that
	uses a standalone interface.  Explain why it may not be appropriate
	to use the output of --output-cflags when compiling code that calls
	exported Mercury procedures.
2012-01-18 03:16:19 +00:00
..
2012-01-04 11:56:09 +00:00

This directory contains some example Mercury programs.

hello.m			"Hello World" in Mercury.

cat.m                   An implementation of a simple version of the
			standard UNIX filter `cat', which just copies
			its input files or the standard input stream to
			the standard output stream.

sort.m                  An implementation of a simple version of the
			standard UNIX filter `sort', which reads lines
			from its input files or the standard input
			stream, sorts them, and then writes the result
			to the standard output stream.

calculator.m            A simple four-function arithmetic calculator,
			with a parser written using the Definite Clause
			Grammar notation.

calculator2.m		A simple four-function arithmetic calculator,
			which uses the parser module in the standard
			library with a user-defined operator precedence
			table.

interpreter.m		An simple interpreter for definite logic programs.
			A demonstration of meta-programming in Mercury.

expand_terms.m		Another example meta-program, showing how to
			emulate Prolog's `expand_term' mechanism.

e.m			A small program which calculates the base of
			natural logarithms to however many digits you
			choose.  It illustrates one way to achieve
			lazy evaluation in Mercury.

Mmakefile		The file used by `mmake', the Mercury Make program,
			to build the programs in this directory.

The `solutions' sub-directory contains some examples of the use of
nondeterminism, showing how a Mercury program can compute 
	- one solution,
	- all solutions, or
	- some solutions (determined by a user-specified criteria)
for a query which has more than one logically correct answer.

The `concurrency' sub-directory contains examples of how to use Mercury's
concurrency interface, i.e. using threads in Mercury programs.

There are also some sub-directories which contain examples of multi-module
Mercury programs:

appengine               A simple Google App Engine servlet.

diff                    This directory contains an implementation of a
			simple version of the standard UNIX utility
			`diff', which prints the differences between
			two files.

c_interface		This directory contains some examples of mixed
			Mercury/C/C++/Fortran programs using the C interface.

java_interface		This directory contains some examples of mixed
			Mercury/Java programs using the foreign language
			interface.

rot13			This directory contains a few implementations of
			rot-13 encoding.

muz			This directory contains a syntax checker / type checker
			for the specification language Z.

solver_types		This directory contains an example solver type
			implementation and some sample applications.

lazy_list		This directory contains an example of the lazy module
			can be used to implement lazy data structures, in this
			case a lazy list.