[mercury-users] MMC Errorformat for Vim?

Ondrej Bojar oboj7042 at ss1000.ms.mff.cuni.cz
Thu Dec 13 21:41:26 AEDT 2001


Finally, I solved it. :-)

Just one sentence in the help for "errorformat" is missing: The
patterns in the list are processed in left-to-right order. The first
matching is used to decide what to do with the input line.

Therefore:

set errorformat=%+C%f:%l:\ \ %m,%A%f:%l:\ %m,%-GFor\ more\ info%.%#

is the simplest solution to parse errors such as:
say.m:020: In `frame2phrase(in, out, in, in, out)':
say.m:020:   error: determinism declaration not satisfied.
say.m:020:   Declared `multi', inferred `nondet'.
say.m:227:   call to `share_among_slots(in, out)' can fail.
For more information, try recompiling with `-E'.

Then :cf say.err shows:

(1 of 1): In `frame2phrase(in, out, in, in, out)': say.m:020:  error:
determinism declaration not satisfied. say.m:020: Declared `multi',
inferred `nondet'. say.m:227:  call to `share_among_slots(in, out)' can
fail.

To see the whole message, one has to :set cmdheight=6 or such. (I spent
two hours searching for the option :-)

Explanation is this:

  %+C%f:%l:\ \ %m   ... tells vim that lines 2-4 of the example
                        are continuations
                        The '+' before C makes vim include the whole line
                        in the message, including "say.m:227:"
                        This is needed if you want to know other line
                        numbers as well, not just the first one.
  %A%f:%l:\ %m  ... Matches the first line of an error. This pattern has
                    to come *after* the pattern for error continuation,
                    because error beginning is a submatch of error conti-
                    nuation. (They differ just in level of indentation.)

  %-GFor\ more\ info%.%#  ... finally tells vim to ignore the message
                       For more information, try recompiling with `-E'.

Other comments:
  \   backslash is needed to escape space in the :set command
  ,   comma delimits the patterns
  %.%#   is a "shortcut" ;-) for ".*" in vim

So this is it, Andrew.

On Fri, 7 Dec 2001, Ralph Becket wrote:
> Ondrej Bojar, Thursday,  6 December 2001:
> > Hi.
> >
> > I use Vim to edit Mercury sources. Doesn't anyone know how to set the
> > errorformat variable in Vim to treat Mercury's multiline error messages
> > properly? (Vim surely supports that but I find it quite tricky to set it
> > correctly.
>
> I spent an hour or two looking at this before giving up (which is not to
> say that a sensible, low-effort solution is possible).
>
> I just open a second Vim window for the .err file and switch between
> them.
>
> The local custom here, though, is to use the `error' program to splice
> the .err messages directly with your source code.
>
> - Ralph
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
>

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