[m-users.] minimal model pragma and compilation options
C. M. Sperberg-McQueen
cmsmcq at blackmesatech.com
Fri Jan 14 04:57:33 AEDT 2022
The documentation (for 20.06-1) and I appear not to be communicating
with each other very well; I wonder if anyone here can help.
What must I do to persuade mmc --make to compile a program that uses
minimal-model tabling?
On a related note, is there any way to find out reliably which grades of
Mercury were installed when I installed the Mercury package?
Fuller details follow.
As an experiment, I have written a couple of definite clause grammars in
Mercury. The one with right-recursive rules works as expected. The one
with left-recursive rules compiles with warnings about left recursion
and infinite loops, and works as expected in all respects: input that
does not involve left recursion is parsed without trouble, and input
that exercises any of those left-recursive rules leads to an infinite
recursion.
When the loop_check and memo pragmas are used, the error message changes
from a notice of a stack overflow to a notice of an uncaught Mercury
exception related to the detection of infinite recursion, which is
roughly what I expected from the documentation.
When the minimal_model pragma is used, and mmc --make is used to compile
the program, exercising one of the left-recursive grammar rules produces
the error message
Mercury runtime: stack copy minimal model code entered when not
enabled
At this point I re-read the discussion of tabling and saw the note at
the end of the section in the reference manual saying
Please note: the current implementation of tabling does not support
all the possible compilation grades (see the “Compilation model
options” section of the Mercury User’s Guide) allowed by the Mercury
implementation. In particular, minimal model tabling is incompatible
with high level code and the use of trailing.
The Mercury User's Guide, version 20.06.1, tells me
The default is no support for minimal model evaluation. When
targeting low-level C, users can specify the grade modifier ‘.mm’,
which enables support for minimal model tabled evaluation of
procedures.
If I have understood the general discussion of grades correctly, this
tells me that instead of issuing the command
mmc --make arithlr0
(for 'arithmetic grammar, left-recursive, version 0'), I should instead
issue the command
mmc --make arithlr0 --grade none.mm
When I do this, an error message is returned immediately saying the
standard library is not available in that grade. I tried some obvious
alternatives, and got the same notice every time:
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 --grade none.mm
mercury_compile: error: the Mercury standard library cannot be found in grade none.mmsc.
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 --grade none.mm.
mercury_compile: error: the Mercury standard library cannot be found in grade none.mmsc.
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 --grade reg.mm
mercury_compile: error: the Mercury standard library cannot be found in grade reg.mmsc.
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 --grade reg
mercury_compile: error: the Mercury standard library cannot be found in grade reg.
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 --grade none
mercury_compile: error: the Mercury standard library cannot be found in grade none.
cmsmcq at gemma:~/2022/etudes/Mercury$ mmc --make arithlr0 -s reg.mm
mercury_compile: error: the Mercury standard library cannot be found in grade reg.mmsc.
Note that a compilation error is raised even if the .mm grade modifier
is left off. That suggests to me I am doing something more
fundamentally wrong.
I also notice that the information produced by mmc --help does not
include 'mm' among the grade modifiers:
-s <grade>, --grade <grade>
Select the compilation model. The <grade> should be one of
the base grades `none', `reg', `asm_fast', `hlc', `java',
`csharp' or `erlang'
or one of those with one or more of the grade modifiers
`.gc', `.prof', `.memprof', `.profdeep', `.tr',
`.spf', `.stseg', `.debug', and/or `.par' appended.
Depending on your particular installation, only a subset
of these possible grades will have been installed.
Attempting to use a grade which has not been installed
will result in an error at link time.
I'm currently at a loss; if anyone can point me in a useful direction I
will be grateful.
--
C. M. Sperberg-McQueen
Black Mesa Technologies LLC
http://blackmesatech.com
More information about the users
mailing list