[m-dev.] '|' as an operator

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 11 14:31:58 AEDT 2003


On 11-Feb-2003, David Overton <dmo at cs.mu.OZ.AU> wrote:
> We have been using `|' as an operator in HAL using the SICstus reader
> (which treats it the same as `;', except in lists).  Now that the HAL
> compiler is compiling to Mercury, we are using lexer.m from the Mercury
> library instead.  Unfortunately, lexer.m treats `|' as a special token
> `ht_sep' so it is not possible to define it as an operator.

The reason lexer.m treats `|' as a special token is because that is
what ISO Prolog specifies.

> It would seem to me that `|' only needs to be treated as a special token
> when we are inside a [ ... ] construct.  My plan is to change lexer.m so
> that `|' produces the token `name("|")' and then changing parser.m to
> use `name("|")' instead of `ht_sep' when parsing lists.  This would then
> allow `|' to also be defined as an operator.
> 
> Can anyone see any problem with this?

Well, if `|' is defined as an operator with priority =< arg_priority, then
there would be no way to use `|' in list syntax -- the parser would always
prefer to parse it as an operator.  Furthermore, in Mercury currently
arg_priority is 1201, i.e. *all* operators have priority =< arg_priority.

-- 
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