caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Error location reporting in Menhir
@ 2007-03-30 14:02 Joel Reymont
  2007-03-30 19:36 ` Francois Pottier
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2007-03-30 14:02 UTC (permalink / raw)
  To: Caml List; +Cc: Francois.Pottier

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 }

I don't do anything special in the lexer to adjust lexeme positions.

How do I rewrite my error reporting for Menhir?

	Thanks, Joel

--
http://wagerlabs.com/






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Error location reporting in Menhir
  2007-03-30 14:02 Error location reporting in Menhir Joel Reymont
@ 2007-03-30 19:36 ` Francois Pottier
  0 siblings, 0 replies; 2+ messages in thread
From: Francois Pottier @ 2007-03-30 19:36 UTC (permalink / raw)
  To: Joel Reymont; +Cc: Caml List


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/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-30 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 14:02 Error location reporting in Menhir Joel Reymont
2007-03-30 19:36 ` Francois Pottier

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