grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Grammatica-users] Catch All production


From: Per Cederberg
Subject: Re: [Grammatica-users] Catch All production
Date: Tue, 22 Mar 2005 23:24:43 +0100

Well, there is not really any support for a default "exception"
production. Depending on what you want though, you can create
it yourself by modifying your grammar in like this:

1. Add a default token (last) to skip any unmatched characters:
   SKIP_ANY = <<.|\n>> %ignore%

2. Add dummy productions on places where you wish to skip stuff:
   Prod = A Skippy* B ;
   Skippy = Token1 | Token2 | ... | TokenN ;

Doing this well might take some practice so that you can accept
all the "common" errors without enlarging the grammar too much.
If you really want accept any erroneous input, maybe Grammatica
isn't the perfect tool for the job.

The Grammatica error handling does something similar though,
attempting to recover from broken input by skipping tokens until
it can continue parsing. Maybe one could modify that to just
skip unrecognized input instead of stopping the parse tree
construction and logging parse errors.

/Per

On tue, 2005-03-22 at 13:40 -0700, Anant Mistry wrote:
> 
> Does grammatica have a way of defining a "catch all" production i.e.
> if your input does not meet the parsing rules of the grammar, then
> jump to a generic or default  production?
> 
> Thanks
> 
> Anant






reply via email to

[Prev in Thread] Current Thread [Next in Thread]