[m-rev.] diff: improve consistency of error and warning messages

Julien Fischer jfischer at opturion.com
Wed Jul 30 17:02:36 AEST 2014


Branches: master

Improve consistency of error and warning messages.

Add two new format components to the error_util library: decl/1 and
pragma_decl/1.  These are converted into strings as follows:

    decl(<Decl>)        ==> `:- <Decl>'
    pragma_decl(<Decl>) ==> `:- pragma <Decl>'

The motivation for this change is that error messages about declarations
often contain text similar to:

     ... in `:- foo' declaration ...

At least that is what occurs most of the time; in some cases the `:-' part is
omitted, in other cases the quotes are omitted.  Using the new format
components makes these consistency problems less likely to occur.  The error
specs are also more concise as well.

This commit also addresses a number of other minor issues related to error.

compiler/error_util.m:
 	Add the two new format components describe above.

 	Use add_quotes/1 as a single point of control for how single quotes
 	are added where possible in this module.

 	Call unexpected/3 in preference to error/1.

compiler/goal_expr_to_goal.m;
 	Quote the word 'else' when referring the 'else' part of a try goal
 	in an error message.

compiler/hlds_out_util.m:
 	Add an XXX comment about cons_ids being incorrectly quoted in
 	error messages.

compiler/det_report.m:
 	Pass the message description to report_determinism_problem/7 as a list
 	of format_components rather than as a string.

compiler/make_hlds_warn.m:
 	Capitalize the word "Warning" when it occurs at the beginning of a warning.

compiler/typecheck_errors.m:
compiler/modules.m:
 	Fix problems I noticed during my previous change.

compiler/add_pragma.m:
compiler/add_type.m:
compiler/det_analysis.m:
compiler/make_hlds_passes.m:
compiler/modules.m:
compiler/oisu_check.m:
compiler/prog_io.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/term_constr_errors.m:
compiler/term_errors.m
compiler/termination.m:
compiler/typecheck_errors.m:
 	Conform to the above changes.

tests/invalid/bad_finalise_decl.err_exp:
tests/invalid/bad_initialise_decl.err_exp:
tests/invalid/bad_mutable.err_exp:
tests/invalid/bug83.err_exp:
tests/invalid/ee_invalid.err_exp:
tests/invalid/foreign_enum_import.err_exp:
tests/invalid/foreign_enum_invalid.err_exp:
tests/invalid/foreign_type_missing.err_exp:
tests/invalid/hawkins_mm_fail_reset.err_exp:
tests/invalid/loopcheck.err_exp:
tests/invalid/nested_impl_in_int.err_exp:
tests/invalid/oisu_check_add_pragma_errors.err_exp:
tests/invalid/oisu_check_semantic_errors.err_exp:
tests/invalid/reserve_tag.err_exp:
tests/invalid/try_io_else.err_exp:
tests/warnings/foreign_term_invalid.exp:
tests/warnings/warn_return.exp*:
tests/warnings/warn_succ_ind.exp:
 	Update expected (error) outputs to conform to the above.

Julien.

diff --git a/compiler/add_pragma.m b/compiler/add_pragma.m
index cc0069b..c840bff 100644
--- a/compiler/add_pragma.m
+++ b/compiler/add_pragma.m
@@ -327,7 +327,7 @@ add_pass_3_pragma(ItemPragma, !Status, !ModuleInfo, !QualInfo, !Specs) :-
              TypeLayout = no,
              TabledInfo = pragma_info_tabled(EvalMethod, _, _, _),
              Pieces = [words("Error:"),
-                quote(":- pragma " ++ eval_method_to_string(EvalMethod)),
+                pragma_decl(eval_method_to_string(EvalMethod)),
                  words("declaration requires type_ctor_layout structures."),
                  words("Don't use --no-type-layout to disable them."), nl],
              Msg = simple_msg(Context, [always(Pieces)]),
@@ -404,8 +404,8 @@ add_pragma_foreign_proc_export(Origin, FPEInfo, Context, !ModuleInfo,
              PredId, Modes, ExportedName, Context, !ModuleInfo, !Specs)
      ;
          PredIds = [_, _ | _],
