[DGD] error reporting with parse_string()

Noah Gibbs noah_gibbs at yahoo.com
Mon Oct 22 07:24:38 CEST 2007


  You are correct about all of this.  Basically, if the file doesn't parse at
all it's hard to give good errors.  Depending on your grammar, one possibility
is to cut up your file using a very simple parse_string grammar (one token is,
say, "***section_end", and the other token type is everything else) to cut up
your file into sections and then use the more complicated parse_string grammar
to parse each section.  Not only are there potentially some efficiency benefits
if your grammar has ambiguities (keep you from shooting yourself in the foot
too badly), but you can also say pretty definitively which section doesn't
parse.  That's a pretty decent start.

--- Carter Cheng <carter_cheng at yahoo.com> wrote:

> Hi Noah,
> 
> Thanks for this. It does give some insight into how parse_string works-
> though I am still uncertain how to generate error messages 
> in cases where the file is yet unparseable. The only technique I know to cope
> with this is some form of local error correction and
> dumping the state of the parser to some extent where the correction takes
> place. My knowledge of coping with errors in
> parsers is limited and books I have on hand seem to suggest that most parsers
> rely on special procedures to cope with it. Anyhow
> thanks again.
> 
> Regards,
> 
> Carter Cheng.
> 
> 
> 
> 
> 
>     
> 
> 
> 
> ___________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the DGD mailing list