Thursday, February 2, 2006

[Patch] Implemented op/3 declaration for Mercury compiler

From:doug.dot.auclair.at.logicaltypes.dot.com
To: mercury.dash.developers.at.cs.dot.mu.dot.oz.dot.au
Subject: [Patch] Implemented op/3 declaration for Mercury compiler
Date:Thu, 12 Jan 2006 12:52:28 -0500

Dear all,

This mail was originally sent from my hotmail.com account; apparently
your mail server rejects emails from this server, so I am resending
this message from my logicaltypes.com server.

Sincerely,
Doug Auclair

> Date: Sun, 08 Jan 2006 20:23:21 +0000
>
> Dear all,
>
> I've implemented the op/3 that has LOCAL (within the current module
> only) extent for the Mercury compiler, 0.12.1. [I consider the
> global effect of op/3 in Prolog a disadvantage. As I use op/3
> frequently, I do not wish syntax for one purpose in one module to
> spill over into syntax used for another purpose in another module]
> I've changed the following files to make this change. I've run the
> old compiler and the new compiler through the test suite -- they
> both had the same test results. I've also included in my
> downloading area a couple of programs that use the op/3
> declaration. New compiler archives for Mac and Sun, as well as
> sample programs and installation instructions are available from my
> site, http://www.logicaltypes.com, under the Latest Developments
> section, until such time you are ready to roll these changes into
> your repository.
>
> Although, in theory, this change should make the compiler slower in
> compiling programs, I have not noticed a slowdown on either Sun or
> Mac implementation.
>
> See you at the PADL/POPL.
>
> Sincerely,
> Doug Auclair
>
>
> library/ops.m -----
> D-Auclairs-Computer:~ dauclair$ diff
> /Volumes/2006-01-06/projects/mercury/ops.m
> /Volumes/DOUGSTICK/ops.m.~1.47.2.2.~
> 26,30d25
> <
> < % modified: January 1, 2006, DMA (Douglas M. Auclair) -- Happy New Year!
> < % changed: Added a map implementation for the Mercury syntax to allow for
> < % mutable syntax with an op/3 declaration.
> <
> 154,159d148
> < % ops__category is used to index the op_table so that
> < % lookups are semidet rather than nondet.
> < % Prefix and binary_prefix operators have ops__category `before'.
> < % Infix and postfix operators have ops__category `after'.
> < :- type ops__category ---> before ; after.
> <
> 164,165d152
> < :- import_module string, require.
> <
> 177a165,170
>>
>> % ops__category is used to index the op_table so that
>> % lookups are semidet rather than nondet.
>> % Prefix and binary_prefix operators have ops__category `before'.
>> % Infix and postfix operators have ops__category `after'.
>> :- type ops__category ---> before ; after.
>
> compiler/prog_io_typeclass.m -----
> D-Auclairs-Computer:~ dauclair$ diff
> /Volumes/2006-01-06/projects/mercury/prog_io_typeclass.m
> /Volumes/DOUGSTICK/prog_io_typeclass.m.~1.33.2.1.~
> 46d45
> < :- import_module parse_tree__prog_io_util.
> 51c50
> < :- import_module int, string, std_util, require, set, map, ops.
> ---
>> :- import_module int, string, std_util, require, set, map.
> 201,202d199
> < init_mercury_op_map(init_mercury_op_table,
> < OpMap),
> 204c201
> < Item, OpMap, _),
> ---
>> Item),
> 680,682c677
> < init_mercury_op_map(init_mercury_op_table, OpMap),
> < parse_item(DefaultModuleName, VarSet, MethodTerm, Result0,
> < OpMap, _),
> ---
>> parse_item(DefaultModuleName, VarSet, MethodTerm, Result0),
>
> compiler/prog_io_util.m -----
> D-Auclairs-Computer:~ dauclair$ diff /Volumes/DOUGSTICK/PARSER.M
> /Volumes/DOUGSTICK/parser.m.~1.44.2.2.~
> 158c158
> < FileName, Result, !IO).
> ---
>> FileName, Result, !IO).
> 166,167c166
> < FileName, String, EndPos,
> < Result).
> ---
>> FileName, String, EndPos, Result).
> 190c189
> < FileName, Tokens, Result).
> ---
>> FileName, Tokens, Result).
> D-Auclairs-Computer:~ dauclair$ vi /Volumes/DOUGSTICK/PARSER.M
> D-Auclairs-Computer:~ dauclair$ diff
> /Volumes/2006-01-06/projects/mercury/prog_io_typeclass.m
> /Volumes/DOUGSTICK/prog_io_typeclass.m.~1.33.2.1.~
> 46d45
> < :- import_module parse_tree__prog_io_util.
> 51c50
> < :- import_module int, string, std_util, require, set, map, ops.
> ---
>> :- import_module int, string, std_util, require, set, map.
> 201,202d199
> < init_mercury_op_map(init_mercury_op_table,
> < OpMap),
> 204c201
> < Item, OpMap, _),
> ---
>> Item),
> 680,682c677
> < init_mercury_op_map(init_mercury_op_table, OpMap),
> < parse_item(DefaultModuleName, VarSet, MethodTerm, Result0,
> < OpMap, _),
> ---
>> parse_item(DefaultModuleName, VarSet, MethodTerm, Result0),
> D-Auclairs-Computer:~ dauclair$ diff
> /Volumes/2006-01-06/projects/mercury/prog_io_util.m
> /Volumes/DOUGSTICK/prog_io_util.m.~1.32.2.1.~
> 29,48c29
> < :- import_module list, map, std_util, term, ops.
> <
> <
> %-----------------------------------------------------------------------------%
> < % DMA: mercury_op_map type
> <
> < :- type op_map == map(pair(string, category), op_info).
> < :- type mercury_op_map ---> mercury_op_map(table, op_map).
> < :- instance op_table(mercury_op_map).
> < :- pred init_mercury_op_map(table::in, mercury_op_map::out) is det.
> <
> < % We expose the op info so we may add information as we encounter op/3
> < % directives. This means we must also expose the category type.
> <
> < :- type op_info ---> op_info(specifier, priority).
> <
> < :- func op_specifier_from_string(string) = specifier.
> < :- func op_category_from_specifier(specifier) = category.
> <
> <
> %-----------------------------------------------------------------------------%
> <
> ---
>> :- import_module list, map, std_util, term.
> 168c149
> < :- import_module bool, string, std_util, term, set, require.
> ---
>> :- import_module bool, string, std_util, term, set.
> 595,673d575
> < % DMA mercury_op_map implementation
> <
> < op_specifier_from_string(String) = Specifier :-
> < specifier_from_string(String, Spec) ->
> < Specifier = Spec
> < ;
> < error("Unknown op specifier: " ++ String).
> <
> < :- pred specifier_from_string(string::in, specifier::out) is semidet.
> <
> < specifier_from_string("fx", fx).
> < specifier_from_string("fy", fy).
> < specifier_from_string("xf", xf).
> < specifier_from_string("yf", yf).
> < specifier_from_string("xfx", xfx).
> < specifier_from_string("yfx", yfx).
> < specifier_from_string("xfy", xfy).
> < specifier_from_string("fxx", fxx).
> < specifier_from_string("fyx", fyx).
> < specifier_from_string("fxy", fxy).
> <
> < op_category_from_specifier(fx) = before.
> < op_category_from_specifier(fy) = before.
> < op_category_from_specifier(xf) = after.
> < op_category_from_specifier(yf) = after.
> < op_category_from_specifier(xfx) = after.
> < op_category_from_specifier(yfx) = after.
> < op_category_from_specifier(xfy) = after.
> < op_category_from_specifier(fxx) = before.
> < op_category_from_specifier(fyx) = before.
> < op_category_from_specifier(fxy) = before.
> <
> < init_mercury_op_map(Table, mercury_op_map(Table, map.init)).
> <
> < :- pred lookup_info(op_map::in, pair(string, category)::in,
> < priority::out, class::out) is semidet.
> < lookup_info(Ops, Op - Cat, Priority, Class) :-
> < search(Ops, Op - Cat, op_info(Specifier, Priority)),
> < op_specifier_to_class(Specifier, Class).
> <
> < :- instance op_table(mercury_op_map) where [
> < (lookup_infix_op(mercury_op_map(Table, Ops), Op, Pri, Left, Right) :-
> < lookup_infix_op(Table, Op, P0, L0, R0) ->
> < Pri = P0,
> < Left = L0,
> < Right = R0
> < ;
> < lookup_info(Ops, Op - after, Pri, infix(Left, Right))),
> < (lookup_operator_term(mercury_op_map(Table, _), Pri, Left, Right) :-
> < lookup_operator_term(Table, Pri, Left, Right)),
> < (lookup_prefix_op(mercury_op_map(Table, Ops), Op, Pri, After) :-
> < lookup_prefix_op(Table, Op, P0, A0) ->
> < Pri = P0,
> < After = A0
> < ;
> < lookup_info(Ops, Op - before, Pri, prefix(After))),
> < (lookup_binary_prefix_op(mercury_op_map(Table, Ops), Op, Pri,
> < Left, Right) :-
> < lookup_binary_prefix_op(Table, Op, P0, L0, R0) ->
> < Pri = P0,
> < Left = L0,
> < Right = R0
> < ;
> < lookup_info(Ops, Op - before, Pri, binary_prefix(Left, Right))),
> < (lookup_postfix_op(mercury_op_map(Table, Ops), Op, Pri, Before) :-
> < lookup_postfix_op(Table, Op, P0, B0) ->
> < Pri = P0,
> < Before = B0
> < ;
> < lookup_info(Ops, Op - after, Pri, postfix(Before))),
> < (lookup_op(mercury_op_map(Table, Ops), Op) :-
> < lookup_op(Table, Op)
> < ;
> < search(Ops, Op - before, _)
> < ;
> < search(Ops, Op - after, _)),
> < (max_priority(mercury_op_map(Table, _)) = max_priority(Table)),
> < (arg_priority(mercury_op_map(Table, _)) = arg_priority(Table))
> < ].
>
> compiler/prog_io.m -----
>
> D-Auclairs-Computer:~ dauclair$ diff
> /Volumes/2006-01-06/projects/mercury/prog_io.m
> /Volumes/DOUGSTICK/prog_io.m.~1.234.2.6.~
> 54,56d53
> < % modified: December 29, 2005, DMA (Douglas M. Auclair)
> < % changed: Added the op/3 declaration implementation
> <
> 166,167c163
> < maybe_item_and_context::out,
> < mercury_op_map::in, mercury_op_map::out) is det.
> ---
>> maybe_item_and_context::out) is det.
> 176,177c172
> < maybe_item_and_context::out,
> < mercury_op_map::in, mercury_op_map::out) is det.
> ---
>> maybe_item_and_context::out) is det.
> 288,289d282
> < :- import_module ops. % DMA 2005-12-29
> <
> 616d608
> < init_mercury_op_map(init_mercury_op_table, OpMap),
> 618,619c610
> < ModuleName, RevMessages, _, _, _,
> < OpMap, _, !IO),
> ---
>> ModuleName, RevMessages, _, _, _, !IO),
> 659d649
> < init_mercury_op_map(init_mercury_op_table, Syntax),
> 661,662c651
> < RevMessages0, RevItems0, MaybeSecondTerm, Error0,
> < Syntax, Syn0, !IO),
> ---
>> RevMessages0, RevItems0, MaybeSecondTerm, Error0, !IO),
> 666c655
> < MaybeSecondItem, Syn0, Syn1),
> ---
>> MaybeSecondItem),
> 670c659
> < Error0, Error1, Syn1, !IO)
> ---
>> Error0, Error1, !IO)
> 675c664
> < Error0, Error1, Syn0, !IO)
> ---
>> Error0, Error1, !IO)
> 704,705c693
> < module_error::out, mercury_op_map::in, mercury_op_map::out,
> < io__state::di, io__state::uo) is det.
> ---
>> module_error::out, io__state::di, io__state::uo) is det.
> 708c696
> < Messages, Items, MaybeSecondTerm, Error, !Syntax, !IO) :-
> ---
>> Messages, Items, MaybeSecondTerm, Error, !IO) :-
> 720c708
> < read_term_with_op_table(!.Syntax, SourceFileName,
> MaybeFirstTerm, !IO),
> ---
>> parser__read_term(SourceFileName, MaybeFirstTerm, !IO),
> 722,723c710
> < process_read_term(RootModuleName, MaybeFirstTerm, MaybeFirstItem,
> < !Syntax),
> ---
>> process_read_term(RootModuleName, MaybeFirstTerm, MaybeFirstItem),
> 735c722
> < !Syntax, !IO)
> ---
>> !IO)
> 842,850c829,834
> < message_list::in, message_list::out,
> < item_list::in, item_list::out,
> < module_error::in,module_error::out,
> < mercury_op_map::in,
> < io__state::di, io__state::uo) is det.
> <
> < read_items_loop(ModuleName, SourceFileName, !Msgs, !Items, !Error,
> < Syn0, !IO) :-
> < read_item(ModuleName, SourceFileName, MaybeItem, !IO, Syn0, Syn1),
> ---
>> message_list::in, message_list::out, item_list::in, item_list::out,
>> module_error::in,module_error::out, io__state::di, io__state::uo)
>> is det.
>>
>> read_items_loop(ModuleName, SourceFileName, !Msgs, !Items, !Error, !IO) :-
>> read_item(ModuleName, SourceFileName, MaybeItem, !IO),
> 852c836
> < !Msgs, !Items, !Error, Syn1, !IO).
> ---
>> !Msgs, !Items, !Error, !IO).
> 856,861c840,843
> < :- pred read_items_loop_2(maybe_item_or_eof::in, module_name::in,
> file_name::in,
> < message_list::in, message_list::out,
> < item_list::in, item_list::out,
> < module_error::in, module_error::out,
> < mercury_op_map::in,
> < io__state::di, io__state::uo) is det.
> ---
>> :- pred read_items_loop_2(maybe_item_or_eof::in, module_name::in,
>> file_name::in, message_list::in, message_list::out,
>> item_list::in, item_list::out, module_error::in, module_error::out,
>> io__state::di, io__state::uo) is det.
> 865c847
> < read_items_loop_2(eof, _ModuleName, _SourceFile, !Msgs, !Items,
> !Error, _, !IO).
> ---
>> read_items_loop_2(eof, _ModuleName, _SourceFile, !Msgs, !Items,
>> !Error, !IO).
> 869c851
> < SourceFileName, !Msgs, !Items, _Error0, Error,
> Syntax, !IO) :-
> ---
>> SourceFileName, !Msgs, !Items, _Error0, Error, !IO) :-
> 878c860
> < Error1, Error, Syntax, !IO).
> ---
>> Error1, Error, !IO).
> 881c863
> < _Error0, Error, Syntax, !IO) :-
> ---
>> _Error0, Error, !IO) :-
> 887c869
> < Error1, Error, Syntax, !IO).
> ---
>> Error1, Error, !IO).
> 890c872
> < !Msgs, !Items, !Error, Syntax, !IO) :-
> ---
>> !Msgs, !Items, !Error, !IO) :-
> 964c946
> < Syntax, !IO).
> ---
>> !IO).
> 997,1004c979,983
> < io::di, io::uo,
> < mercury_op_map::in, mercury_op_map::out)
> < is det.
> <
> < read_item(ModuleName, SourceFileName, MaybeItem, !IO, !Syntax) :-
> < parser__read_term_with_op_table(!.Syntax, SourceFileName,
> < MaybeTerm, !IO),
> < process_read_term(ModuleName, MaybeTerm, MaybeItem, !Syntax).
> ---
>> io::di, io::uo) is det.
>>
>> read_item(ModuleName, SourceFileName, MaybeItem, !IO) :-
>> parser__read_term(SourceFileName, MaybeTerm, !IO),
>> process_read_term(ModuleName, MaybeTerm, MaybeItem).
> 1007,1008c986
> < maybe_item_or_eof::out,
> < mercury_op_map::in, mercury_op_map::out) is det.
> ---
>> maybe_item_or_eof::out) is det.
> 1010c988
> < process_read_term(_ModuleName, eof, eof) --> [].
> ---
>> process_read_term(_ModuleName, eof, eof).
> 1012,1013c990,991
> < syntax_error(ErrorMsg, LineNumber)) --> [].
> < process_read_term(ModuleName, term(VarSet, Term), MaybeItemOrEof) -->
> ---
>> syntax_error(ErrorMsg, LineNumber)).
>> process_read_term(ModuleName, term(VarSet, Term), MaybeItemOrEof) :-
> 1015c993
> < { convert_item(MaybeItem, MaybeItemOrEof) }.
> ---
>> convert_item(MaybeItem, MaybeItemOrEof).
> 1023c1001
> < parse_item(ModuleName, VarSet, Term, Result, !Syntax) :-
> ---
>> parse_item(ModuleName, VarSet, Term, Result) :-
> 1028c1006
> < parse_decl(ModuleName, VarSet, Decl, Result, !Syntax)
> ---
>> parse_decl(ModuleName, VarSet, Decl, Result)
> 1034,1035c1012,1013
> < parse_dcg_clause(ModuleName, VarSet,
> < DCG_H, DCG_B, DCG_Context, Result)
> ---
>> parse_dcg_clause(ModuleName, VarSet, DCG_H, DCG_B,
>> DCG_Context, Result)
> 1097c1075
> < error(ErrMessage, Term)) :-
> ---
>> error(ErrMessage, Term)) :-
> 1121c1099
> < parse_decl(ModuleName, VarSet, F, Result) -->
> ---
>> parse_decl(ModuleName, VarSet, F, Result) :-
> 1130,1131c1108
> < maybe_item_and_context::out,
> < mercury_op_map::in, mercury_op_map::out) is det.
> ---
>> maybe_item_and_context::out) is det.
> 1133c1110
> < parse_decl_2(ModuleName, VarSet, F, Attributes, Result, !Syntax) :-
> ---
>> parse_decl_2(ModuleName, VarSet, F, Attributes, Result) :-
> 1142c1119
> < NewAttributes, Result, !Syntax)
> ---
>> NewAttributes, Result)
> 1145c1122
> < Attributes, R, !Syntax)
> ---
>> Attributes, R)
> 1155c1132
> < % process_decl(ModuleName, VarSet, Atom, Args, Attributes, Result)
> ---
>> % process_decl(ModuleName, VarSet, Attributes, Atom, Args, Result)
> 1161,1162c1138
> < decl_attrs::in, maybe1(item)::out,
> < mercury_op_map::in, mercury_op_map::out) is semidet.
> ---
>> decl_attrs::in, maybe1(item)::out) is semidet.
> 1164,1165c1140
> < process_decl(ModuleName, VarSet, "type", [TypeDecl], Attributes, Result,
> < !_Syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "type", [TypeDecl], Attributes, Result) :-
> 1168,1169c1143
> < process_decl(ModuleName, VarSet, "pred", [PredDecl], Attributes, Result,
> < !_Syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "pred", [PredDecl], Attributes, Result) :-
> 1172,1173c1146
> < process_decl(ModuleName, VarSet, "func", [FuncDecl], Attributes, Result,
> < !_Syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "func", [FuncDecl], Attributes, Result) :-
> 1176,1177c1149
> < process_decl(ModuleName, VarSet, "mode", [ModeDecl], Attributes, Result,
> < !_syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "mode", [ModeDecl], Attributes, Result) :-
> 1180,1181c1152
> < process_decl(ModuleName, VarSet, "inst", [InstDecl], Attributes, Result,
> < !_syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "inst", [InstDecl], Attributes, Result) :-
> 1186c1157
> < Result, !_syntax) :-
> ---
>> Result) :-
> 1191c1162
> < Result, !_syntax) :-
> ---
>> Result) :-
> 1196c1167
> < Result, !_syntax) :-
> ---
>> Result) :-
> 1200,1216c1171,1262
> < process_decl(_ModuleName, VarSet, "op", OpSpec, Attributes, Result,
> < Map0, Map1) :-
> < OpSpec = [functor(integer(Priority), _, _),
> < functor(atom(Spec), _, _),
> < OpFunctor] ->
> < Map0 = mercury_op_map(T, M0),
> < Map1 = mercury_op_map(T, Map),
> < OpFunctor = functor(atom(Op), _, _),
> < Specifier = op_specifier_from_string(Spec),
> < det_insert(M0, Op - op_category_from_specifier(Specifier),
> < op_info(Specifier, Priority), Map),
> < parse_symlist_decl(parse_op_specifier, make_op, make_use,
> < OpFunctor, Attributes, VarSet, Result)
> < ;
> < Result = error("Bad op format", functor(atom("op"), OpSpec,
> < context("meh", 42))),
> < Map1 = Map0.
> ---
>> process_decl(_ModuleName, VarSet, "import_sym", [SymSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_symbol_specifier, make_sym, make_import,
>> SymSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_sym", [SymSpec],
>> Attributes, Result) :-
>> parse_symlist_decl(parse_symbol_specifier, make_sym, make_use,
>> SymSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_sym", [SymSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_symbol_specifier, make_sym, make_export,
>> SymSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_pred", [PredSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_predicate_specifier, make_pred, make_import,
>> PredSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_pred", [PredSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_predicate_specifier, make_pred, make_use,
>> PredSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_pred", [PredSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_predicate_specifier, make_pred, make_export,
>> PredSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_func", [FuncSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_function_specifier, make_func, make_import,
>> FuncSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_func", [FuncSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_function_specifier, make_func, make_use,
>> FuncSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_func", [FuncSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_function_specifier, make_func, make_export,
>> FuncSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_cons", [ConsSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_constructor_specifier, make_cons,
>> make_import,
>> ConsSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_cons", [ConsSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_constructor_specifier, make_cons, make_use,
>> ConsSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_cons", [ConsSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_constructor_specifier, make_cons,
>> make_export,
>> ConsSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_type", [TypeSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_type_specifier, make_type, make_import,
>> TypeSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_type", [TypeSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_type_specifier, make_type, make_use,
>> TypeSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_type", [TypeSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_type_specifier, make_type, make_export,
>> TypeSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_adt", [ADT_Spec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_adt_specifier, make_adt, make_import,
>> ADT_Spec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "use_adt", [ADT_Spec],
>> Attributes, Result) :-
>> parse_symlist_decl(parse_adt_specifier, make_adt, make_use,
>> ADT_Spec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_adt", [ADT_Spec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_adt_specifier, make_adt, make_export,
>> ADT_Spec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "import_op", [OpSpec], Attributes,
>> Result) :-
>> parse_symlist_decl(parse_op_specifier, make_op, make_import,
>> OpSpec, Attributes, VarSet, Result).
> 1218,1219c1264,1272
> < process_decl(_ModuleName, VarSet0, "interface", [], Attributes, Result,
> < !_syntax) :-
> ---
>> process_decl(_ModuleName, VarSet, "use_op", [OpSpec], Attributes, Result) :-
>> parse_symlist_decl(parse_op_specifier, make_op, make_use,
>> OpSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet, "export_op", [OpSpec],
>> Attributes, Result) :-
>> parse_symlist_decl(parse_op_specifier, make_op, make_export,
>> OpSpec, Attributes, VarSet, Result).
>>
>> process_decl(_ModuleName, VarSet0, "interface", [], Attributes, Result) :-
> 1224,1225c1277
> < process_decl(_ModuleName, VarSet0, "implementation", [],
> Attributes, Result,
> < !_syntax) :-
> ---
>> process_decl(_ModuleName, VarSet0, "implementation", [],
>> Attributes, Result) :-
> 1230,1231c1282
> < process_decl(ModuleName, VarSet, "external", Args, Attributes, Result,
> < !_syntax) :-
> ---
>> process_decl(ModuleName, VarSet, "external", Args, Attributes, Result) :-
> 1253c1304
> < Result, !_syntax) :-
> ---
>> Result) :-
> 1256c1307
> < Result0 = ok(ModuleNameSym),
> ---
>> Result0 = ok(ModuleNameSym),
> 1266c1317
> < Attributes, Result, !_syntax) :-
> ---
>> Attributes, Result) :-
> 1280c1331
> < Attributes, Result, !_syntax) :-
> ---
>> Attributes, Result) :-
> 1300,1301c1351
> < process_decl(ModuleName, VarSet, "pragma", Pragma, Attributes, Result,
> < !_sytax):-
> ---
>> process_decl(ModuleName, VarSet, "pragma", Pragma, Attributes, Result):-
> 1305,1306c1355
> < process_decl(ModuleName, VarSet, "promise", Assertion, Attributes, Result,
> < !_syntax):-
> ---
>> process_decl(ModuleName, VarSet, "promise", Assertion, Attributes, Result):-
> 1311c1360
> < Result, !_syntax):-
> ---
>> Result):-
> 1316c1365
> < Result, !_syntax):-
> ---
>> Result):-
> 1318c1367
> < Result).
> ---
>> Result).
> 1321c1370
> < Attributes, Result, !_syntax):-
> ---
>> Attributes, Result):-
> 1323c1372
> < Attributes, Result).
> ---
>> Attributes, Result).
> 1325,1326c1374
> < process_decl(ModuleName, VarSet, "typeclass", Args, Attributes, Result,
> < !_syntax):-
> ---
>> process_decl(ModuleName, VarSet, "typeclass", Args, Attributes, Result):-
> 1330,1331c1378
> < process_decl(ModuleName, VarSet, "instance", Args, Attributes, Result,
> < !_syntax):-
> ---
>> process_decl(ModuleName, VarSet, "instance", Args, Attributes, Result):-
> 1336,1337c1383,1384
> < [VersionNumberTerm, ModuleNameTerm, VersionNumbersTerm],
> < Attributes, Result, !_syntax) :-
> ---
>> [VersionNumberTerm, ModuleNameTerm, VersionNumbersTerm],
>> Attributes, Result) :-
> 1383c1430
> < term::out) is semidet.
> ---
>> term::out) is semidet.
> 3572a3620,3622
>> :- pred make_op(list(op_specifier)::in, sym_list::out) is det.
>> make_op(X, op(X)).
>>
> 3621a3672,3675
>> ; Functor = "op" ->
>> parse_op_specifier(Term, Result0),
>> process_maybe1(make_op_symbol_specifier, Result0,
>> Result)
> 3662a3717,3720
>> :- pred make_op_symbol_specifier(op_specifier::in,
>> sym_specifier::out) is det.
>>
>> make_op_symbol_specifier(OpSpec, op(OpSpec)).
>>
> 3674,3693d3731
> < :- pred make_op(list(op_specifier)::in, sym_list::out) is det.
> < make_op(X, op(X)).
> <
> <
> %-----------------------------------------------------------------------------%
> <
> < % For the moment, an OpSpecifier is just a symbol name specifier.
> < % XXX We should allow specifying the fixity of an operator
> <
> < :- pred parse_op_specifier(term::in, maybe1(op_specifier)::out) is det.
> <
> < parse_op_specifier(Term, Result) :-
> < parse_symbol_name_specifier(Term, R),
> < process_maybe1(make_op_specifier, R, Result).
> <
> < :- pred make_op_specifier(sym_name_specifier::in,
> op_specifier::out) is det.
> <
> < make_op_specifier(X, sym(X)).
> <
> <
> %-----------------------------------------------------------------------------%
> <
> 4144a4183,4197
>>
>> %-----------------------------------------------------------------------------%
>>
>> % For the moment, an OpSpecifier is just a symbol name specifier.
>> % XXX We should allow specifying the fixity of an operator
>>
>> :- pred parse_op_specifier(term::in, maybe1(op_specifier)::out) is det.
>>
>> parse_op_specifier(Term, Result) :-
>> parse_symbol_name_specifier(Term, R),
>> process_maybe1(make_op_specifier, R, Result).
>>
>> :- pred make_op_specifier(sym_name_specifier::in, op_specifier::out) is det.
>>
>> make_op_specifier(X, sym(X)).
>
> compiler/basics.m -----
>
> There's an extra (redundant) import of the string module.

No comments:

Post a Comment