Version française
Home     About     Download     Resources     Contact us    
Browse thread
Error location reporting in Menhir
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Francois Pottier <Francois.Pottier@i...>
Subject: Re: Error location reporting in Menhir

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/