[antlr-interest] Development of an XQuery parser with full-text extensions, project report
Gavin Lambert
antlr at mirality.co.nz
Thu Dec 27 12:36:03 PST 2007
At 04:00 28/12/2007, Guntis Ozols wrote:
>Will you be hapy with a database tool which happily deletes all
>rows from the table because of misspelled where clause (on the
>way, printing humble error message somewhere on the server
>console), what kind of reliability is that?
Obviously you shouldn't do that, and if you've got something where
that's a possibility, it means that you're probably doing the
wrong thing in your parser actions.
When you've got a case where the input may be invalid (which is
most of the time), you should ensure that your parser actions
don't have side-effects -- they should merely record state (eg.
similar to building an AST, but a bit less formal) or queue up
tasks that need to be performed without actually taking any
action. Then your main program actions it all only if it managed
to complete the parse without errors. (It might be a good idea to
change to actually build an AST in your parser.)
And incidentally, I'm not sure that was the best example -- SQL is
a particularly unforgiving language (oops, I just accidentally
pressed ENTER after typing "DELETE FROM Paychecks"; I was going to
enter a WHERE clause, honest!).
More information about the antlr-interest
mailing list