简体   繁体   中英

Is there a BNF grammar available for SQL?

I'd rather not create the grammar myself. I did download a 'grammar' but it is written in a non-standard form for ANTLR or Yacc and it contains lexer statements. It would take me some time to separate the two and to introduce the correct syntax for a parser generator.

There are lots of SQL grammars suitable for parser generators, since most SQL processors use parser generators to produce their parsers. These might or might not serve your needs, depending on which SQL dialect you are interested in, and which parser generator you are planning on using.

Here are a few examples. These are all taken from official code repositories for the respective databases, which I believe avoids the "opinion-based" criterion for avoiding resource requests. There are also many non-official grammars scattered around the internet, particularly on Github, but not all of them are correct or usable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM