[m-dev.] Added module qualified backquoted operators to the syntax
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Dec 22 22:18:56 AEDT 2003
On 22-Dec-2003, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Index: doc/reference_manual.texi
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
> retrieving revision 1.283
> diff -u -r1.283 reference_manual.texi
> --- doc/reference_manual.texi 5 Dec 2003 05:15:10 -0000 1.283
> +++ doc/reference_manual.texi 22 Dec 2003 05:31:25 -0000
> @@ -367,8 +367,8 @@
> is a valid tuple term.
>
> An operator term is a term specified using operator notation, as in Prolog.
> -Operators can also be formed by enclosing a variable or name between grave
> -accents (backquotes). Any variable or name may
> +Operators can also be formed by enclosing a variable or (possibly module
> +qualified) name between grave accents (backquotes). Any variable or name may
> be used as an operator in this way.
s/or/or a/
Also, this section precedes the "Modules" chapter which describes module
qualifiers, so there should be a forward reference to that section.
So I suggest
Operators can also be formed by enclosing a name, a module
qualified name (@pxref{The module system}), or a variable between
grave accents (backquotes). Any name or variable may be used
as an operator in this way.
> Index: library/parser.m
> +:- pred parse_backquoted_operator_2(maybe(term(T)), maybe(term(T)),
> + string, string,
> + parser__state(Ops, T), parser__state(Ops, T)) <= op_table(Ops).
> +:- mode parse_backquoted_operator_2(in, out, in, out, in, out) is semidet.
> +
> +parse_backquoted_operator_2(Qualifier0, Qualifier, OpName0, OpName) -->
> + ( if
> + parser__get_token(name(ModuleSeparator), _),
> + {
> + ModuleSeparator = "."
> + ;
> + ModuleSeparator = ":"
> + },
> + parser__get_token(name(OpName1), Context),
> + { OpName1 \= "`" }
> + then
> + parser__get_term_context(Context, TermContext),
> + { QTerm1 = term__functor(atom(OpName0), [], TermContext) },
Here you are using the context of OpName1 for OpName0.
The context of this term should be the context for the OpName0 token,
not the context for the OpName1 token.
parse_backquoted_operator//3 should not ignore the context for the first
token; it should pass it down to parse_backquoted_operator_2 so that
you can use it here.
> + {
> + Qualifier0 = no,
> + Qualifier1 = yes(QTerm1)
> + ;
> + Qualifier0 = yes(QTerm0),
> + Qualifier1 = yes(functor(atom("."), [QTerm0, QTerm1],
> + TermContext))
> + },
The context here should be the context for the ModuleSeparator token.
The test case should include tests of symbols qualified with two and
three module qualifiers.
Otherwise that looks fine.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list