mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
Add some comments.
Estimated hours taken: 0.5 compiler/prog_io.m: compiler/prog_data.m: Add some comments.
This commit is contained in:
@@ -203,6 +203,11 @@
|
||||
% higher-order pred modes
|
||||
; not_reached
|
||||
; inst_var(var)
|
||||
% A defined_inst is possibly recursive
|
||||
% inst whose value is stored in the
|
||||
% inst_table. This is used both for
|
||||
% user-defined insts and for
|
||||
% compiler-generated insts.
|
||||
; defined_inst(inst_name)
|
||||
% An abstract inst is a defined inst which
|
||||
% has been declared but not actually been
|
||||
@@ -248,6 +253,15 @@
|
||||
|
||||
:- type bound_inst ---> functor(cons_id, list(inst)).
|
||||
|
||||
% An `inst_name' is used as a key for the inst_table.
|
||||
% It is either a user-defined inst `user_inst(Name, Args)',
|
||||
% or some sort of compiler-generated inst, whose name
|
||||
% is a representation of it's meaning. For example
|
||||
% `merge_inst(InstA, InstB)' is the name used for the inst
|
||||
% that results from merging InstA and InstB using `merge_inst'.
|
||||
% Similarly `unify_inst(IsLive, InstA, InstB, IsReal)' is
|
||||
% the name for the inst that results from a call to
|
||||
% `abstractly_unify_inst(IsLive, InstA, InstB, IsReal)', etc.
|
||||
:- type inst_name ---> user_inst(sym_name, list(inst))
|
||||
; merge_inst(inst, inst)
|
||||
; unify_inst(is_live, inst, inst, unify_is_real)
|
||||
|
||||
@@ -162,11 +162,17 @@
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
% When actually reading in type declarations, we need to
|
||||
% check for errors.
|
||||
% When parsing declarations, we need to check for errors.
|
||||
% Most of the parsing predicates return a `maybe1(T)'
|
||||
% or a `maybe2(T1, T2)', which will either be the
|
||||
% `ok(ParseTree)' (or `ok(ParseTree1, ParseTree2)'),
|
||||
% if the parse is successful, or `error(Message, Term)'
|
||||
% if it is not. The `Term' there should be the term which
|
||||
% is syntactically incorrect.
|
||||
|
||||
:- type maybe1(T) ---> error(string, term)
|
||||
; ok(T).
|
||||
|
||||
:- type maybe_item_and_context
|
||||
== maybe2(item, term__context).
|
||||
|
||||
@@ -2193,8 +2199,8 @@ process_func_mode(error(M, T), _, _, _, _, _, error(M, T)).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
% parse a `:- inst foo = ...' definition
|
||||
|
||||
% Parse a `:- inst <InstDefn>.' declaration.
|
||||
%
|
||||
:- pred parse_inst_decl(string, varset, term, maybe1(item)).
|
||||
:- mode parse_inst_decl(in, in, in, out) is det.
|
||||
parse_inst_decl(ModuleName, VarSet, InstDefn, Result) :-
|
||||
@@ -2230,6 +2236,8 @@ parse_inst_decl(ModuleName, VarSet, InstDefn, Result) :-
|
||||
% (don't bother at the moment, since we ignore
|
||||
% conditions anyhow :-)
|
||||
|
||||
% Parse a `:- inst <Head> ---> <Body>.' definition.
|
||||
%
|
||||
:- pred convert_inst_defn(string, term, term, maybe1(inst_defn)).
|
||||
:- mode convert_inst_defn(in, in, in, out) is det.
|
||||
convert_inst_defn(ModuleName, Head, Body, Result) :-
|
||||
@@ -2330,6 +2338,9 @@ convert_inst_list([H0|T0], [H|T]) :-
|
||||
convert_inst(H0, H),
|
||||
convert_inst_list(T0, T).
|
||||
|
||||
% Parse an inst.
|
||||
% Fails on syntax errors.
|
||||
%
|
||||
:- pred convert_inst(term, inst).
|
||||
:- mode convert_inst(in, out) is semidet.
|
||||
convert_inst(term__variable(V), inst_var(V)).
|
||||
|
||||
Reference in New Issue
Block a user