caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Francois Pottier <Francois.Pottier@inria.fr>
To: Joel Reymont <joelr1@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: Error location reporting in Menhir
Date: Fri, 30 Mar 2007 21:36:35 +0200	[thread overview]
Message-ID: <20070330193635.GA598@yquem.inria.fr> (raw)
In-Reply-To: <7DE6C068-8889-4A8E-9C98-66471DDD9878@gmail.com>


Hello,

On Fri, Mar 30, 2007 at 03:02:06PM +0100, Joel Reymont wrote:
> I currently retrieve location like this during parser errors:
> 
>   let rhs_loc n = (Parsing.rhs_start_pos n, Parsing.rhs_end_pos n)
> 
> I then report it like this:
> 
>   let syntax_error s num =
>     parser_error s (rhs_loc num)
> 
> In my grammar I report errors like this:
> 
>   | INPUT COLON input_decs error { syntax_error "Missing semicolon" 4 }
> 
> How do I rewrite my error reporting for Menhir?

Probably something like this:

    | INPUT COLON input_decs error
      { parser_error "Missing semicolon" ($startpos($4), $endpos($4)) }

$startpos and $endpos are keywords and can be used only within a semantic
action, so you can no longer define auxiliary functions such as your rhs_loc.

Hope this helps,

-- 
François Pottier
Francois.Pottier@inria.fr
http://cristal.inria.fr/~fpottier/


      reply	other threads:[~2007-03-30 19:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-30 14:02 Joel Reymont
2007-03-30 19:36 ` Francois Pottier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070330193635.GA598@yquem.inria.fr \
    --to=francois.pottier@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=joelr1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).