[mercury-users] Custom declarations and preprocessors.

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Apr 16 01:15:12 AEST 2000


On 14-Apr-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> Response to Tyson's comments:
> 
> > While several people have said that they prefer putting this kind of
> > information in comments, I personally believe that directives are
> > the way to go.
> > 
> > Why?  Mostly because it simplifies implementing various things and
> > allows a much smoother path towards integration into the language.
> 
> I'm not sure I want this integrated into the language.  It increases
> the burden on later compiler writers and is entirely orthogonal to
> what the compiler is there for.

Getting the compiler to ignore certain declarations is very very
easy to implement.  So as long as implementations are not _required_
to interpret them, they don't impose any significant additional
burden on later compiler writers.

> > - Easier to implement (don't have write crappy perl regular 
> > expressions
> >   to parse Mercury, just re-use existing Mercury parsers).
> 
> Solution: (a) the PERL (or something more sane) records the line
> numbers where comments start/end; (b) the Mercury parser spots the
> surrounding declarations/clauses; (c) we just match up the line
> numbers.  Easy!

This approach is much more complicated and I think it has some significant
flaws.

The Perl (or alternative) code will have to do much of the work of tokenizing
Mercury source code, in order to properly recognize comments.  So you will
have to reimplement a substantial fraction of the Mercury parser.

The issue of recognizing line numbers will be more complicated
in the case where the Mercury code was generated by a preprocessor.
You want the line numbers to reflect the original source code,
but this means that the Perl (or alternative) needs to handle
the `:- pragma source_file("...").' declaration and `#<line>' directive,
which requires handling a larger portion of Mercury syntax,
and it also makes the process of matching up the line numbers a
lot more difficult.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list