[m-rev.] for review: Fixing samples/rot13_concise + libxml compile error

Sebastian Godelet sebastian.godelet+github at gmail.com
Thu Mar 6 09:49:13 AEDT 2014


Hello Julien,

incorporated all of the requested changes.

boehm_gc/.gitignore:
    Ignore .obj files

extras/xml/xml.dtd.m:
extras/xml/xml.parse.m:
    Change the name of functor ('1') in the multiplicity/0 type
    to one. The former name does not (yet) work with the C# grade.

samples/.gitignore:
    Ignore library output and sample executables.

samples/c_interface/standalone_c/.gitignore:
    Ignore mercury_lib_int output files.

samples/c_interface/standalone_c/Makefile:
    chmod 0644.

samples/c_interface/.gitignore:
    Ignore object files and executables.

samples/java_interface/.gitignore:
    Ignore Java class files and executables.

samples/lazy_list/.gitignore:
samples/muz/.gitignore:
samples/rot13/.gitignore:
    Ignore executables.

samples/rot13/rot13_concise.m:
    Update call to index_det to use string.det_index. Added comments
    to clarify type inference.

samples/solutions/.gitignore:
    Ignore executables.

samples/solutions/all_solutions.m:
samples/solutions/n_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
    chmod 0644.

samples/solver_types/.gitignore:
    Ignore executables.

samples/solver_types/sudoku.m:
    Output the solution in a 3x3 grid.

---
 boehm_gc/.gitignore                         |  1 +
 extras/xml/xml.dtd.m                        |  2 +-
 extras/xml/xml.parse.m                      |  2 +-
 samples/.gitignore                          | 23 +++++++++++++++++++++++
 samples/c_interface/.gitignore              |  6 ++++++
 samples/c_interface/standalone_c/.gitignore |  1 +
 samples/c_interface/standalone_c/Makefile   |  0
 samples/java_interface/.gitignore           |  2 ++
 samples/lazy_list/.gitignore                |  1 +
 samples/muz/.gitignore                      |  1 +
 samples/rot13/.gitignore                    |  5 +++++
 samples/rot13/rot13_concise.m               |  9 ++++++++-
 samples/solutions/.gitignore                |  4 ++++
 samples/solutions/all_solutions.m           |  0
 samples/solutions/n_solutions.m             |  0
 samples/solutions/one_solution.m            |  0
 samples/solutions/some_solutions.m          |  0
 samples/solver_types/.gitignore             |  2 ++
 samples/solver_types/sudoku.m               | 20 ++++++++++++++------
 19 files changed, 70 insertions(+), 9 deletions(-)
 create mode 100644 samples/.gitignore
 create mode 100644 samples/c_interface/.gitignore
 create mode 100644 samples/c_interface/standalone_c/.gitignore
 mode change 100755 => 100644 samples/c_interface/standalone_c/Makefile
 create mode 100644 samples/java_interface/.gitignore
 create mode 100644 samples/lazy_list/.gitignore
 create mode 100644 samples/muz/.gitignore
 create mode 100644 samples/rot13/.gitignore
 create mode 100644 samples/solutions/.gitignore
 mode change 100755 => 100644 samples/solutions/all_solutions.m
 mode change 100755 => 100644 samples/solutions/n_solutions.m
 mode change 100755 => 100644 samples/solutions/one_solution.m
 mode change 100755 => 100644 samples/solutions/some_solutions.m
 create mode 100644 samples/solver_types/.gitignore
diff --git a/boehm_gc/.gitignore b/boehm_gc/.gitignore
index 1ccf936..99fe1e6 100644
--- a/boehm_gc/.gitignore
+++ b/boehm_gc/.gitignore
@@ -10,6 +10,7 @@ mercury_boehm_gc_conf.h
 gc.lib
 libgc.lib
 *.a
+*.obj
 *.exe
 *.ilk
 *.o
diff --git a/extras/xml/xml.dtd.m b/extras/xml/xml.dtd.m
index 3719b13..6906849 100644
--- a/extras/xml/xml.dtd.m
+++ b/extras/xml/xml.dtd.m
@@ -57,7 +57,7 @@
  ---> mixed(list(name)).

 :- type multiplicity
- ---> ('1')
+ ---> one
  ; ('*')
  ; ('+')
  ; ('?')
diff --git a/extras/xml/xml.parse.m b/extras/xml/xml.parse.m
index cbf74c3..bd6f528 100644
--- a/extras/xml/xml.parse.m
+++ b/extras/xml/xml.parse.m
@@ -1746,7 +1746,7 @@ children -->
 :- mode multiplicity(in, out) is det.

 multiplicity -->
