Off the top of my head, and not 100% sure it's helpful in your context, but here goes:
A technique I'd like to see used more is "error rules" -- rules which represent things which should *not* appear in the parse. These have not been used much because traditional parsers have trouble enough parsing a full set of correct rules, so that any technique that involves more rules is very problematic. Marpa::R2 has a special "bail out" static method <https://metacpan.org/pod/Marpa::R2::Semantics#Bailing-out-of-parse-evaluation>, which can be used in the semantic action of an error rules. On Tue, Dec 30, 2014 at 1:06 PM, Zeev Atlas <[email protected]> wrote: > Is there a way to tell Marpa to ignore a certain, obviously wrong, element > in the input. > > Case in mind a language that by at large adhere with the BNF, but a vendor > added some extensions without publishing the proper BNF and I would like to > postpone doing that task for various reasons. > > Example: SQL Server variety of SQL 2003, keyword TOP: > > SELECT TOP 5 column1, column2 FROM table1; > > This is a valid SQL 2003 SELECT statement except of the 'TOP 5' > > What I have in mind is something like this > > my $grammar = Marpa::R2::Scanless::G->new( { source => \$dsl, Handlers => > {UNKNOWNTOKEN => \&handle_unknowntoken}}); > > Now handle_unknowntoken could potentially see the rest of the input from > the point where the unknown token was found, report it, make it into spaces > and return to the module with a code that say, continue anyway with what > you see, or die the way the module is doing now. > > I do not know whether this option is available in any shape or whether it > is at all feasible. > > Thanks > ZA > > > -- > You received this message because you are subscribed to the Google Groups > "marpa parser" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "marpa parser" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