-        StartPieces = [words("error: ambiguous"), p_or_f(PredOrFunc),
-            words("name in"), quote("pragma foreign_export"),
+        StartPieces = [words("Error: ambiguous"), p_or_f(PredOrFunc),
+            words("name in"), pragma_decl("foreign_export"),
              words("declaration."), nl,
              words("The possible matches are:"), nl_indent_delta(1)],
          PredIdPiecesList = list.map(
@@ -425,7 +425,7 @@ add_pragma_foreign_proc_export(Origin, FPEInfo, Context, !ModuleInfo,
          (
              Origin = user,
              undefined_pred_or_func_error(Name, Arity, Context,
-                [quote(":- pragma foreign_export"), words("declaration")],
+                [pragma_decl("foreign_export"), words("declaration")],
                  !Specs)
          ;
              Origin = compiler(Details),
@@ -472,8 +472,8 @@ add_pragma_foreign_export_2(Arity, PredTable, Origin, Lang, Name, PredId,
              ; Detism = detism_multi
              )
          ->
-            Pieces = [words("Error: "),
-                quote(":- pragma foreign_export"), words("declaration"),
+            Pieces = [words("Error:"),
+                pragma_decl("foreign_export"), words("declaration"),
                  words("for a procedure that has"),
                  words("a declared determinism of"),
                  fixed(determinism_to_string(Detism) ++ "."), nl],
@@ -518,7 +518,7 @@ add_pragma_foreign_export_2(Arity, PredTable, Origin, Lang, Name, PredId,
          (
              Origin = user,
              undefined_mode_error(Name, Arity, Context,
-                [quote(":- pragma foreign_export"), words("declaration")],
+                [pragma_decl("foreign_export"), words("declaration")],
                  !Specs)
          ;
              Origin = compiler(Details),
@@ -562,7 +562,7 @@ add_pragma_reserve_tag(TypeCtor, PragmaStatus, Context, !ModuleInfo, !Specs) :-
              )
          ->
              MaybeSeverity = yes(severity_error),
-            ErrorPieces = [words("error:"), quote("pragma reserve_tag"),
+            ErrorPieces = [words("error:"), pragma_decl("reserve_tag"),
                  words("declaration must have"),
                  words("the same visibility as the type definition.")]
          ;
@@ -578,7 +578,7 @@ add_pragma_reserve_tag(TypeCtor, PragmaStatus, Context, !ModuleInfo, !Specs) :-
                  ->
                      MaybeSeverity = yes(severity_warning),
                      ErrorPieces = [words("warning: multiple"),
-                        quote("pragma reserved_tag"),
+                        pragma_decl("reserved_tag"),
                          words("declarations for the same type."), nl]
                  ;
                      MaybeSeverity = no,
@@ -625,7 +625,7 @@ add_pragma_reserve_tag(TypeCtor, PragmaStatus, Context, !ModuleInfo, !Specs) :-
              MaybeSeverity = no,
              unexpected($module, $pred, "no severity")
          ),
-        ContextPieces = [words("In"), quote("pragma reserve_tag"),
+        ContextPieces = [words("In"), pragma_decl("reserve_tag"),
              words("declaration for"), sym_name_and_arity(TypeName / TypeArity),
              suffix(":"), nl],
          Msg = simple_msg(Context, [always(ContextPieces ++ ErrorPieces)]),
@@ -645,7 +645,7 @@ add_pragma_foreign_export_enum(FEEInfo, _ImportStatus, Context,
          Attributes, Overrides),
      TypeCtor = type_ctor(TypeName, TypeArity),
      module_info_get_type_table(!.ModuleInfo, TypeTable),
-    ContextPieces = [words("In"), quote("pragma foreign_export_enum"),
+    ContextPieces = [words("In"), pragma_decl("foreign_export_enum"),
          words("declaration for"),
          sym_name_and_arity(TypeName / TypeArity), suffix(":"), nl],
      (
@@ -987,7 +987,7 @@ add_pragma_foreign_enum(FEInfo, ImportStatus, Context, !ModuleInfo, !Specs) :-
      FEInfo = pragma_info_foreign_enum(Lang, TypeCtor, ForeignTagValues),
      TypeCtor = type_ctor(TypeName, TypeArity),
      module_info_get_type_table(!.ModuleInfo, TypeTable0),
-    ContextPieces = [words("In"), quote("pragma foreign_enum"),
+    ContextPieces = [words("In"), pragma_decl("foreign_enum"),
          words("declaration for"),
          sym_name_and_arity(TypeName / TypeArity), suffix(":"), nl],
      (
@@ -1272,7 +1272,7 @@ add_foreign_enum_bijection_error(Context, ContextPieces, !Specs) :-
  add_foreign_enum_pragma_in_interface_error(Context, TypeName, TypeArity,
          !Specs) :-
      ErrorPieces = [words("Error: "),
-        quote("pragma foreign_enum"), words("declaration for"),
+        pragma_decl("foreign_enum"), words("declaration for"),
          sym_name_and_arity(TypeName / TypeArity),
          words("in module interface."), nl ],
      Msg = simple_msg(Context, [always(ErrorPieces)]),
@@ -1302,17 +1302,17 @@ add_pragma_unused_args(UnusedArgsInfo, Context, !ModuleInfo, !Specs) :-
          module_info_set_unused_arg_info(UnusedArgInfo, !ModuleInfo)
      ;
          PredIds = [],
-        Pieces = [words("Internal compiler error: "),
-            words("unknown predicate in"), quote("pragma unused_args"),
-            suffix("."), nl],
+        Pieces = [words("Internal compiler error:"),
+            words("unknown predicate in"), pragma_decl("unused_args"),
+            words("declaration."), nl],
          Msg = simple_msg(Context, [always(Pieces)]),
          Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
          !:Specs = [Spec | !.Specs]
      ;
          PredIds = [_, _ | _],
-        Pieces = [words("Internal compiler error: "),
-            words("ambiguous predicate in "), quote("pragma unused_args"),
-            suffix("."), nl],
+        Pieces = [words("Internal compiler error:"),
+            words("ambiguous predicate in"), pragma_decl("unused_args"),
+            words("declaration."), nl],
          Msg = simple_msg(Context, [always(Pieces)]),
          Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
          !:Specs = [Spec | !.Specs]
@@ -1436,7 +1436,7 @@ add_pragma_type_spec(TSInfo, Context, !ModuleInfo, !QualInfo, !Specs) :-
      ;
          PredIds = [],
          undefined_pred_or_func_error(SymName, Arity, Context,
-            [quote(":- pragma type_spec"), words("declaration")], !Specs)
+            [pragma_decl("type_spec"), words("declaration")], !Specs)
      ).

  :- pred add_pragma_type_spec_2(pragma_info_type_spec::in,
@@ -1782,15 +1782,15 @@ report_unknown_vars_to_subst(PredInfo, Context, TVarSet, UnknownVars,
      PredOrFunc = pred_info_is_pred_or_func(PredInfo),
      (
          PredOrFunc = pf_predicate,
-        Decl = ":- pred"
+        Decl = "pred"
      ;
          PredOrFunc = pf_function,
-        Decl = ":- func"
+        Decl = "func"
      ),
      Pieces = pragma_type_spec_to_pieces(PredInfo) ++
          [words("error:")] ++ report_variables(UnknownVars, TVarSet) ++
          [words(choose_number(UnknownVars, "does not", "do not")),
-        words("occur in the"), quote(Decl), words("declaration.")],
+        words("occur in the"), decl(Decl), words("declaration.")],
      Msg = simple_msg(Context, [always(Pieces)]),
      Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
      !:Specs = [Spec | !.Specs].
@@ -1803,7 +1803,7 @@ pragma_type_spec_to_pieces(PredInfo) = Pieces :-
      Arity = pred_info_orig_arity(PredInfo),
      PredOrFunc = pred_info_is_pred_or_func(PredInfo),
      SimpleCallId = simple_call_id(PredOrFunc, qualified(Module, Name), Arity),
-    Pieces = [words("In"), quote(":- pragma type_spec"),
+    Pieces = [words("In"), pragma_decl("type_spec"),
          words("declaration for"), simple_call(SimpleCallId), suffix(":"), nl].

  :- func report_variables(list(tvar), tvarset) = list(format_component).
@@ -1837,7 +1837,7 @@ handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes,
          ;
              module_info_incr_errors(!ModuleInfo),
              undefined_mode_error(SymName, Arity, Context,
-                [quote(":- pragma type_spec"), words("declaration")], !Specs),
+                [pragma_decl("type_spec"), words("declaration")], !Specs),
              MaybeProcIds = no
          )
      ;
@@ -1904,7 +1904,7 @@ add_pragma_termination2_info(Term2Info, Context, !ModuleInfo, !Specs) :-
              map.det_update(PredId, PredInfo, PredTable0, PredTable),
              module_info_set_preds(PredTable, !ModuleInfo)
          ;
-            Pieces = [words("Error:"), quote(":- pragma termination2_info"),
+            Pieces = [words("Error:"), pragma_decl("termination2_info"),
                  words("declaration for undeclared mode of"),
                  simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                  suffix("."), nl],
@@ -1916,8 +1916,8 @@ add_pragma_termination2_info(Term2Info, Context, !ModuleInfo, !Specs) :-
          PredIds = [_, _ | _],
          Pieces = [words("Error: ambiguous predicate name"),
              simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
-            words("in"), quote("pragma termination2_info"),
-            suffix("."), nl],
+            words("in"), pragma_decl("termination2_info"),
+            words("declaration."), nl],
          Msg = simple_msg(Context, [always(Pieces)]),
          Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
          !:Specs = [Spec | !.Specs]
@@ -1966,7 +1966,7 @@ add_pragma_structure_sharing(SharingInfo, Context, !ModuleInfo, !Specs):-
                  map.det_update(PredId, PredInfo, PredTable0, PredTable),
                  module_info_set_preds(PredTable, !ModuleInfo)
              ;
-                Pieces = [words("Error:"), quote(":- pragma structure_sharing"),
+                Pieces = [words("Error:"), pragma_decl("structure_sharing"),
                      words("declaration for undeclared mode of"),
                      simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                      suffix("."), nl],
@@ -1979,8 +1979,8 @@ add_pragma_structure_sharing(SharingInfo, Context, !ModuleInfo, !Specs):-
              PredIds = [_ , _ | _],
              Pieces = [words("Error: ambiguous predicate name"),
                  simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
-                words("in"), quote("pragma structure_sharing."),
-                suffix("."), nl],
+                words("in"), pragma_decl("structure_sharing."),
+                words("declaration."), nl],
              Msg = simple_msg(Context, [always(Pieces)]),
              Spec = error_spec(severity_error, phase_parse_tree_to_hlds,
                  [Msg]),
@@ -2031,7 +2031,7 @@ add_pragma_structure_reuse(ReuseInfo, Context, !ModuleInfo, !Specs):-
                  map.det_update(PredId, PredInfo, PredTable0, PredTable),
                  module_info_set_preds(PredTable, !ModuleInfo)
              ;
-                Pieces = [words("Error:"), quote(":- pragma structure_reuse"),
+                Pieces = [words("Error:"), pragma_decl("structure_reuse"),
                      words("declaration for undeclared mode of"),
                      simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                      suffix("."), nl],
@@ -2044,7 +2044,8 @@ add_pragma_structure_reuse(ReuseInfo, Context, !ModuleInfo, !Specs):-
              PredIds = [_, _ | _],
              Pieces = [words("Error: ambiguous predicate name"),
                  simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
-                words("in"), quote("pragma structure_reuse"), suffix("."), nl],
+                words("in"), pragma_decl("structure_reuse"),
+                words("declaration."), nl],
              Msg = simple_msg(Context, [always(Pieces)]),
              Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
              !:Specs = [Spec | !.Specs]
@@ -2097,7 +2098,7 @@ add_pragma_termination_info(TermInfo, Context, !ModuleInfo, !Specs) :-
              module_info_set_preds(PredTable, !ModuleInfo)
          ;
              module_info_incr_errors(!ModuleInfo),
-            Pieces = [words("Error:"), quote(":- pragma termination_info"),
+            Pieces = [words("Error:"), pragma_decl("termination_info"),
                  words("declaration for undeclared mode of"),
                  simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                  suffix("."), nl],
@@ -2110,7 +2111,8 @@ add_pragma_termination_info(TermInfo, Context, !ModuleInfo, !Specs) :-
          PredIds = [_, _ | _],
          Pieces = [words("Error: ambiguous predicate name"),
              simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
-            words("in"), quote("pragma termination_info"), suffix("."), nl],
+            words("in"), pragma_decl("termination_info"),
+            words("declaration."), nl],
          Msg = simple_msg(Context, [always(Pieces)]),
          Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
          !:Specs = [Spec | !.Specs]
@@ -2178,7 +2180,7 @@ add_pragma_foreign_proc(FPInfo, Status, Context, MaybeItemNumber,
          preds_add_implicit_report_error(!ModuleInfo, ModuleName,
              PredName, Arity, PredOrFunc, Status, no, Context,
              origin_user(PredName),
-            [quote(":- pragma foreign_proc"), words("declaration")],
+            [pragma_decl("foreign_proc"), words("declaration")],
              PredId, !Specs)
      ;
          PredIds = [PredId]
@@ -2234,7 +2236,7 @@ add_pragma_foreign_proc(FPInfo, Status, Context, MaybeItemNumber,
          ;
              pred_info_is_imported(!.PredInfo)
          ->
-            Pieces = [words("Error:"), quote(":- pragma foreign_proc"),
+            Pieces = [words("Error:"), pragma_decl("foreign_proc"),
                  words("declaration for imported"),
                  simple_call(simple_call_id(PredOrFunc, PredName, Arity)),
                  suffix("."), nl],
@@ -2288,7 +2290,7 @@ add_pragma_foreign_proc(FPInfo, Status, Context, MaybeItemNumber,
                      SimpleCallId, PredId, ProcId, !Specs)
              ;
                  Pieces = [words("Error:"),
-                    quote(":- pragma foreign_proc"), words("declaration"),
+                    pragma_decl("foreign_proc"), words("declaration"),
                      words("for undeclared mode of"),
                      simple_call(SimpleCallId), suffix("."), nl],
                  Msg = simple_msg(Context, [always(Pieces)]),
@@ -2328,8 +2330,7 @@ module_add_pragma_tabled(TabledInfo, Context, !Status, !ModuleInfo,
          ;
              PredIds0 = [],
              module_info_get_name(!.ModuleInfo, ModuleName),
-            DescPieces = [quote(":- pragma " ++ EvalMethodStr),
-                words("declaration")],
+            DescPieces = [pragma_decl(EvalMethodStr), words("declaration")],
              preds_add_implicit_report_error(!ModuleInfo, ModuleName,
                  PredName, Arity, PredOrFunc, !.Status, no, Context,
                  origin_user(PredName), DescPieces, PredId, !Specs),
@@ -2345,8 +2346,7 @@ module_add_pragma_tabled(TabledInfo, Context, !Status, !ModuleInfo,
          ;
              PredIds0 = [],
              module_info_get_name(!.ModuleInfo, ModuleName),
-            DescPieces = [quote(":- pragma " ++ EvalMethodStr),
-                words("declaration")],
+            DescPieces = [pragma_decl(EvalMethodStr), words("declaration")],
              preds_add_implicit_report_error(!ModuleInfo, ModuleName,
                  PredName, Arity, pf_predicate, !.Status, no, Context,
                  origin_user(PredName), DescPieces, PredId, !Specs),
@@ -2460,9 +2460,9 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc,
          WarnInline = yes
      ->
          InlineWarningPieces = [words("Warning: "), simple_call(SimpleCallId),
-            words("has a"), quote(":- pragma " ++ EvalMethodStr),
+            words("has a"), pragma_decl(EvalMethodStr),
              words("declaration but also has a"),
-            quote(":- pragma inline"), words("declaration."), nl,
+            pragma_decl("inline"), words("declaration."), nl,
              words("This inline pragma will be ignored"),
              words("since tabled predicates cannot be inlined."), nl,
              words("You can use the"), quote("--no-warn-table-with-inline"),
@@ -2475,7 +2475,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc,
          true
      ),
      ( pred_info_is_imported(PredInfo0) ->
-        Pieces = [words("Error: "), quote(":- pragma " ++ EvalMethodStr),
+        Pieces = [words("Error: "), pragma_decl(EvalMethodStr),
              words("declaration for imported"), simple_call(SimpleCallId),
              suffix("."), nl],
          Msg = simple_msg(Context, [always(Pieces)]),
@@ -2509,7 +2509,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc,
                  module_info_set_pred_info(PredId, PredInfo, !ModuleInfo)
              ;
                  Pieces = [words("Error:"),
-                    quote(":- pragma " ++ EvalMethodStr),
+                    pragma_decl(EvalMethodStr),
                      words("declaration for undeclared mode of"),
                      simple_call(SimpleCallId), suffix("."), nl],
                  Msg = simple_msg(Context, [always(Pieces)]),
@@ -2522,7 +2522,7 @@ module_add_pragma_tabled_2(EvalMethod0, PredName, Arity0, MaybePredOrFunc,
              (
                  ExistingProcs = [],
                  Pieces = [words("Error: "),
-                    quote(":- pragma " ++ EvalMethodStr),
+                    pragma_decl(EvalMethodStr),
                      words("declaration for"), simple_call(SimpleCallId),
                      words("with no declared modes."), nl],
                  Msg = simple_msg(Context, [always(Pieces)]),
@@ -2605,7 +2605,7 @@ set_eval_method_create_aux_preds(ProcId, ProcInfo0, Context, SimpleCallId,
          (
              MaybeDeclaredArgModes = no,
              EvalMethodStr = eval_method_to_string(EvalMethod),
-            Pieces = [words("Error:"), quote("pragma " ++ EvalMethodStr),
+            Pieces = [words("Error:"), pragma_decl(EvalMethodStr),
                  words("declaration for"), simple_call(SimpleCallId),
                  suffix(","), words("which has no declared modes."), nl],
              Msg = simple_msg(Context, [always(Pieces)]),
@@ -3084,8 +3084,8 @@ add_pragma_oisu(OISUInfo, Status, Context, !ModuleInfo, !Specs) :-
                  module_info_set_oisu_map(OISUMap, !ModuleInfo)
              ;
                  TypeCtor = type_ctor(TypeName, TypeArity),
-                DupPieces = [words("Duplicate"), quote("pragma oisu"),
-                    words("declaration for"),
+                DupPieces = [words("Duplicate"), pragma_decl("oisu"),
+                    words("declarations for"),
                      sym_name_and_arity(TypeName/TypeArity), suffix("."), nl],
                  DupMsg = simple_msg(Context, [always(DupPieces)]),
                  DupSpec = error_spec(severity_error, phase_parse_tree_to_hlds,
@@ -3164,7 +3164,7 @@ find_unique_pred_for_oisu(ModuleInfo, Context, TypeCtor, Kind,
          TypeCtor = type_ctor(TypeName, TypeArity),
          Pieces = [words("In the"), nth_fixed(!.SeqNum),
              fixed(Kind), words("predicate specification"),
-            words("within the"), quote("pragma oisu"),
+            words("within the"), pragma_decl("oisu"),
              words("declaration for"),
              sym_name_and_arity(TypeName/TypeArity), suffix(":"), nl,
              words("error: ambiguous predicate name"),
@@ -3208,7 +3208,7 @@ add_pragma_fact_table(FTInfo, Status, Context, !ModuleInfo, !Specs) :-
      (
          PredIds = [],
          undefined_pred_or_func_error(Pred, Arity, Context,
-            [quote(":- pragma fact_table"), words("declaration")], !Specs)
+            [pragma_decl("fact_table"), words("declaration")], !Specs)
      ;
          PredIds = [HeadPredId | TailPredIds],
          (
@@ -3451,7 +3451,7 @@ clauses_info_do_add_pragma_foreign_proc(Purity, Attributes0,
          MultipleArgs = [_ | _],
          adjust_func_arity(PredOrFunc, OrigArity, Arity),
          SimpleCallId = simple_call_id(PredOrFunc, PredName, OrigArity),
-        Pieces1 = [words("In"), quote(":- pragma foreign_proc"),
+        Pieces1 = [words("In"), pragma_decl("foreign_proc"),
              words("declaration for"), simple_call(SimpleCallId),
              suffix(":"), nl],
          (
diff --git a/compiler/add_type.m b/compiler/add_type.m
index 6716a6e..8b214b2 100644
--- a/compiler/add_type.m
+++ b/compiler/add_type.m
@@ -457,7 +457,7 @@ check_foreign_type(TypeCtor, ForeignTypeBody, Context, FoundError, !ModuleInfo,
          ; Target = target_erlang, LangStr = "Erlang"
          ),
          MainPieces = [words("Error: no"), fixed(LangStr),
-            quote("pragma foreign_type"), words("declaration for"),
+            pragma_decl("foreign_type"), words("declaration for"),
              sym_name_and_arity(Name/Arity), nl],
          VerbosePieces = [words("There are representations for this type"),
              words("on other back-ends, but none for this back-end."), nl],
diff --git a/compiler/det_analysis.m b/compiler/det_analysis.m
index 6e51fc1..204634e 100644
--- a/compiler/det_analysis.m
+++ b/compiler/det_analysis.m
@@ -368,7 +368,7 @@ det_infer_proc(PredId, ProcId, !ModuleInfo, OldDetism, NewDetism, !Specs) :-
                  PragmaContext)
          ->
              ExportPieces = [words("Error:"),
-                quote(":- pragma foreign_export"), words("declaration"),
+                pragma_decl("foreign_export"), words("declaration"),
                  words("for a procedure that has a determinism of"),
                  fixed(determinism_to_string(NewDetism) ++ ".")],
              ExportSpec = error_spec(severity_error, phase_detism_check,
diff --git a/compiler/det_report.m b/compiler/det_report.m
index 3d407e1..afd3651 100644
--- a/compiler/det_report.m
+++ b/compiler/det_report.m
@@ -245,10 +245,12 @@ check_determinism(PredId, ProcId, PredInfo, ProcInfo, !ModuleInfo, !Specs) :-
                  status_defined_in_this_module(ImportStatus) = yes
              ->
                  proc_info_get_detism_decl(ProcInfo, DetismDecl),
-                Message = "warning: " ++ detism_decl_name(DetismDecl) ++
-                    " could be tighter.\n",
+                MessagePieces = [words("warning:"),
+                    words(detism_decl_name(DetismDecl)),
+                    words("could be tighter."), nl
+                ],
                  report_determinism_problem(PredId, ProcId, !.ModuleInfo,
-                    Message, DeclaredDetism, InferredDetism, ReportMsgs),
+                    MessagePieces, DeclaredDetism, InferredDetism, ReportMsgs),
                  ReportSpec = error_spec(severity_warning, phase_detism_check,
                      ReportMsgs),
                  !:Specs = [ReportSpec | !.Specs]
@@ -258,10 +260,11 @@ check_determinism(PredId, ProcId, PredInfo, ProcInfo, !ModuleInfo, !Specs) :-
          ;
              Cmp = tighter,
              proc_info_get_detism_decl(ProcInfo, DetismDecl),
-            Message = "error: " ++ detism_decl_name(DetismDecl) ++
-                " not satisfied.\n",
-            report_determinism_problem(PredId, ProcId, !.ModuleInfo, Message,
-                DeclaredDetism, InferredDetism, ReportMsgs),
+            MessagePieces = [words("error:"),
+                words(detism_decl_name(DetismDecl)),
+                words("not satisfied."), nl],
+            report_determinism_problem(PredId, ProcId, !.ModuleInfo,
+                MessagePieces, DeclaredDetism, InferredDetism, ReportMsgs),
              proc_info_get_goal(ProcInfo, Goal),
              proc_info_get_vartypes(ProcInfo, VarTypes),
              proc_info_get_initial_instmap(ProcInfo, !.ModuleInfo, InstMap0),
@@ -288,9 +291,8 @@ check_determinism(PredId, ProcId, PredInfo, ProcInfo, !ModuleInfo, !Specs) :-
      ;
          Valid = no,
          proc_info_get_context(ProcInfo, Context),
-        MainPieces =
-            [words("Error: `pragma "
-                ++ eval_method_to_pragma_name(EvalMethod) ++ "'"),
+        MainPieces = [words("Error:"),
+            pragma_decl(eval_method_to_pragma_name(EvalMethod)),
              words("declaration not allowed for procedure"),
              words("with determinism"),
              quote(determinism_to_string(InferredDetism)), suffix(".")],
@@ -490,20 +492,24 @@ det_check_lambda(DeclaredDetism, InferredDetism, Goal, GoalInfo, InstMap0,
      ).

  :- pred report_determinism_problem(pred_id::in, proc_id::in, module_info::in,
-    string::in, determinism::in, determinism::in, list(error_msg)::out) is det.
+    format_components::in, determinism::in, determinism::in,
+    list(error_msg)::out) is det.

-report_determinism_problem(PredId, ProcId, ModuleInfo, Message,
+report_determinism_problem(PredId, ProcId, ModuleInfo, MessagePieces,
          DeclaredDetism, InferredDetism, Msgs) :-
      module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
      proc_info_get_context(ProcInfo, Context),
      ProcPieces = describe_one_proc_name_mode(ModuleInfo,
          should_not_module_qualify, proc(PredId, ProcId)),
-    Pieces = [words("In")] ++ ProcPieces ++ [suffix(":"), nl,
-        words(Message), nl,
-        words("Declared"),
-        quote(determinism_to_string(DeclaredDetism)), suffix(","),
-        words("inferred"),
-        quote(determinism_to_string(InferredDetism)), suffix(".")],
+    Pieces = [words("In")] ++ ProcPieces ++ [suffix(":"), nl] ++
+        MessagePieces ++
+        [
+            nl,
+            words("Declared"),
+            quote(determinism_to_string(DeclaredDetism)), suffix(","),
+            words("inferred"),
+            quote(determinism_to_string(InferredDetism)), suffix(".")
+        ],
      Msgs = [simple_msg(Context, [always(Pieces)])].

  %-----------------------------------------------------------------------------%
diff --git a/compiler/error_util.m b/compiler/error_util.m
index eb75f64..9b33e51 100644
--- a/compiler/error_util.m
+++ b/compiler/error_util.m
@@ -326,6 +326,13 @@
      ;       simple_call(simple_call_id)
              % Output the identity of the given call.

+    ;       decl(string)
+            % Prefix the string with ":- ", surround with single quotes
+            % and then treat as fixed.
+
+    ;       pragma_decl(string)
+            % As above but prefix the string with ":- pragma ".
+
      ;       nl
              % Insert a line break if there has been text output since
              % the last line break.
@@ -1084,6 +1091,14 @@ error_pieces_to_string_2(FirstInMsg, [Component | Components]) = Str :-
          Word = simple_call_id_to_string(SimpleCallId),
          Str = join_string_and_tail(Word, Components, TailStr)
      ;
+        Component = decl(Decl),
+        Word = add_quotes(":- " ++ Decl),
+        Str = join_string_and_tail(Word, Components, TailStr)
+    ;
+        Component = pragma_decl(PragmaName),
+        Word = add_quotes(":- pragma " ++ PragmaName),
+        Str = join_string_and_tail(Word, Components, TailStr)
+    ;
          Component = top_ctor_of_type(Type),
          ( type_to_ctor(Type, TypeCtor) ->
              TypeCtor = type_ctor(TypeCtorName, TypeCtorArity),
@@ -1091,7 +1106,7 @@ error_pieces_to_string_2(FirstInMsg, [Component | Components]) = Str :-
              Word = sym_name_and_arity_to_word(SymName),
              Str = join_string_and_tail(Word, Components, TailStr)
          ;
-            error("error_pieces_to_string: type is variable")
+            unexpected($file, $pred, "type is variable")
          )
      ;
          Component = nl,
@@ -1212,7 +1227,7 @@ convert_components_to_paragraphs_acc(FirstInMsg, [Component | Components],
              NewWord = plain_word(sym_name_and_arity_to_word(SymName)),
              RevWords1 = [NewWord | RevWords0]
          ;
-            error("convert_components_to_paragraphs_acc: type is variable")
+            unexpected($file, $pred, "type is variable")
          )
      ;
          Component = p_or_f(PredOrFunc),
@@ -1223,6 +1238,14 @@ convert_components_to_paragraphs_acc(FirstInMsg, [Component | Components],
          WordsStr = simple_call_id_to_string(SimpleCallId),
          break_into_words(WordsStr, RevWords0, RevWords1)
      ;
+        Component = decl(DeclName),
+        Word = add_quotes(":- " ++ DeclName),
+        RevWords1 = [plain_word(Word) | RevWords0]
+    ;
+        Component = pragma_decl(PragmaName),
+        Word = add_quotes(":- pragma " ++ PragmaName),
+        RevWords1 = [plain_word(Word) | RevWords0]
+    ;
          Component = nl,
          Strings = rev_words_to_strings(RevWords0),
          !:Paras = snoc(!.Paras, paragraph(Strings, 0, 0)),
@@ -1341,12 +1364,12 @@ lower_initial(Str0) = Str :-
  :- func sym_name_to_word(sym_name) = string.

  sym_name_to_word(SymName) =
-    "`" ++ sym_name_to_string(SymName) ++ "'".
+    add_quotes(sym_name_to_string(SymName)).

  :- func sym_name_and_arity_to_word(sym_name_and_arity) = string.

  sym_name_and_arity_to_word(SymName / Arity) =
-    "`" ++ sym_name_to_string(SymName) ++ "'" ++ "/" ++ int_to_string(Arity).
+    add_quotes(sym_name_to_string(SymName)) ++ "/" ++ int_to_string(Arity).

  :- pred break_into_words(string::in, list(word)::in, list(word)::out) is det.

diff --git a/compiler/goal_expr_to_goal.m b/compiler/goal_expr_to_goal.m
index 93ebdaa..68165be 100644
--- a/compiler/goal_expr_to_goal.m
+++ b/compiler/goal_expr_to_goal.m
@@ -358,7 +358,8 @@ transform_goal_expr_to_goal(LocKind, Expr, Context, Renaming, Goal,
                  MaybeElse0 = yes(_),
                  Pieces = [words("Error: a"), quote("try"),
                      words("goal with an"), quote("io"),
-                    words("parameter cannot have an else part."), nl],
+                    words("parameter cannot have an"), quote("else"),
+                    words("part."), nl],
                  Msg = simple_msg(Context, [always(Pieces)]),
                  Spec = error_spec(severity_error,
                      phase_parse_tree_to_hlds, [Msg]),
diff --git a/compiler/hlds_out_util.m b/compiler/hlds_out_util.m
index 3e53470..82c4527 100644
--- a/compiler/hlds_out_util.m
+++ b/compiler/hlds_out_util.m
@@ -432,6 +432,8 @@ in_argument_to_pieces(First, SubContext, !Pieces) :-
      start_in_message_to_pieces(First, !Pieces),
      SubContext = unify_sub_context(ConsId, ArgNum),
      ArgNumStr = int_to_string(ArgNum),
+    % XXX Using cons_id_and_arity_to_string here results in the
+    % quotes being in the wrong place.
      ConsIdStr = cons_id_and_arity_to_string(ConsId),
      !:Pieces = !.Pieces ++ [words("argument"), fixed(ArgNumStr),
          words("of functor"), quote(ConsIdStr), suffix(":"), nl].
diff --git a/compiler/make_hlds_passes.m b/compiler/make_hlds_passes.m
index bed501b..6dc8f15 100644
--- a/compiler/make_hlds_passes.m
+++ b/compiler/make_hlds_passes.m
@@ -3107,7 +3107,7 @@ add_stratified_pred(PragmaName, Name, Arity, Context, !ModuleInfo, !Specs) :-
          module_info_set_stratified_preds(StratPredIds, !ModuleInfo)
      ;
          PredIds = [],
-        DescPieces = [quote(":- pragma " ++ PragmaName), words("declaration")],
+        DescPieces = [pragma_decl(PragmaName), words("declaration")],
          undefined_pred_or_func_error(Name, Arity, Context, DescPieces, !Specs)
      ).

@@ -3152,7 +3152,7 @@ do_add_pred_marker(PragmaName, Name, Arity, Status, MustBeExported, Context,
          module_info_set_predicate_table(PredTable, !ModuleInfo)
      ;
          PredIds = [],
-        DescPieces = [quote(":- pragma " ++ PragmaName), words("declaration")],
+        DescPieces = [pragma_decl(PragmaName), words("declaration")],
          undefined_pred_or_func_error(Name, Arity, Context, DescPieces, !Specs)
      ).

@@ -3183,7 +3183,7 @@ module_mark_as_external(PredName, Arity, Context, !ModuleInfo, !Specs) :-
      ;
          PredIds = [],
          undefined_pred_or_func_error(PredName, Arity, Context,
-            [quote(":- external"), words("declaration")], !Specs)
+            [decl("external"), words("declaration")], !Specs)
      ).

  :- pred module_mark_preds_as_external(list(pred_id)::in,
diff --git a/compiler/make_hlds_warn.m b/compiler/make_hlds_warn.m
index e080cc3..58f940f 100644
--- a/compiler/make_hlds_warn.m
+++ b/compiler/make_hlds_warn.m
@@ -665,7 +665,7 @@ check_fp_body_for_success_indicator(ModuleInfo, Lang, Context, SimpleCallId,
                  ( list.member(SuccIndStr, BodyPieces) ->
                      LangStr = foreign_language_string(Lang),
                      Pieces = [
-                        words("warning: the "), fixed(LangStr),
+                        words("Warning: the"), fixed(LangStr),
                          words("code for"), simple_call(SimpleCallId),
                          words("may set"), quote(SuccIndStr), suffix(","),
                          words("but it cannot fail.")
@@ -691,7 +691,7 @@ check_fp_body_for_success_indicator(ModuleInfo, Lang, Context, SimpleCallId,
                  ;
                      LangStr = foreign_language_string(Lang),
                      Pieces = [
-                        words("warning: the "), fixed(LangStr),
+                        words("Warning: the"), fixed(LangStr),
                          words("code for"), simple_call(SimpleCallId),
                          words("does not appear to set"),
                          quote(SuccIndStr), suffix(","),
@@ -736,7 +736,7 @@ check_fp_body_for_return(Lang, Context, SimpleCallId, BodyPieces, !Specs) :-
          ( list.member("return", BodyPieces) ->
              LangStr = foreign_language_string(Lang),
              Pieces = [
-                words("warning: the "), fixed(LangStr),
+                words("Warning: the"), fixed(LangStr),
                  words("code for"), simple_call(SimpleCallId),
                  words("may contain a"), quote("return"),
                  words("statement."), nl
@@ -760,7 +760,7 @@ check_fp_body_for_return(Lang, Context, SimpleCallId, BodyPieces, !Specs) :-
              )
          ->
              Pieces = [
-                words("warning: the IL code for"), simple_call(SimpleCallId),
+                words("Warning: the IL code for"), simple_call(SimpleCallId),
                  words("may contain a"), quote("ret"),
                  words("or"), quote("jmp"),
                  words("instruction."), nl
diff --git a/compiler/modules.m b/compiler/modules.m
index de424d4..3ea52a7 100644
--- a/compiler/modules.m
+++ b/compiler/modules.m
@@ -1764,12 +1764,12 @@ generate_no_exports_warning(Globals, ModuleName, Spec, !IO) :-
          verbose_only(
              [words("To be useful, a module should export something."),
              words("A file should contain at least one declaration"),
-            words("other than"), quote(":- import_module"),
+            words("other than"), decl("import_module"),
              words("in its interface section(s)."),
              words("This would normally be a"),
-            quote(":- pred"), suffix(","), quote(":- func"), suffix(","),
-            quote(":- type"), suffix(","), quote(":- inst"), words("or"),
-            quote(":- mode"), words("declaration.")])
+            decl("pred"), suffix(","), decl("func"), suffix(","),
+            decl("type"), suffix(","), decl("inst"), words("or"),
+            decl("mode"), words("declaration.")])
          ]),
      Msg = simple_msg(Context, [Component]),
      Spec = error_spec(Severity, phase_term_to_parse_tree, [Msg]).
@@ -2216,8 +2216,8 @@ do_warn_if_duplicate_use_import_decls(_ModuleName, FileName,
              words(choose_number(BothList, "module", "modules"))] ++
              component_list_to_pieces(list.map(wrap_symname, BothList)) ++
              [words(choose_number(BothList, "is", "are")),
-            words("imported using both"), quote(":- import_module"),
-            words("and"), quote(":- use_module"), words("declarations."), nl],
+            words("imported using both"), decl("import_module"),
+            words("and"), decl("use_module"), words("declarations."), nl],
          Msg = simple_msg(Context,
              [option_is_set(warn_simple_code, yes, [always(Pieces)])]),
          Severity = severity_conditional(warn_simple_code, yes,
@@ -3497,8 +3497,7 @@ report_error_implementation_in_interface(ModuleName, Context, !Specs) :-
      Pieces = [words("In interface for module"), sym_name(ParentModule),
          suffix(":"), nl, words("in definition of sub-module"),
          quote(ChildModule), suffix(":"), nl,
-        % XXX should there be a full stop after implementation?
-        words("error:"), quote(":- implementation."),
+        words("error:"), decl("implementation"),
          words("declaration for sub-module\n"),
          words("occurs in interface section of parent module.")],
      Msg = simple_msg(Context, [always(Pieces)]),
diff --git a/compiler/oisu_check.m b/compiler/oisu_check.m
index c12fa87..86ccb51 100644
--- a/compiler/oisu_check.m
+++ b/compiler/oisu_check.m
@@ -154,7 +154,7 @@ check_local_oisu_pred(ModuleInfo, KindMap, OISUTypeCtors,
                  PredDesc = describe_one_pred_info_name(
                      should_not_module_qualify, PredInfo0),
                  ProcsPieces = PredDesc ++ [words("is mentioned"),
-                    words("in a"), quote("pragma oisu"), words("declaration,"),
+                    words("in a"), pragma_decl("oisu"), words("declaration,"),
                      words("so it should have exactly one procedure."), nl],
                  pred_info_get_context(PredInfo0, Context),
                  ProcsMsg = simple_msg(Context, [always(ProcsPieces)]),
@@ -430,7 +430,7 @@ check_args_have_no_oisu_types(PredInfo, OISUTypeCtors, [Type | Types],
              PredInfo),
          TypeCtor = type_ctor(TypeName, TypeArity),
          ProcsPieces = PredDesc ++ [words("is not mentioned"),
-            words("in the"), quote("pragma oisu"), words("declaration"),
+            words("in the"), pragma_decl("oisu"), words("declaration"),
              words("as a predicate that handles values of the type"),
              sym_name_and_arity(TypeName / TypeArity), nl],
          pred_info_get_context(PredInfo, Context),
diff --git a/compiler/prog_io.m b/compiler/prog_io.m
index 02044ca..d945451 100644
--- a/compiler/prog_io.m
+++ b/compiler/prog_io.m
@@ -473,9 +473,9 @@ check_end_module(EndModule, !Items, !Specs, !Error) :-
              StartModuleName \= EndModuleName
          ->
              Pieces = [words("Error:"),
-                quote(":- end_module"), words("declaration"),
+                decl("end_module"), words("declaration"),
                  words("does not match"),
-                quote(":- module"), words("declaration."), nl],
+                decl("module"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(EndModuleContext, [always(Pieces)])]),
              !:Specs = [Spec | !.Specs],
@@ -684,7 +684,7 @@ read_first_item(DefaultModuleName, !SourceFileName, ModuleName,
              term.context_init(!.SourceFileName, 1, FirstContext)
          ),
          Pieces = [words("Error: module must start with a"),
-            quote(":- module"), words("declaration."), nl],
+            decl("module"), words("declaration."), nl],
          Severity = severity_error,
          Msgs  = [always(Pieces)],
          Spec = error_spec(Severity, phase_term_to_parse_tree,
@@ -1518,7 +1518,7 @@ parse_func_decl_base(ModuleName, VarSet, Term, Condition, MaybeDet,
                  [MaybeSugaredFuncTerm, ReturnTerm], _)
          ->
              FuncTerm = desugar_field_access(MaybeSugaredFuncTerm),
-            ContextPieces = [words("In"), quote(":- func"),
+            ContextPieces = [words("In"), decl("func"),
                  words("declaration")],
              parse_implicitly_qualified_sym_name_and_args(ModuleName, FuncTerm,
                  VarSet, ContextPieces, MaybeFuncNameAndArgs),
@@ -1535,7 +1535,7 @@ parse_func_decl_base(ModuleName, VarSet, Term, Condition, MaybeDet,
                  ;
                      FuncTermStr = describe_error_term(VarSet, FuncTerm),
                      ArgsPieces = [words("Error: syntax error in arguments of"),
-                        quote(":- func"), words("declaration at"),
+                        decl("func"), words("declaration at"),
                          words(FuncTermStr), suffix("."), nl],
                      ArgsSpec = error_spec(severity_error,
                          phase_term_to_parse_tree,
@@ -1550,7 +1550,7 @@ parse_func_decl_base(ModuleName, VarSet, Term, Condition, MaybeDet,
                      MaybeReturnArg = ok1(ReturnArgPrime)
                  ;
                      ReturnPieces = [words("Error: syntax error"),
-                        words("in return type of"), quote(":- func"),
+                        words("in return type of"), decl("func"),
                          words("declaration."), nl],
                      ReturnSpec = error_spec(severity_error,
                          phase_term_to_parse_tree,
@@ -1576,7 +1576,7 @@ parse_func_decl_base(ModuleName, VarSet, Term, Condition, MaybeDet,
              )
          ;
              Pieces = [words("Error:"), quote("="), words("expected in"),
-                quote(":- func"), words("declaration."), nl],
+                decl("func"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(Term), [always(Pieces)])]),
              MaybeItem = error1([Spec])
@@ -1755,7 +1755,7 @@ parse_mode_decl_base(ModuleName, VarSet, Term, Condition, Attributes, WithInst,
              [MaybeSugaredFuncTerm, ReturnTypeTerm], _)
      ->
          FuncTerm = desugar_field_access(MaybeSugaredFuncTerm),
-        ContextPieces = [words("In function"), quote(":- mode"),
+        ContextPieces = [words("In function"), decl("mode"),
              words("declaration")],
          parse_implicitly_qualified_sym_name_and_args(ModuleName, FuncTerm,
              VarSet, ContextPieces, MaybeFunctorArgs),
@@ -1769,7 +1769,7 @@ parse_mode_decl_base(ModuleName, VarSet, Term, Condition, Attributes, WithInst,
                  Attributes, Context, SeqNum, MaybeItem)
          )
      ;
-        ContextPieces = [words("In"), quote(":- mode"), words("declaration")],
+        ContextPieces = [words("In"), decl("mode"), words("declaration")],
          parse_implicitly_qualified_sym_name_and_args(ModuleName, Term,
              VarSet, ContextPieces, MaybeFunctorArgs),
          (
@@ -2250,9 +2250,9 @@ get_purity(Purity, !Attributes) :-
  :- func pred_or_func_decl_pieces(pred_or_func) = list(format_component).

  pred_or_func_decl_pieces(pf_function) =
-    [quote(":- func"), words("declaration")].
+    [decl("func"), words("declaration")].
  pred_or_func_decl_pieces(pf_predicate) =
-    [quote(":- pred"), words("declaration")].
+    [decl("pred"), words("declaration")].

  %-----------------------------------------------------------------------------%

diff --git a/compiler/prog_io_mode_defn.m b/compiler/prog_io_mode_defn.m
index 06f64f2..90e7051 100644
--- a/compiler/prog_io_mode_defn.m
+++ b/compiler/prog_io_mode_defn.m
@@ -71,7 +71,7 @@ parse_inst_defn(ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
              Condition, Context, SeqNum, MaybeItem)
      ;
          Pieces = [words("Error:"), quote("=="), words("expected in"),
-            quote(":- inst"), words("definition."), nl],
+            decl("inst"), words("definition."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(Term), [always(Pieces)])]),
          MaybeItem = error1([Spec])
diff --git a/compiler/prog_io_mutable.m b/compiler/prog_io_mutable.m
index 2c8fa0d..e2eb517 100644
--- a/compiler/prog_io_mutable.m
+++ b/compiler/prog_io_mutable.m
@@ -60,7 +60,7 @@ parse_initialise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
          (
              SymNameSpecifier = name(_),
              TermStr = describe_error_term(VarSet, Term),
-            Pieces = [words("Error:"), quote("initialise"),
+            Pieces = [words("Error:"), decl("initialise"),
                  words("declaration"), words("requires arity, found"),
                  words(TermStr), suffix("."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
@@ -75,10 +75,10 @@ parse_initialise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
                  MaybeItem = ok1(Item)
              ;
                  TermStr = describe_error_term(VarSet, Term),
-                Pieces = [words("Error:"), quote("initialise"),
+                Pieces = [words("Error:"), decl("initialise"),
                      words("declaration specifies a predicate"),
                      words("whose arity is not zero or two:"),
-                    words(TermStr), suffix("."), nl],
+                    fixed(TermStr), suffix("."), nl],
                  Spec = error_spec(severity_error, phase_term_to_parse_tree,
                      [simple_msg(get_term_context(Term), [always(Pieces)])]),
                  MaybeItem = error1([Spec])
@@ -98,9 +98,9 @@ parse_finalise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
          (
              SymNameSpecifier = name(_),
              TermStr = describe_error_term(VarSet, Term),
-            Pieces = [words("Error:"), quote("finalise"),
+            Pieces = [words("Error:"), decl("finalise"),
                  words("declaration"), words("requires arity, found"),
-                words(TermStr), suffix("."), nl],
+                fixed(TermStr), suffix("."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(Term), [always(Pieces)])]),
              MaybeItem = error1([Spec])
@@ -113,7 +113,7 @@ parse_finalise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
                  MaybeItem = ok1(Item)
              ;
                  TermStr = describe_error_term(VarSet, Term),
-                Pieces = [words("Error:"), quote("finalise"),
+                Pieces = [words("Error:"), decl("finalise"),
                      words("declaration specifies a predicate"),
                      words("whose arity is not zero or two:"),
                      words(TermStr), suffix("."), nl],
@@ -190,8 +190,8 @@ parse_mutable_name(NameTerm, MaybeName) :-
  parse_mutable_type(VarSet, TypeTerm, MaybeType) :-
      ( term.contains_var(TypeTerm, _) ->
          TypeTermStr = describe_error_term(VarSet, TypeTerm),
-        Pieces = [words("Error: the type in a mutable declaration"),
-            words("cannot contain variables:"),
+        Pieces = [words("Error: the type in a"), decl("mutable"),
+            words("declaration cannot contain variables:"),
              words(TypeTermStr), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(TypeTerm), [always(Pieces)])]),
@@ -206,8 +206,8 @@ parse_mutable_type(VarSet, TypeTerm, MaybeType) :-
  parse_mutable_inst(VarSet, InstTerm, MaybeInst) :-
      ( term.contains_var(InstTerm, _) ->
          InstTermStr = describe_error_term(VarSet, InstTerm),
-        Pieces = [words("Error: the inst in a mutable declaration"),
-            words("cannot contain variables:"),
+        Pieces = [words("Error: the inst in a"), decl("mutable"),
+            words("declaration cannot contain variables:"),
              words(InstTermStr), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(InstTerm), [always(Pieces)])]),
@@ -215,7 +215,8 @@ parse_mutable_inst(VarSet, InstTerm, MaybeInst) :-
      ; convert_inst(no_allow_constrained_inst_var, InstTerm, Inst) ->
          MaybeInst = ok1(Inst)
      ;
-        Pieces = [words("Error: invalid inst in mutable declaration."), nl],
+        Pieces = [words("Error: invalid inst in"), decl("mutable"),
+            words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(InstTerm), [always(Pieces)])]),
          MaybeInst = error1([Spec])
@@ -274,7 +275,7 @@ parse_mutable_attrs(VarSet, MutAttrsTerm, MaybeMutAttrs) :-
      ;
          MutAttrsStr = mercury_term_to_string(VarSet, no, MutAttrsTerm),
          Pieces = [words("Error: malformed attribute list"),
-            words("in mutable declaration:"),
+            words("in"), decl("mutable"), words("declaration:"),
              words(MutAttrsStr), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(MutAttrsTerm), [always(Pieces)])]),
@@ -338,7 +339,7 @@ parse_mutable_attr(MutAttrTerm, MutAttrResult) :-
          MutAttrResult = ok1(MutAttr)
      ;
          Pieces = [words("Error: unrecognised attribute"),
-            words("in mutable declaration."), nl],
+            words("in"), decl("mutable"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(MutAttrTerm), [always(Pieces)])]),
          MutAttrResult = error1([Spec])
diff --git a/compiler/prog_io_pragma.m b/compiler/prog_io_pragma.m
index f308b65..e75fe6b 100644
--- a/compiler/prog_io_pragma.m
+++ b/compiler/prog_io_pragma.m
@@ -344,7 +344,7 @@ parse_pragma_source_file(PragmaTerms, ErrorTerm, Context, SeqNum, MaybeItem) :-
              MaybeItem = ok1(Item)
          ;
              Pieces = [words("Error: the argument of a"),
-                quote(":- pragma source_file"),
+                pragma_decl("source_file"),
                  words("declaration should be a string."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(SourceFileTerm),
@@ -353,7 +353,7 @@ parse_pragma_source_file(PragmaTerms, ErrorTerm, Context, SeqNum, MaybeItem) :-
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma source_file"), words("declaration."), nl],
+            pragma_decl("source_file"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -403,7 +403,7 @@ parse_pragma_foreign_type(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
                          MaybeAssertionTerm = yes(ErrorAssertionTerm)
                      ->
                          Pieces = [words("Error: invalid assertion in"),
-                            quote(":- pragma foreign_type"),
+                            pragma_decl("foreign_type"),
                              words("declaration."), nl],
                          Spec = error_spec(severity_error,
                              phase_term_to_parse_tree,
@@ -425,14 +425,14 @@ parse_pragma_foreign_type(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
              )
          ;
              Pieces = [words("Error: invalid foreign language in"),
-                quote(":- pragma foreign_type"), words("declaration."), nl],
+                pragma_decl("foreign_type"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(LangTerm), [always(Pieces)])]),
              MaybeItem = error1([Spec])
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma foreign_type"), words("declaration."), nl],
+            pragma_decl("foreign_type"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -497,7 +497,7 @@ parse_pragma_foreign_export_enum(PragmaTerms, ErrorTerm, VarSet, Context,
              )
          ;
              Pieces = [words("Error: invalid foreign language in"),
-                quote(":- pragma foreign_export_enum"), words("declaration."),
+                pragma_decl("foreign_export_enum"), words("declaration."),
                  nl],
              % XXX Get_term_context(LangTerm) would be better.
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
@@ -506,7 +506,7 @@ parse_pragma_foreign_export_enum(PragmaTerms, ErrorTerm, VarSet, Context,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma foreign_export_enum"), words("declaration."), nl],
+            pragma_decl("foreign_export_enum"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -519,7 +519,7 @@ parse_export_enum_type_ctor(TypeTerm, MaybeTypeCtor) :-
          MaybeTypeCtor = ok1(type_ctor(Name, Arity))
      ;
          Pieces = [words("Error: expected name/arity for type in"),
-            quote(":- pragma foreign_export_enum"), words("declaration."), nl],
+            pragma_decl("foreign_export_enum"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(TypeTerm), [always(Pieces)])]),
          MaybeTypeCtor = error1([Spec])
@@ -587,7 +587,7 @@ parse_export_enum_attributes(VarSet, AttributesTerm, AttributesResult) :-
          ->
              % XXX Print the conflicting attributes themselves.
              Pieces = [words("Error: conflicting attributes in"),
-                quote(":- pragma foreign_export_enum"), words("declaration."),
+                pragma_decl("foreign_export_enum"), words("declaration."),
                  nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(AttributesTerm),
@@ -611,7 +611,7 @@ parse_export_enum_attributes(VarSet, AttributesTerm, AttributesResult) :-
                  % XXX Print the multiply-occurring attribute.
                  Pieces = [words("Error: prefix attribute"),
                      words("occurs multiple times in"),
-                    quote(":- pragma foreign_export_enum"),
+                    pragma_decl("foreign_export_enum"),
                      words("declaration."), nl],
                  Spec = error_spec(severity_error, phase_term_to_parse_tree,
                      [simple_msg(get_term_context(AttributesTerm),
@@ -621,7 +621,7 @@ parse_export_enum_attributes(VarSet, AttributesTerm, AttributesResult) :-
          )
      ;
          Pieces = [words("Error: malformed attributes list in"),
-            quote(":- pragma foreign_export_enum"), words("declaration."), nl],
+            pragma_decl("foreign_export_enum"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(AttributesTerm), [always(Pieces)])]),
          AttributesResult = error1([Spec])
@@ -657,7 +657,7 @@ parse_export_enum_attr(VarSet, Term, MaybeAttribute) :-
      ;
          TermStr = describe_error_term(VarSet, Term),
          Pieces = [words("Error: unrecognised attribute in"),
-            quote(":- pragma foreign_export_enum"), words("declaration:"),
+            pragma_decl("foreign_export_enum"), words("declaration:"),
              words(TermStr), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(Term), [always(Pieces)])]),
@@ -704,7 +704,7 @@ parse_pragma_foreign_enum(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
              )
          ;
              Pieces = [words("Error: invalid foreign language in"),
-                quote(":- pragma foreign_export_enum"), words("declaration."),
+                pragma_decl("foreign_export_enum"), words("declaration."),
                  nl],
              % XXX We should use the context of LangTerm.
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
@@ -713,7 +713,7 @@ parse_pragma_foreign_enum(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma foreign_export_enum"), words("declaration."), nl],
+            pragma_decl("foreign_export_enum"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -732,7 +732,7 @@ parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
      ( PragmaTerms = [LangTerm, PredAndModesTerm, FunctionTerm] ->
          ( FunctionTerm = term.functor(term.string(Function), [], _) ->
              ContextPieces = [words("In"),
-                quote(":- pragma foreign_export"), words("declaration")],
+                pragma_decl("foreign_export"), words("declaration")],
              parse_pred_or_func_and_arg_modes(no, PredAndModesTerm,
                  ErrorTerm, VarSet, ContextPieces, MaybePredAndModes),
              (
@@ -749,8 +749,8 @@ parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
                      MaybeItem = ok1(Item)
                  ;
                      Pieces = [words("Error: invalid foreign language in"),
-                        quote(":- pragma foreign_export"),
-                        words("declaration."), nl],
+                        pragma_decl("foreign_export"), words("declaration."),
+                        nl],
                      Spec = error_spec(severity_error, phase_term_to_parse_tree,
                          [simple_msg(get_term_context(LangTerm),
                              [always(Pieces)])]),
@@ -773,7 +773,7 @@ parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma foreign_export"), words("declaration."), nl],
+            pragma_decl("foreign_export"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -798,7 +798,7 @@ parse_pragma_foreign_import_module(PragmaTerms, ErrorTerm, Context, SeqNum,
              MaybeItem = ok1(Item)
          ;
              Pieces = [words("Error: invalid foreign language in"),
-                quote(":- pragma foreign_import_module"),
+                pragma_decl("foreign_import_module"),
                  words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(LangTerm), [always(Pieces)])]),
@@ -807,7 +807,7 @@ parse_pragma_foreign_import_module(PragmaTerms, ErrorTerm, Context, SeqNum,
      ;
          Pieces = [words("Error: wrong number of arguments"),
              words("or invalid module name in"),
-            quote(":- pragma foreign_import_module"),
+            pragma_decl("foreign_import_module"),
              words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -842,7 +842,7 @@ parse_pragma_unused_args(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
          MaybeItem = ok1(Item)
      ;
          % XXX Improve this message.
-        Pieces = [words("Error in"), quote(":- pragma unused_args"),
+        Pieces = [words("Error in"), pragma_decl("unused_args"),
              suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -871,7 +871,7 @@ parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
              MaybeName = yes(SpecName)
          )
      ->
-        ArityOrModesContextPieces = [words("In"), quote(":- pragma type_spec"),
+        ArityOrModesContextPieces = [words("In"), pragma_decl("type_spec"),
              words("declaration:")],
          parse_arity_or_modes(ModuleName, PredAndModesTerm, ErrorTerm,
              VarSet, ArityOrModesContextPieces, MaybeArityOrModes),
@@ -903,7 +903,7 @@ parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
                  MaybeItem = ok1(Item)
              ;
                  Pieces = [words("Error: expected type substitution in"),
-                    quote(":- pragma type_spec"), words("declaration."), nl],
+                    pragma_decl("type_spec"), words("declaration."), nl],
                  Spec = error_spec(severity_error, phase_term_to_parse_tree,
                      [simple_msg(get_term_context(TypeSubnTerm),
                          [always(Pieces)])]),
@@ -915,7 +915,7 @@ parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma type_spec"), words("declaration."), nl],
+            pragma_decl("type_spec"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -953,7 +953,7 @@ parse_pragma_fact_table(ModuleName, PragmaTerms, ErrorTerm,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma fact_table"), words("declaration."), nl],
+            pragma_decl("fact_table"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -967,7 +967,7 @@ parse_pragma_termination_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
      (
          PragmaTerms = [PredAndModesTerm0, ArgSizeTerm, TerminationTerm],
          ContextPieces = [words("In"),
-            quote(":- pragma termination_info"), words("declaration:")],
+            pragma_decl("termination_info"), words("declaration:")],
          parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
              ErrorTerm, VarSet, ContextPieces, MaybeNameAndModes),
          MaybeNameAndModes = ok2(PredName - PredOrFunc, ModeList),
@@ -1009,7 +1009,7 @@ parse_pragma_termination_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
          MaybeItem = ok1(Item)
      ;
          Pieces = [words("Syntax error in"),
-            quote(":- pragma termination_info"), words("declaration."), nl],
+            pragma_decl("termination_info"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1023,7 +1023,7 @@ parse_pragma_termination2_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
      (
          PragmaTerms = [PredAndModesTerm0, SuccessArgSizeTerm,
              FailureArgSizeTerm, TerminationTerm],
-        ContextPieces = [words("In"), quote(":- pragma termination2_info"),
+        ContextPieces = [words("In"), pragma_decl("termination2_info"),
              words("declaration:")],
          parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
              ErrorTerm, VarSet, ContextPieces, NameAndModesResult),
@@ -1053,7 +1053,7 @@ parse_pragma_termination2_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
          MaybeItem = ok1(Item)
      ;
          Pieces = [words("Syntax error in"),
-            quote(":- pragma termination2_info"), words("declaration."), nl],
+            pragma_decl("termination2_info"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1068,7 +1068,7 @@ parse_pragma_structure_sharing(ModuleName, PragmaTerms, ErrorTerm, VarSet,
          PragmaTerms = [PredAndModesTerm0, HeadVarsTerm,
              HeadVarTypesTerm, SharingInformationTerm],
          ModesContextPieces = [words("In"),
-            quote(":- pragma structure_sharing"), words("declaration:")],
+            pragma_decl("structure_sharing"), words("declaration:")],
          parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
              ErrorTerm, VarSet, ModesContextPieces, MaybeNameAndModes),
          MaybeNameAndModes = ok2(PredName - PredOrFunc, ModeList),
@@ -1105,7 +1105,7 @@ parse_pragma_structure_sharing(ModuleName, PragmaTerms, ErrorTerm, VarSet,
          MaybeItem = ok1(Item)
      ;
          Pieces = [words("Syntax error in"),
-            quote(":- pragma structure_sharing"), words("declaration."), nl],
+            pragma_decl("structure_sharing"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1119,7 +1119,7 @@ parse_pragma_structure_reuse(ModuleName, PragmaTerms, ErrorTerm, VarSet,
      (
          PragmaTerms = [PredAndModesTerm0, HeadVarsTerm,
              HeadVarTypesTerm, MaybeStructureReuseTerm],
-        ReuseContextPieces = [words("In"), quote(":- pragma structure_reuse"),
+        ReuseContextPieces = [words("In"), pragma_decl("structure_reuse"),
              words("declaration:")],
          parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
              ErrorTerm, VarSet, ReuseContextPieces, MaybeNameAndModes),
@@ -1157,7 +1157,7 @@ parse_pragma_structure_reuse(ModuleName, PragmaTerms, ErrorTerm, VarSet,
          MaybeItem = ok1(Item)
      ;
          Pieces = [words("Syntax error in"),
-            quote(":- pragma structure_reuse"), words("declaration."), nl],
+            pragma_decl("structure_reuse"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1211,7 +1211,7 @@ parse_pragma_exceptions(ModuleName, PragmaTerms, ErrorTerm, Context,
          MaybeItem = ok1(Item)
      ;
          Pieces = [words("Error in"),
-            quote(":- pragma exceptions"), suffix("."), nl],
+            pragma_decl("exceptions"), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1252,7 +1252,7 @@ parse_pragma_trailing_info(ModuleName, PragmaTerms, ErrorTerm, Context,
          Item = item_pragma(ItemPragma),
          MaybeItem = ok1(Item)
      ;
-        Pieces = [words("Error in"), quote(":- pragma trailing_info"),
+        Pieces = [words("Error in"), pragma_decl("trailing_info"),
              suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -1294,7 +1294,7 @@ parse_pragma_mm_tabling_info(ModuleName, PragmaTerms, ErrorTerm,
          Item = item_pragma(ItemPragma),
          MaybeItem = ok1(Item)
      ;
-        Pieces = [words("Error in"), quote(":- pragma mm_tabling_info"),
+        Pieces = [words("Error in"), pragma_decl("mm_tabling_info"),
              suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -1350,7 +1350,7 @@ parse_pragma_require_feature_set(PragmaTerms, VarSet, ErrorTerm, Context,
          )
      ;
          Pieces = [words("Syntax error in"),
-            quote(":- pragma require_feature_set"), words("declaration."), nl],
+            pragma_decl("require_feature_set"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1586,7 +1586,7 @@ parse_foreign_type_assertion(Term, Assertion) :-
  parse_pragma_foreign_decl_pragma(_ModuleName, PragmaName, PragmaTerms,
          ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
      InvalidDeclPieces = [words("Error: invalid"),
-        quote(":- pragma " ++ PragmaName), words("declaration:")],
+        pragma_decl(PragmaName), words("declaration:")],
      (
          (
              PragmaTerms = [LangTerm, HeaderTerm],
@@ -1623,7 +1623,7 @@ parse_pragma_foreign_decl_pragma(_ModuleName, PragmaName, PragmaTerms,
          )
      ;
          TermStr = describe_error_term(VarSet, ErrorTerm),
-        Pieces = [words("Error: invalid"), quote(":- pragma " ++ PragmaName),
+        Pieces = [words("Error: invalid"), pragma_decl(PragmaName),
              words("declaration:"), words(TermStr), suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -1641,7 +1641,7 @@ parse_pragma_foreign_decl_pragma(_ModuleName, PragmaName, PragmaTerms,
  parse_pragma_foreign_code_pragma(_ModuleName, PragmaName, PragmaTerms,
          ErrorTerm, _VarSet, Context, SeqNum, MaybeItem) :-
      InvalidDeclPrefix = [words("Error: invalid"),
-        quote(":- pragma " ++ PragmaName), words("declaration:")],
+        pragma_decl(PragmaName), words("declaration:")],
      ( PragmaTerms = [LangTerm, CodeTerm] ->
          ( parse_foreign_language(LangTerm, ForeignLanguagePrime) ->
              ForeignLanguage = ForeignLanguagePrime,
@@ -1696,7 +1696,7 @@ parse_pragma_foreign_code_pragma(_ModuleName, PragmaName, PragmaTerms,
  parse_pragma_foreign_proc_pragma(ModuleName, PragmaName, PragmaTerms,
          ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
      InvalidDeclPrefix = [words("Error: invalid"),
-        quote(":- pragma " ++ PragmaName), words("declaration:")],
+        pragma_decl(PragmaName), words("declaration:")],
      (
          PragmaTerms = [LangTerm | RestTerms],
          ( parse_foreign_language(LangTerm, ForeignLanguagePrime) ->
@@ -1837,7 +1837,7 @@ parse_name_arity_pragma(ModuleName, PragmaName, NameKind, MakePragma,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma " ++ PragmaName), words("declaration."), nl],
+            pragma_decl(PragmaName), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -1862,7 +1862,7 @@ parse_simple_name_and_arity(ModuleName, PragmaName, NameKind,
      ;
          NameAndArityTermStr = describe_error_term(VarSet, NameAndArityTerm),
          Pieces = [words("Error: expected"), words(NameKind),
-            words("name/arity for"), quote(":- pragma " ++ PragmaName),
+            words("name/arity for"), pragma_decl(PragmaName),
              words("declaration, not"), quote(NameAndArityTermStr),
              suffix("."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
@@ -2291,7 +2291,7 @@ parse_ordinary_despite_detism(

  parse_pragma_foreign_proc(ModuleName, Flags, PredAndVarsTerm0,
          PragmaImpl, VarSet, Context, SeqNum, MaybeItem) :-
-    ContextPieces = [words("In"), quote(":- pragma foreign_proc"),
+    ContextPieces = [words("In"), pragma_decl("foreign_proc"),
          words("declaration:")],
      parse_pred_or_func_and_args_general(yes(ModuleName), PredAndVarsTerm0,
          VarSet, ContextPieces, MaybePredAndArgs),
@@ -2403,7 +2403,7 @@ parse_oisu_pragma(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
              TypeCtorTermStr = describe_error_term(VarSet, TypeCtorTerm),
              Pieces = [words("Error: expected"),
                  words("predicate name/arity for first argument of"),
-                quote(":- pragma oisu"), words("declaration, not"),
+                pragma_decl("oisu"), words("declaration, not"),
                  quote(TypeCtorTermStr), suffix("."), nl],
              TypeCtorSpec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
@@ -2442,7 +2442,7 @@ parse_oisu_pragma(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma oisu"), words("declaration."), nl],
+            pragma_decl("oisu"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -2462,7 +2462,7 @@ parse_oisu_preds_term(ModuleName, VarSet, ArgNum, ExpectedFunctor, Term,
              Arg, MaybeNamesArities)
      ;
          Pieces = [words("Error:"), words(ArgNum), words("argument of"),
-            quote(":- pragma oisu"), words("declaration"),
+            pragma_decl("oisu"), words("declaration"),
              words("should have the form"),
              quote(ExpectedFunctor ++ "([pred1/arity1, ..., predn/arityn])"),
              suffix("."), nl],
@@ -2544,7 +2544,7 @@ parse_tabling_pragma(ModuleName, PragmaName, EvalMethod, PragmaTerms,
              MaybeAttrs = yes(AttrListTerm0)
          )
      ->
-        ContextPieces = [words("In"), quote(":- pragma " ++ PragmaName),
+        ContextPieces = [words("In"), pragma_decl(PragmaName),
              words("declaration:")],
          parse_arity_or_modes(ModuleName, PredAndModesTerm0, ErrorTerm,
              VarSet, ContextPieces, MaybeArityOrModes),
@@ -2599,7 +2599,7 @@ parse_tabling_pragma(ModuleName, PragmaName, EvalMethod, PragmaTerms,
          )
      ;
          Pieces = [words("Error: wrong number of arguments in"),
-            quote(":- pragma " ++ PragmaName), words("declaration."), nl],
+            pragma_decl(PragmaName), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeItem = error1([Spec])
@@ -2626,7 +2626,7 @@ update_tabling_attributes([Context - SingleAttr | TermSingleAttrs],
                  MaybeAttributes)
          ;
              Pieces = [words("Error: duplicate argument tabling methods"),
-                words("attribute in"), quote(":- pragma memo"),
+                words("attribute in"), pragma_decl("memo"),
                  words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(Context, [always(Pieces)])]),
@@ -2640,7 +2640,7 @@ update_tabling_attributes([Context - SingleAttr | TermSingleAttrs],
                  MaybeAttributes)
          ;
              Pieces = [words("Error: duplicate size limits attribute in"),
-                quote(":- pragma memo"), words("declaration."), nl],
+                pragma_decl("memo"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(Context, [always(Pieces)])]),
              MaybeAttributes = error1([Spec])
@@ -2655,7 +2655,7 @@ update_tabling_attributes([Context - SingleAttr | TermSingleAttrs],
                  MaybeAttributes)
          ;
              Pieces = [words("Error: duplicate statistics attribute in"),
-                quote(":- pragma memo"), words("declaration."), nl],
+                pragma_decl("memo"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(Context, [always(Pieces)])]),
              MaybeAttributes = error1([Spec])
@@ -2668,7 +2668,7 @@ update_tabling_attributes([Context - SingleAttr | TermSingleAttrs],
                  MaybeAttributes)
          ;
              Pieces = [words("Error: duplicate allow_reset attribute in"),
-                quote(":- pragma memo"), words("declaration."), nl],
+                pragma_decl("memo"), words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(Context, [always(Pieces)])]),
              MaybeAttributes = error1([Spec])
diff --git a/compiler/prog_io_sym_name.m b/compiler/prog_io_sym_name.m
index b38ca4c..15154b0 100644
--- a/compiler/prog_io_sym_name.m
+++ b/compiler/prog_io_sym_name.m
@@ -237,7 +237,7 @@ parse_implicitly_qualified_sym_name_and_args(DefaultModuleName, Term,
              \+ match_sym_name(ModuleName, DefaultModuleName)
          ->
              Pieces = [words("Error: module qualifier in definition"),
-                words("does not match preceding"), quote(":- module"),
+                words("does not match preceding"), decl("module"),
                  words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(Term), [always(Pieces)])]),
@@ -365,7 +365,7 @@ parse_implicitly_qualified_symbol_name(DefaultModuleName, VarSet, Term,
              \+ match_sym_name(ModuleName, DefaultModuleName)
          ->
              Pieces = [words("Error: module qualifier in definition"),
-                words("does not match preceding"), quote(":- module"),
+                words("does not match preceding"), decl("module"),
                  words("declaration."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(get_term_context(Term), [always(Pieces)])]),
diff --git a/compiler/term_constr_errors.m b/compiler/term_constr_errors.m
index 953d74d..c763a06 100644
--- a/compiler/term_constr_errors.m
+++ b/compiler/term_constr_errors.m
@@ -250,7 +250,7 @@ description(horder_call, _, _, Pieces, no) :-
      Pieces = [words("It contains a higher-order call.")].

  description(does_not_term_pragma(PredId), Single, Module, Pieces, no) :-
-    Pieces1 = [words("There is a"), quote(":- pragma does_not_terminate"),
+    Pieces1 = [words("There is a"), pragma_decl("does_not_terminate"),
          words("declaration for")],
      (
          Single = yes(PPId),
diff --git a/compiler/term_errors.m b/compiler/term_errors.m
index 24bd4e9..6877c50 100644
--- a/compiler/term_errors.m
+++ b/compiler/term_errors.m
@@ -348,7 +348,7 @@ description(pragma_foreign_code, _, _, Pieces, no) :-
      Pieces = [
          words("It depends on the properties of"),
          words("foreign language code included via a"),
-        quote(":- pragma foreign_proc"),
+        pragma_decl("foreign_proc"),
          words("declaration.")
      ].

@@ -533,7 +533,7 @@ description(is_builtin(_PredId), _Single, _, Pieces, no) :-
  description(does_not_term_pragma(PredId), Single, Module,
          Pieces, no) :-
      Pieces1 = [
-        words("There is a"), quote(":- pragma does_not_terminate"),
+        words("There is a"), pragma_decl("does_not_terminate"),
          words("declaration for")],
      (
          Single = yes(PPId),
diff --git a/compiler/termination.m b/compiler/termination.m
index de45648..c495be2 100644
--- a/compiler/termination.m
+++ b/compiler/termination.m
@@ -192,7 +192,7 @@ check_foreign_code_attributes_2([PPId], !ModuleInfo, !Specs) :-
                          should_module_qualify, PPId),
                      Pieces =
                          [words("Warning:") | ProcNamePieces] ++
-                        [words("has a"), quote("pragma terminates"),
+                        [words("has a"), pragma_decl("terminates"),
                          words("declaration but also has the"),
                          quote("does_not_terminate"),
                          words("foreign code attribute set.")],
@@ -220,7 +220,7 @@ check_foreign_code_attributes_2([PPId], !ModuleInfo, !Specs) :-
                          should_module_qualify, PPId),
                      Pieces =
                          [words("Warning:") | ProcNamePieces] ++
-                        [words("has a"), quote("pragma does_not_terminate"),
+                        [words("has a"), pragma_decl("does_not_terminate"),
                          words("declaration but also has the"),
                          quote("terminates"),
                          words("foreign code attribute set.")],
diff --git a/compiler/typecheck_errors.m b/compiler/typecheck_errors.m
index 87a6469..f5fe3d3 100644
--- a/compiler/typecheck_errors.m
+++ b/compiler/typecheck_errors.m
@@ -1233,8 +1233,8 @@ syntax_functor_components("-->", 2, Components) :-
      Components = [always(Pieces)].
  syntax_functor_components(".", 2, Components) :-
      Pieces = [words("error: the list constructor is now"),
-        % XXX should the arity be unquoted in the following?
-        quote("[|]/2"), suffix(","), words("not"), quote("./2"),
+        sym_name_and_arity(unqualified("[|]") / 2),
+        suffix(","), words("not"), quote("./2"),
          suffix("."), nl],
      Components = [always(Pieces)].
  syntax_functor_components("!", 1, Components) :-
@@ -1261,7 +1261,7 @@ report_cons_error(Context, ConsError) = Msgs :-
          ConsError = foreign_type_constructor(TypeCtor, _),
          TypeCtor = type_ctor(TypeName, TypeArity),
          Pieces = [words("There are"),
-            quote(":- pragma foreign_type"),
+            pragma_decl("foreign_type"),
              words("declarations for type"),
              sym_name_and_arity(TypeName / TypeArity),
              suffix(","),
diff --git a/tests/invalid/bad_finalise_decl.err_exp b/tests/invalid/bad_finalise_decl.err_exp
index e688126..a4baa2b 100644
--- a/tests/invalid/bad_finalise_decl.err_exp
+++ b/tests/invalid/bad_finalise_decl.err_exp
@@ -5,7 +5,7 @@ bad_finalise_decl.m:023: Error: `i1'/2 used in finalise declaration has invalid
  bad_finalise_decl.m:023:   signature.
  bad_finalise_decl.m:024: Error: `i3'/2 used in finalise declaration does not
  bad_finalise_decl.m:024:   have a corresponding pred declaration.
-bad_finalise_decl.m:025: Error: `finalise' declaration requires arity, found
+bad_finalise_decl.m:025: Error: `:- finalise' declaration requires arity, found
  bad_finalise_decl.m:025:   i4.
-bad_finalise_decl.m:026: Error: `finalise' declaration specifies a predicate
+bad_finalise_decl.m:026: Error: `:- finalise' declaration specifies a predicate
  bad_finalise_decl.m:026:   whose arity is not zero or two: (i5 / 6).
diff --git a/tests/invalid/bad_initialise_decl.err_exp b/tests/invalid/bad_initialise_decl.err_exp
index 1b2cf77..20b5296 100644
--- a/tests/invalid/bad_initialise_decl.err_exp
+++ b/tests/invalid/bad_initialise_decl.err_exp
@@ -5,8 +5,8 @@ bad_initialise_decl.m:026: Error: `i1'/2 used in initialise declaration has
  bad_initialise_decl.m:026:   invalid signature.
  bad_initialise_decl.m:027: Error: `i3'/2 used in initialise declaration does
  bad_initialise_decl.m:027:   not have a corresponding pred declaration.
-bad_initialise_decl.m:028: Error: `initialise' declaration requires arity,
+bad_initialise_decl.m:028: Error: `:- initialise' declaration requires arity,
  bad_initialise_decl.m:028:   found i4.
-bad_initialise_decl.m:029: Error: `initialise' declaration specifies a
-bad_initialise_decl.m:029:   predicate whose arity is not zero or two: (i5 /
-bad_initialise_decl.m:029:   6).
+bad_initialise_decl.m:029: Error: `:- initialise' declaration specifies a
+bad_initialise_decl.m:029:   predicate whose arity is not zero or two:
+bad_initialise_decl.m:029:   (i5 / 6).
diff --git a/tests/invalid/bad_mutable.err_exp b/tests/invalid/bad_mutable.err_exp
index 2c4618c..394157d 100644
--- a/tests/invalid/bad_mutable.err_exp
+++ b/tests/invalid/bad_mutable.err_exp
@@ -5,9 +5,9 @@ bad_mutable.m:013: Error: the inst `special_ground' is not a valid inst for a
  bad_mutable.m:013:   mutable declaration.
  bad_mutable.m:013: In declaration for mutable `not_an_inst':
  bad_mutable.m:013:   error: undefined inst `special_ground'/0.
-bad_mutable.m:015: Error: malformed attribute list in mutable declaration:
+bad_mutable.m:015: Error: malformed attribute list in `:- mutable' declaration:
  bad_mutable.m:015:   [untrailed, bad_attrib].
-bad_mutable.m:017: Error: the type in a mutable declaration cannot contain
+bad_mutable.m:017: Error: the type in a `:- mutable' declaration cannot contain
  bad_mutable.m:017:   variables: list(T).
  bad_mutable.m:019: Error: conflicting attributes in attribute list:
  bad_mutable.m:019:   [untrailed, trailed].
diff --git a/tests/invalid/bug83.err_exp b/tests/invalid/bug83.err_exp
index 04df85c..275be76 100644
--- a/tests/invalid/bug83.err_exp
+++ b/tests/invalid/bug83.err_exp
@@ -1,4 +1,4 @@
-bug83.m:022: error: ambiguous function name in `pragma foreign_export'
+bug83.m:022: Error: ambiguous function name in `:- pragma foreign_export'
  bug83.m:022:   declaration.
  bug83.m:022:   The possible matches are:
  bug83.m:022:     function `io.make_io_error'/1,
diff --git a/tests/invalid/ee_invalid.err_exp b/tests/invalid/ee_invalid.err_exp
index 78ef478..a33158a 100644
--- a/tests/invalid/ee_invalid.err_exp
+++ b/tests/invalid/ee_invalid.err_exp
@@ -1,44 +1,44 @@
-ee_invalid.m:033: In `pragma foreign_export_enum' declaration for `int'/0:
+ee_invalid.m:033: In `:- pragma foreign_export_enum' declaration for `int'/0:
  ee_invalid.m:033:   error: `int'/0 is an atomic type.
  ee_invalid.m:037: In pragma foreign_export_enum:
  ee_invalid.m:037:   error: undefined type `undefined_type'/0.
-ee_invalid.m:041: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:041: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:041:   `ee_invalid.foo'/1:
  ee_invalid.m:041:   error: `ee_invalid.foo'/1 is not an enumeration type. It
  ee_invalid.m:041:   has one or more non-zero arity constructors.
-ee_invalid.m:045: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:045: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:045:   `ee_invalid.bar'/0:
  ee_invalid.m:045:   error: `ee_invalid.bar'/0 is not an enumeration type.
-ee_invalid.m:052: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:052: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:052:   `ee_invalid.baz'/0:
  ee_invalid.m:052:   error: `ee_invalid.baz'/0 is not an enumeration type.
-ee_invalid.m:057: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:057: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:057:   `ee_invalid.alphabet'/0:
  ee_invalid.m:057:   user-specified foreign names for constructors that do not
  ee_invalid.m:057:   match match any of the constructors of
  ee_invalid.m:057:   `ee_invalid.alphabet'/0.
  ee_invalid.m:057:   The following constructor does not match:
  ee_invalid.m:057:       `deg'
-ee_invalid.m:061: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:061: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:061:   `ee_invalid.alphabet'/0:
  ee_invalid.m:061:   user-specified foreign names for constructors that do not
  ee_invalid.m:061:   match match any of the constructors of
  ee_invalid.m:061:   `ee_invalid.alphabet'/0.
  ee_invalid.m:061:   The following constructor does not match:
  ee_invalid.m:061:       `foo.def'
-ee_invalid.m:066: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:066: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:066:   `ee_invalid.alphabet'/0:
  ee_invalid.m:066:   error: the user-specified mapping between Mercury and
  ee_invalid.m:066:   foreign names does not form a bijection.
-ee_invalid.m:067: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:067: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:067:   `ee_invalid.alphabet'/0:
  ee_invalid.m:067:   error: the mapping between Mercury and foreign names does
  ee_invalid.m:067:   not form a bijection.
-ee_invalid.m:068: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:068: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:068:   `ee_invalid.alphabet'/0:
  ee_invalid.m:068:   error: the user-specified mapping between Mercury and
  ee_invalid.m:068:   foreign names does not form a bijection.
-ee_invalid.m:073: In `pragma foreign_export_enum' declaration for
+ee_invalid.m:073: In `:- pragma foreign_export_enum' declaration for
  ee_invalid.m:073:   `ee_invalid.strange_names'/0:
  ee_invalid.m:073:   error: not all the constructors of the type
  ee_invalid.m:073:   `ee_invalid.strange_names'/0 can be converted into valid C
diff --git a/tests/invalid/foreign_enum_import.err_exp b/tests/invalid/foreign_enum_import.err_exp
index 394da1c..0933cea 100644
--- a/tests/invalid/foreign_enum_import.err_exp
+++ b/tests/invalid/foreign_enum_import.err_exp
@@ -1,4 +1,4 @@
-foreign_enum_import.m:010: In `pragma foreign_enum' declaration for
+foreign_enum_import.m:010: In `:- pragma foreign_enum' declaration for
  foreign_enum_import.m:010:   `bool.bool'/0:
  foreign_enum_import.m:010:   error: `bool.bool'/0 is not defined in this
  foreign_enum_import.m:010:   module.
diff --git a/tests/invalid/foreign_enum_invalid.err_exp b/tests/invalid/foreign_enum_invalid.err_exp
index 674c2ba..5929b71 100644
--- a/tests/invalid/foreign_enum_invalid.err_exp
+++ b/tests/invalid/foreign_enum_invalid.err_exp
@@ -1,13 +1,13 @@
-foreign_enum_invalid.m:020: Error: `pragma foreign_enum' declaration for
+foreign_enum_invalid.m:020: Error: `:- pragma foreign_enum' declaration for
  foreign_enum_invalid.m:020:   `foreign_enum_invalid.in_int'/0 in module
  foreign_enum_invalid.m:020:   interface.
-foreign_enum_invalid.m:026: In `pragma foreign_enum' declaration for
+foreign_enum_invalid.m:026: In `:- pragma foreign_enum' declaration for
  foreign_enum_invalid.m:026:   `foreign_enum_invalid.incomplete'/0:
  foreign_enum_invalid.m:026:   error: not all constructors have a foreign value.
  foreign_enum_invalid.m:026:   The following constructor does not have a foreign
  foreign_enum_invalid.m:026:   value
  foreign_enum_invalid.m:026:       `foreign_enum_invalid.baz'
-foreign_enum_invalid.m:031: In `pragma foreign_enum' declaration for
+foreign_enum_invalid.m:031: In `:- pragma foreign_enum' declaration for
  foreign_enum_invalid.m:031:   `foreign_enum_invalid.incomplete2'/0:
  foreign_enum_invalid.m:031:   error: not all constructors have a foreign value.
  foreign_enum_invalid.m:031:   The following constructors do not have foreign
@@ -15,12 +15,12 @@ foreign_enum_invalid.m:031:   values
  foreign_enum_invalid.m:031:       `foreign_enum_invalid.bar2',
  foreign_enum_invalid.m:031:       `foreign_enum_invalid.baz2',
  foreign_enum_invalid.m:031:       `foreign_enum_invalid.foo2'
-foreign_enum_invalid.m:033: In `pragma foreign_enum' declaration for
+foreign_enum_invalid.m:033: In `:- pragma foreign_enum' declaration for
  foreign_enum_invalid.m:033:   `foreign_enum_invalid.not_a_bijection'/0:
  foreign_enum_invalid.m:033:   error: the mapping between Mercury enumeration
  foreign_enum_invalid.m:033:   values and foreign values does not form a
  foreign_enum_invalid.m:033:   bijection.
-foreign_enum_invalid.m:041: In `pragma foreign_enum' declaration for
+foreign_enum_invalid.m:041: In `:- pragma foreign_enum' declaration for
  foreign_enum_invalid.m:041:   `foreign_enum_invalid.dup_foreign_enum'/0:
  foreign_enum_invalid.m:041:   error: `foreign_enum_invalid.dup_foreign_enum'/0
  foreign_enum_invalid.m:041:   has multiple foreign_enum pragmas.
diff --git a/tests/invalid/foreign_type_missing.err_exp b/tests/invalid/foreign_type_missing.err_exp
index 4868f0e..53e88a5 100644
--- a/tests/invalid/foreign_type_missing.err_exp
+++ b/tests/invalid/foreign_type_missing.err_exp
@@ -1,2 +1,2 @@
-foreign_type_missing.m:010: Error: no IL `pragma foreign_type' declaration for
-foreign_type_missing.m:010:   `foreign_type_missing.foreign'/0
+foreign_type_missing.m:010: Error: no IL `:- pragma foreign_type' declaration
+foreign_type_missing.m:010:   for `foreign_type_missing.foreign'/0
diff --git a/tests/invalid/hawkins_mm_fail_reset.err_exp b/tests/invalid/hawkins_mm_fail_reset.err_exp
index d1b94a5..b8f59ef 100644
--- a/tests/invalid/hawkins_mm_fail_reset.err_exp
+++ b/tests/invalid/hawkins_mm_fail_reset.err_exp
@@ -2,14 +2,14 @@ hawkins_mm_fail_reset.m:020: In `entry'(out):
  hawkins_mm_fail_reset.m:020:   warning: determinism declaration could be
  hawkins_mm_fail_reset.m:020:   tighter.
  hawkins_mm_fail_reset.m:020:   Declared `nondet', inferred `failure'.
-hawkins_mm_fail_reset.m:027: Error: `pragma minimal_model' declaration not
+hawkins_mm_fail_reset.m:027: Error: `:- pragma minimal_model' declaration not
  hawkins_mm_fail_reset.m:027:   allowed for procedure with determinism
  hawkins_mm_fail_reset.m:027:   `failure'.
  hawkins_mm_fail_reset.m:030: Warning: this disjunct will never have any
  hawkins_mm_fail_reset.m:030:   solutions.
  hawkins_mm_fail_reset.m:033: Warning: this disjunct will never have any
  hawkins_mm_fail_reset.m:033:   solutions.
-hawkins_mm_fail_reset.m:036: Error: `pragma minimal_model' declaration not
+hawkins_mm_fail_reset.m:036: Error: `:- pragma minimal_model' declaration not
  hawkins_mm_fail_reset.m:036:   allowed for procedure with determinism
  hawkins_mm_fail_reset.m:036:   `failure'.
  For more information, recompile with `-E'.
diff --git a/tests/invalid/loopcheck.err_exp b/tests/invalid/loopcheck.err_exp
index 2a0dede..5672359 100644
--- a/tests/invalid/loopcheck.err_exp
+++ b/tests/invalid/loopcheck.err_exp
@@ -1,7 +1,7 @@
  loopcheck.m:009: In `main'(di, uo):
  loopcheck.m:009:   warning: determinism declaration could be tighter.
  loopcheck.m:009:   Declared `det', inferred `erroneous'.
-loopcheck.m:016: Error: `pragma loop_check' declaration not allowed for
+loopcheck.m:016: Error: `:- pragma loop_check' declaration not allowed for
  loopcheck.m:016:   procedure with determinism `erroneous'.
  loopcheck.m:016:   The pragma requested is only valid for the following
  loopcheck.m:016:   determinisms: cc_multi, cc_nondet, det, multi, nondet and
diff --git a/tests/invalid/nested_impl_in_int.err_exp b/tests/invalid/nested_impl_in_int.err_exp
index ae1bed4..25830c6 100644
--- a/tests/invalid/nested_impl_in_int.err_exp
+++ b/tests/invalid/nested_impl_in_int.err_exp
@@ -1,10 +1,10 @@
  nested_impl_in_int.m:020: In interface for module `nested_impl_in_int':
  nested_impl_in_int.m:020:   in definition of sub-module `child':
-nested_impl_in_int.m:020:   error: `:- implementation.' declaration for
+nested_impl_in_int.m:020:   error: `:- implementation' declaration for
  nested_impl_in_int.m:020:   sub-module occurs in interface section of parent
  nested_impl_in_int.m:020:   module.
  nested_impl_in_int.m:037: In interface for module `nested_impl_in_int':
  nested_impl_in_int.m:037:   in definition of sub-module `child2':
-nested_impl_in_int.m:037:   error: `:- implementation.' declaration for
+nested_impl_in_int.m:037:   error: `:- implementation' declaration for
  nested_impl_in_int.m:037:   sub-module occurs in interface section of parent
  nested_impl_in_int.m:037:   module.
diff --git a/tests/invalid/oisu_check_add_pragma_errors.err_exp b/tests/invalid/oisu_check_add_pragma_errors.err_exp
index e5a9529..c381a76 100644
--- a/tests/invalid/oisu_check_add_pragma_errors.err_exp
+++ b/tests/invalid/oisu_check_add_pragma_errors.err_exp
@@ -1,4 +1,4 @@
-oisu_check_add_pragma_errors.m:014: Duplicate `pragma oisu' declaration for
+oisu_check_add_pragma_errors.m:014: Duplicate `:- pragma oisu' declarations for
  oisu_check_add_pragma_errors.m:014:   `oisu_check_add_pragma_errors.foo'/0.
  oisu_check_add_pragma_errors.m:020: In pragma oisu:
  oisu_check_add_pragma_errors.m:020:   error: undefined type
diff --git a/tests/invalid/oisu_check_semantic_errors.err_exp b/tests/invalid/oisu_check_semantic_errors.err_exp
index e0d590b..dd37498 100644
--- a/tests/invalid/oisu_check_semantic_errors.err_exp
+++ b/tests/invalid/oisu_check_semantic_errors.err_exp
@@ -31,7 +31,7 @@ oisu_check_semantic_errors.m:034: The second argument of predicate
  oisu_check_semantic_errors.m:034:   `destroy_foo3'/4 handles a previous handled
  oisu_check_semantic_errors.m:034:   OISU type.
  oisu_check_semantic_errors.m:035: predicate `destroy_foo4'/3 is mentioned in a
-oisu_check_semantic_errors.m:035:   `pragma oisu' declaration, so it should
+oisu_check_semantic_errors.m:035:   `:- pragma oisu' declaration, so it should
  oisu_check_semantic_errors.m:035:   have exactly one procedure.
  oisu_check_semantic_errors.m:039: predicate `create_bar1'/2 is declared to
  oisu_check_semantic_errors.m:039:   handle the following OISU types, but it
diff --git a/tests/invalid/reserve_tag.err_exp b/tests/invalid/reserve_tag.err_exp
index 4033977..5b4f32d 100644
--- a/tests/invalid/reserve_tag.err_exp
+++ b/tests/invalid/reserve_tag.err_exp
@@ -1,18 +1,19 @@
-reserve_tag.m:021: In `pragma reserve_tag' declaration for
+reserve_tag.m:021: In `:- pragma reserve_tag' declaration for
  reserve_tag.m:021:   `reserve_tag.undefined_type'/1:
  reserve_tag.m:021:   error: undefined type `reserve_tag.undefined_type'/1.
  reserve_tag.m:023: Error: expected type name/arity for `:- pragma reserve_tag'
  reserve_tag.m:023:   declaration, not `(list__list / 1)'.
-reserve_tag.m:024: In `pragma reserve_tag' declaration for
+reserve_tag.m:024: In `:- pragma reserve_tag' declaration for
  reserve_tag.m:024:   `reserve_tag.list'/1:
  reserve_tag.m:024:   error: undefined type `reserve_tag.list'/1.
-reserve_tag.m:025: In `pragma reserve_tag' declaration for
+reserve_tag.m:025: In `:- pragma reserve_tag' declaration for
  reserve_tag.m:025:   `reserve_tag.exported_type'/0:
-reserve_tag.m:025:   error: `pragma reserve_tag' declaration must have the same
-reserve_tag.m:025:   visibility as the type definition.
-reserve_tag.m:032: In `pragma reserve_tag' declaration for
+reserve_tag.m:025:   error: `:- pragma reserve_tag' declaration must have the
+reserve_tag.m:025:   same visibility as the type definition.
+reserve_tag.m:032: In `:- pragma reserve_tag' declaration for
  reserve_tag.m:032:   `reserve_tag.invalid_arity'/1:
  reserve_tag.m:032:   error: undefined type `reserve_tag.invalid_arity'/1.
-reserve_tag.m:044: In `pragma reserve_tag' declaration for `reserve_tag.foo'/0:
-reserve_tag.m:044:   warning: multiple `pragma reserved_tag' declarations for
-reserve_tag.m:044:   the same type.
+reserve_tag.m:044: In `:- pragma reserve_tag' declaration for
+reserve_tag.m:044:   `reserve_tag.foo'/0:
+reserve_tag.m:044:   warning: multiple `:- pragma reserved_tag' declarations
+reserve_tag.m:044:   for the same type.
diff --git a/tests/invalid/try_io_else.err_exp b/tests/invalid/try_io_else.err_exp
index 2391b0c..97bff96 100644
--- a/tests/invalid/try_io_else.err_exp
+++ b/tests/invalid/try_io_else.err_exp
@@ -1,2 +1,2 @@
  try_io_else.m:024: Error: a `try' goal with an `io' parameter cannot have an
-try_io_else.m:024:   else part.
+try_io_else.m:024:   `else' part.
diff --git a/tests/warnings/foreign_term_invalid.exp b/tests/warnings/foreign_term_invalid.exp
index 8a36cb2..5c1cae3 100644
--- a/tests/warnings/foreign_term_invalid.exp
+++ b/tests/warnings/foreign_term_invalid.exp
@@ -1,8 +1,8 @@
  foreign_term_invalid.m:009: Warning: predicate `foreign_term_invalid.test1'/1
-foreign_term_invalid.m:009:   mode 0 has a `pragma does_not_terminate'
+foreign_term_invalid.m:009:   mode 0 has a `:- pragma does_not_terminate'
  foreign_term_invalid.m:009:   declaration but also has the `terminates' foreign
  foreign_term_invalid.m:009:   code attribute set.
  foreign_term_invalid.m:010: Warning: predicate `foreign_term_invalid.test2'/1
-foreign_term_invalid.m:010:   mode 0 has a `pragma terminates' declaration but
-foreign_term_invalid.m:010:   also has the `does_not_terminate' foreign code
-foreign_term_invalid.m:010:   attribute set.
+foreign_term_invalid.m:010:   mode 0 has a `:- pragma terminates' declaration
+foreign_term_invalid.m:010:   but also has the `does_not_terminate' foreign
+foreign_term_invalid.m:010:   code attribute set.
diff --git a/tests/warnings/warn_return.exp b/tests/warnings/warn_return.exp
index 36a2638..de9e0b4 100644
--- a/tests/warnings/warn_return.exp
+++ b/tests/warnings/warn_return.exp
@@ -1,2 +1,2 @@
-warn_return.m:012: warning: the C code for predicate `warn_return.foo'/2 may
+warn_return.m:012: Warning: the C code for predicate `warn_return.foo'/2 may
  warn_return.m:012:   contain a `return' statement.
diff --git a/tests/warnings/warn_return.exp2 b/tests/warnings/warn_return.exp2
index 9fd4489..4691988 100644
--- a/tests/warnings/warn_return.exp2
+++ b/tests/warnings/warn_return.exp2
@@ -1,2 +1,2 @@
-warn_return.m:028: warning: the Java code for predicate `warn_return.foo'/2 may
+warn_return.m:028: Warning: the Java code for predicate `warn_return.foo'/2 may
  warn_return.m:028:   contain a `return' statement.
diff --git a/tests/warnings/warn_return.exp3 b/tests/warnings/warn_return.exp3
index 7d7de20..cc09cf4 100644
--- a/tests/warnings/warn_return.exp3
+++ b/tests/warnings/warn_return.exp3
@@ -1,2 +1,2 @@
-warn_return.m:020: warning: the C# code for predicate `warn_return.foo'/2 may
+warn_return.m:020: Warning: the C# code for predicate `warn_return.foo'/2 may
  warn_return.m:020:   contain a `return' statement.
diff --git a/tests/warnings/warn_succ_ind.exp b/tests/warnings/warn_succ_ind.exp
index 17d765e..0c30a1f 100644
--- a/tests/warnings/warn_succ_ind.exp
+++ b/tests/warnings/warn_succ_ind.exp
@@ -1,10 +1,10 @@
-warn_succ_ind.m:016: warning: the C code for predicate `warn_succ_ind.foo'/2
+warn_succ_ind.m:016: Warning: the C code for predicate `warn_succ_ind.foo'/2
  warn_succ_ind.m:016:   may set `SUCCESS_INDICATOR', but it cannot fail.
-warn_succ_ind.m:048: warning: the C code for predicate `warn_succ_ind.foo2'/2
+warn_succ_ind.m:048: Warning: the C code for predicate `warn_succ_ind.foo2'/2
  warn_succ_ind.m:048:   may set `SUCCESS_INDICATOR', but it cannot fail.
-warn_succ_ind.m:080: warning: the C code for predicate `warn_succ_ind.bar'/2
+warn_succ_ind.m:080: Warning: the C code for predicate `warn_succ_ind.bar'/2
  warn_succ_ind.m:080:   does not appear to set `SUCCESS_INDICATOR', but it can
  warn_succ_ind.m:080:   fail.
-warn_succ_ind.m:108: warning: the C code for predicate `warn_succ_ind.bar2'/2
+warn_succ_ind.m:108: Warning: the C code for predicate `warn_succ_ind.bar2'/2
  warn_succ_ind.m:108:   does not appear to set `SUCCESS_INDICATOR', but it can
  warn_succ_ind.m:108:   fail.
diff --git a/tests/warnings/warn_succ_ind.exp2 b/tests/warnings/warn_succ_ind.exp2
index ec1fdbe..e9f5a02 100644
--- a/tests/warnings/warn_succ_ind.exp2
+++ b/tests/warnings/warn_succ_ind.exp2
@@ -1,10 +1,10 @@
-warn_succ_ind.m:024: warning: the C# code for predicate `warn_succ_ind.foo'/2
+warn_succ_ind.m:024: Warning: the C# code for predicate `warn_succ_ind.foo'/2
  warn_succ_ind.m:024:   may set `SUCCESS_INDICATOR', but it cannot fail.
-warn_succ_ind.m:056: warning: the C# code for predicate `warn_succ_ind.foo2'/2
+warn_succ_ind.m:056: Warning: the C# code for predicate `warn_succ_ind.foo2'/2
  warn_succ_ind.m:056:   may set `SUCCESS_INDICATOR', but it cannot fail.
-warn_succ_ind.m:087: warning: the C# code for predicate `warn_succ_ind.bar'/2
+warn_succ_ind.m:087: Warning: the C# code for predicate `warn_succ_ind.bar'/2
  warn_succ_ind.m:087:   does not appear to set `SUCCESS_INDICATOR', but it can
  warn_succ_ind.m:087:   fail.
-warn_succ_ind.m:115: warning: the C# code for predicate `warn_succ_ind.bar2'/2
+warn_succ_ind.m:115: Warning: the C# code for predicate `warn_succ_ind.bar2'/2
  warn_succ_ind.m:115:   does not appear to set `SUCCESS_INDICATOR', but it can
  warn_succ_ind.m:115:   fail.
diff --git a/tests/warnings/warn_succ_ind.exp3 b/tests/warnings/warn_succ_ind.exp3
index 597fee3..9775c30 100644
--- a/tests/warnings/warn_succ_ind.exp3
+++ b/tests/warnings/warn_succ_ind.exp3
@@ -1,11 +1,11 @@
-warn_succ_ind.m:032: warning: the Java code for predicate `warn_succ_ind.foo'/2
+warn_succ_ind.m:032: Warning: the Java code for predicate `warn_succ_ind.foo'/2
  warn_succ_ind.m:032:   may set `SUCCESS_INDICATOR', but it cannot fail.
-warn_succ_ind.m:064: warning: the Java code for predicate
+warn_succ_ind.m:064: Warning: the Java code for predicate
  warn_succ_ind.m:064:   `warn_succ_ind.foo2'/2 may set `SUCCESS_INDICATOR', but
  warn_succ_ind.m:064:   it cannot fail.
-warn_succ_ind.m:094: warning: the Java code for predicate `warn_succ_ind.bar'/2
+warn_succ_ind.m:094: Warning: the Java code for predicate `warn_succ_ind.bar'/2
  warn_succ_ind.m:094:   does not appear to set `SUCCESS_INDICATOR', but it can
  warn_succ_ind.m:094:   fail.
-warn_succ_ind.m:122: warning: the Java code for predicate
+warn_succ_ind.m:122: Warning: the Java code for predicate
  warn_succ_ind.m:122:   `warn_succ_ind.bar2'/2 does not appear to set
  warn_succ_ind.m:122:   `SUCCESS_INDICATOR', but it can fail.
diff --git a/tests/warnings/warn_succ_ind.exp4 b/tests/warnings/warn_succ_ind.exp4
index 28b351f..0710f27 100644
--- a/tests/warnings/warn_succ_ind.exp4
+++ b/tests/warnings/warn_succ_ind.exp4
@@ -1,12 +1,12 @@
-warn_succ_ind.m:040: warning: the Erlang code for predicate
+warn_succ_ind.m:040: Warning: the Erlang code for predicate
  warn_succ_ind.m:040:   `warn_succ_ind.foo'/2 may set `SUCCESS_INDICATOR', but
  warn_succ_ind.m:040:   it cannot fail.
-warn_succ_ind.m:072: warning: the Erlang code for predicate
+warn_succ_ind.m:072: Warning: the Erlang code for predicate
  warn_succ_ind.m:072:   `warn_succ_ind.foo2'/2 may set `SUCCESS_INDICATOR', but
  warn_succ_ind.m:072:   it cannot fail.
-warn_succ_ind.m:101: warning: the Erlang code for predicate
+warn_succ_ind.m:101: Warning: the Erlang code for predicate
  warn_succ_ind.m:101:   `warn_succ_ind.bar'/2 does not appear to set
  warn_succ_ind.m:101:   `SUCCESS_INDICATOR', but it can fail.
-warn_succ_ind.m:129: warning: the Erlang code for predicate
+warn_succ_ind.m:129: Warning: the Erlang code for predicate
  warn_succ_ind.m:129:   `warn_succ_ind.bar2'/2 does not appear to set
  warn_succ_ind.m:129:   `SUCCESS_INDICATOR', but it can fail.




More information about the reviews mailing list