-    opt(lit1(('?'), ('?')) or lit1(('*'), ('*')) or lit1(('+'), ('+')), '1').
+    opt(lit1(('?'), ('?')) or lit1(('*'), ('*')) or lit1(('+'), ('+')), one).

 %   [48]  cp ::= (Name | choice | seq) ('?' | '*' | '+')?

diff --git a/samples/.gitignore b/samples/.gitignore
new file mode 100644
index 0000000..08aa600
--- /dev/null
+++ b/samples/.gitignore
@@ -0,0 +1,23 @@
+Mercury
+Mercury/**
+*.mh
+*.init
+*.err
+*.jar
+*.dll
+*.exe
+*.bat
+lib*.dylib
+lib*.dll
+lib*.so
+lib*.a
+hello
+calculator
+calculator2
+cat
+e
+eliza
+expand_terms
+interpreter
+sort
+ultra_sub
diff --git a/samples/c_interface/.gitignore b/samples/c_interface/.gitignore
new file mode 100644
index 0000000..511021c
--- /dev/null
+++ b/samples/c_interface/.gitignore
@@ -0,0 +1,6 @@
+c_main.o*
+c_main
+cpp_main.o*
+cpp_main
+mercury_main
+short_example
diff --git a/samples/c_interface/standalone_c/.gitignore
b/samples/c_interface/standalone_c/.gitignore
new file mode 100644
index 0000000..532bd66
--- /dev/null
+++ b/samples/c_interface/standalone_c/.gitignore
@@ -0,0 +1 @@
+mercury_lib_int.[cho]
diff --git a/samples/c_interface/standalone_c/Makefile
b/samples/c_interface/standalone_c/Makefile
old mode 100755
new mode 100644
diff --git a/samples/java_interface/.gitignore
b/samples/java_interface/.gitignore
new file mode 100644
index 0000000..111dcd9
--- /dev/null
+++ b/samples/java_interface/.gitignore
@@ -0,0 +1,2 @@
+mercury_main
+my_package
diff --git a/samples/lazy_list/.gitignore b/samples/lazy_list/.gitignore
new file mode 100644
index 0000000..5a2e901
--- /dev/null
+++ b/samples/lazy_list/.gitignore
@@ -0,0 +1 @@
+lazy_list_test
diff --git a/samples/muz/.gitignore b/samples/muz/.gitignore
new file mode 100644
index 0000000..0effa1a
--- /dev/null
+++ b/samples/muz/.gitignore
@@ -0,0 +1 @@
+muz
diff --git a/samples/rot13/.gitignore b/samples/rot13/.gitignore
new file mode 100644
index 0000000..ed3973d
--- /dev/null
+++ b/samples/rot13/.gitignore
@@ -0,0 +1,5 @@
+rot13_concise
+rot13_juergen
+rot13_gustavo
+rot13_ralph
+rot13_verbose
diff --git a/samples/rot13/rot13_concise.m b/samples/rot13/rot13_concise.m
index 02217b7..f0d234d 100644
--- a/samples/rot13/rot13_concise.m
+++ b/samples/rot13/rot13_concise.m
@@ -10,6 +10,8 @@
 % This version is more concise (but less efficient) than its companion,
 % rot13_verbose.
 %
+% Compile with: mmc --make --infer-all
+%
 % Key features:
 % - is independent of character set (e.g. ASCII, EBCDIC)
 % - has proper error handling
@@ -27,18 +29,23 @@
 :- import_module char, int, string.

 % The length of `alphabet' should be a multiple of `cycle'.
+% Inferred declaration: func alphabet = string.
 alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".
+
+% Inferred declaration: func cycle = int.
 cycle = 26.

+% Inferred declaration: func rot_n(int, char) = char.
 rot_n(N, Char) = RotChar :-
  char_to_string(Char, CharString),
  ( if sub_string_search(alphabet, CharString, Index) then
   NewIndex = (Index + N) mod cycle + cycle * (Index // cycle),
-  index_det(alphabet, NewIndex, RotChar)
+  string.det_index(alphabet, NewIndex, RotChar)
  else
   RotChar = Char
  ).

+% Inferred declaration: func rot13(char) = char.
 rot13(Char) = rot_n(13, Char).

 main -->
diff --git a/samples/solutions/.gitignore b/samples/solutions/.gitignore
new file mode 100644
index 0000000..c139182
--- /dev/null
+++ b/samples/solutions/.gitignore
@@ -0,0 +1,4 @@
+all_solutions
+n_solutions
+one_solution
+some_solutions
diff --git a/samples/solutions/all_solutions.m
b/samples/solutions/all_solutions.m
old mode 100755
new mode 100644
diff --git a/samples/solutions/n_solutions.m b/samples/solutions/n_solutions.m
old mode 100755
new mode 100644
diff --git a/samples/solutions/one_solution.m b/samples/solutions/one_solution.m
old mode 100755
new mode 100644
diff --git a/samples/solutions/some_solutions.m
b/samples/solutions/some_solutions.m
old mode 100755
new mode 100644
diff --git a/samples/solver_types/.gitignore b/samples/solver_types/.gitignore
new file mode 100644
index 0000000..b2f2515
--- /dev/null
+++ b/samples/solver_types/.gitignore
@@ -0,0 +1,2 @@
+sudoku
+test_eqneq
diff --git a/samples/solver_types/sudoku.m b/samples/solver_types/sudoku.m
index 2f34eac..14b2778 100644
--- a/samples/solver_types/sudoku.m
+++ b/samples/solver_types/sudoku.m
@@ -40,7 +40,7 @@ main(!IO) :-
                 ReadResult = ok(StartString),
                 Start = string.words(StartString),
                 ( if solve_sudoku(Start, Solution) then
-                    write_solution(9, Solution, !IO)
+                    write_solution(9, 1, Solution, !IO)
                   else
                     io.write_string("No solution.\n", !IO)
                 )
@@ -169,19 +169,27 @@ label_board([EqNeq | EqNeqs], [X | Xs]) :-

     % Pretty-print a solution.
     %
-:- pred write_solution(int::in, list(int)::in, io::di, io::uo) is det.
+:- pred write_solution(int::in, int::in, list(int)::in, io::di, io::uo) is det.

-write_solution(_, [], !IO) :-
+write_solution(_, _, [], !IO) :-
     io.nl(!IO).

-write_solution(N, [X | Xs], !IO) :-
+write_solution(N, R, [X | Xs], !IO) :-
     ( if N = 0 then
         io.nl(!IO),
-        write_solution(9, [X | Xs], !IO)
+        ( if   (R mod 3) = 0
+          then io.nl(!IO)
+          else true
+        ),
+        write_solution(9, R + 1, [X | Xs], !IO)
       else
         io.write_int(X, !IO),
         io.write_char(' ', !IO),
-        write_solution(N - 1, Xs, !IO)
+        ( if   (N mod 3) = 1
+          then io.write_char(' ', !IO)
+          else true
+        ),
+        write_solution(N - 1, R + 1, Xs, !IO)
     ).

 %-----------------------------------------------------------------------------%
-- 
1.8.3.2

On 2 March 2014 14:04, Julien Fischer <jfischer at opturion.com> wrote:
>
> Hi Sebastian,
>
>
> On Fri, 28 Feb 2014, Sebastian Godelet wrote:
>
>> for a quick review, my last problems I had with going through all the
>> samples and extras, except the wix compiler, that one I didn't figure out
>> yet.
>>
>> branch: master
>> boehm_gc/.gitignore b/boehm_gc/.gitignore:
>>     ignoring Windows 'cl' .obj files
>
>
> Change that to:
>
>       Ignore .obj files.
>
>
>> extras/xml/xml.dtd.m b/extras/xml/xml.dtd.m:
>> extras/xml/xml.parse.m b/extras/xml/xml.parse.m:
>>     Changing multiplicity ('1') -> one, such that it compiles (and works)
>>     in the C# grade.
>
>
> Change to:
>
>       Change the name of the functor ('1') in the multiplicity/0 type
>       to one.  The former name does not (yet) work with the C# grade.
>
>
>> samples/rot13/rot13_concise.m:
>>     added missing func and pred declarations
>
>
> Change to:
>
>      Add missing func and pred declarations.
>
> (I suspect, however, that their omission was deliberate; the authors
> presumably thought it more concise to infer the predmodes of local
> procedures rather than explicitly declare them.)
>
>
>>     changed string index_det -> string.det_index.
>
>
> Change to:
>
>       Update calls to string.index_det to use string.det_index.
>
>
>> samples/solver_types/sudoku.m:
>>     The solution grid is now in a 3x3 block format,
>>     for that the row number is accumulated in write_solution predicate.
>
>
> Change to:
>
>       Output the solution in a 3x3 grid.
>
> The rest of the change looks fine.
>
> Cheers,
> Julien.



More information about the reviews mailing list