Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!howland.reston.ans.net!math.ohio-state.edu!uwm.edu!msunews!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Prolog syntax
Message-ID: <9512503.12950@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <9511221.23905@mulga.cs.mu.OZ.AU> <3nkjnc$q0o@goanna.cs.rmit.edu.au> <9512019.12772@mulga.cs.mu.OZ.AU> <3o55f0$c1m@goanna.cs.rmit.edu.au>
Date: Thu, 4 May 1995 17:06:28 GMT
Lines: 43

ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:

>zs@munta.cs.mu.OZ.AU (Zoltan Somogyi) writes:
>    Neither Mercury's nor NU-Prolog's error message was all that helpful
>    beyond giving me the name of the predicate that had the error.
>
>But this is not a fact about Prolog syntax.  It is a fact about the
>Mercury and NU-Prolog implementations.

Richard O'Keefe is absolutely right here.

I finally got around to testing out this example.  Zoltan is being a
little bit unfair to NU-Prolog - NU-Prolog's message is not ideal, and
in particular fails to state the line number where the problem occurs,
but it do a reasonable job of pinpointing the token causing the error:

ERROR Unexpected punctuation, expecting - )
 mercury_compile__semantic_pass_by_phases(...) --> globals__io_lookup_bool_option(...) , mercury_compile__typecheck(...) , maybe_report_stats(...) , mercury_compile__maybe_dump_hlds(...) ,{...} , globals__io_lookup_bool_option(...) , ({...} -> mercury_compile__modecheck(...) , maybe_report_stats(...) , mercury_compile__maybe_dump_hlds(...) ***HERE***>. 

ERROR Unexpected punctuation, expecting - . 
{...} , globals__io_lookup_bool_option(...) , (...) ,{...} , (...) ;{...} ,{...} ***HERE***>). 

Zoltan's criticism of the Mercury parser's error message is valid, but
only applies to _yesterday's_ Mercury parser, since the reason for the
poor error message in this case was a simple bug in the parser that I
have now fixed!

Today's Mercury parser now reports the following error messages:

	zs.m:14: Syntax error at token `. ': expecting `)' or operator.
	zs.m:56: Syntax error at token `)': operator or `.' expected.

The first message pinpoints the line and token at which the error
occurred and even does a reasonable job of explaining the cause.

The upshot of all this is that Zoltan's example is not really relevant
to my original query which started this thread, except as an example of
the sort of syntax errors for which Prolog parsers can easily give good
error messages.

--
Fergus "will flame^H^H^H^H^Hconstructively criticize even his own
PhD supervisor" Henderson ;-)
